diff options
author | Jing Yu <jingyu@google.com> | 2009-11-05 15:11:04 -0800 |
---|---|---|
committer | Jing Yu <jingyu@google.com> | 2009-11-05 15:11:04 -0800 |
commit | df62c1c110e8532b995b23540b7e3695729c0779 (patch) | |
tree | dbbd4cbdb50ac38011e058a2533ee4c3168b0205 /gcc-4.3.1/libstdc++-v3/testsuite/backward | |
parent | 8d401cf711539af5a2f78d12447341d774892618 (diff) | |
download | toolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.tar.gz toolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.tar.bz2 toolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.zip |
Check in gcc sources for prebuilt toolchains in Eclair.
Diffstat (limited to 'gcc-4.3.1/libstdc++-v3/testsuite/backward')
9 files changed, 514 insertions, 0 deletions
diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/11460.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/11460.cc new file mode 100644 index 000000000..8d1ec2338 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/11460.cc @@ -0,0 +1,72 @@ +// { dg-options "-Wno-deprecated" } +// Copyright (C) 2003, 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <strstream> +#include <testsuite_hooks.h> + +class Buf : public std::strstreambuf +{ +public: + Buf(const char* p, std::streamsize n) + : std::strstreambuf(p, n) + { } + + int_type pub_pbackfail(int_type c = traits_type::eof()) + { + return pbackfail(c); + } +}; + +// libstdc++/11460 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::strstreambuf::traits_type Traits; + const char str[] = "a\xff"; + + Buf buf(str, 2); + + Traits::int_type a = Traits::to_int_type('a'); + VERIFY( buf.sbumpc() == a ); + VERIFY( buf.sungetc() == a ); + VERIFY( buf.sbumpc() == a ); + VERIFY( buf.sputbackc('a') == a ); + VERIFY( buf.sbumpc() == a ); + VERIFY( buf.pub_pbackfail() != Traits::eof() ); + VERIFY( buf.sbumpc() == a ); + VERIFY( buf.pub_pbackfail(a) == a ); + buf.sbumpc(); + + Traits::int_type xff = Traits::to_int_type('\xff'); + VERIFY( buf.sbumpc() == xff ); + VERIFY( buf.sungetc() == xff ); + VERIFY( buf.sbumpc() == xff ); + VERIFY( buf.sputbackc('\xff') == xff ); + VERIFY( buf.sbumpc() == xff ); + VERIFY( buf.pub_pbackfail() != Traits::eof() ); + VERIFY( buf.sbumpc() == xff ); + VERIFY( buf.pub_pbackfail(xff) == xff ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/1.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/1.cc new file mode 100644 index 000000000..faa97d6f2 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/1.cc @@ -0,0 +1,106 @@ +// { dg-options "-Wno-deprecated" } + +// Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// hash_map (SGI extension) + +#include <cstdlib> +#include <string> +#include <hash_map> +#include <testsuite_hooks.h> + +namespace __gnu_cxx +{ + using std::string; + + inline size_t hash_string(const char* s) + { + unsigned long h; + for (h=0; *s; ++s) { + h = 5*h + *s; + } + return size_t(h); + } + + template<class T> struct hash<T *> + { + size_t operator()(const T *const & s) const + { return reinterpret_cast<size_t>(s); } + }; + + template<> struct hash<string> + { + size_t operator()(const string &s) const { return hash_string(s.c_str()); } + }; + + template<> struct hash<const string> + { + size_t operator()(const string &s) const { return hash_string(s.c_str()); } + }; + + template<class T1, class T2> struct hash<pair<T1,T2> > + { + hash<T1> __fh; + hash<T2> __sh; + size_t operator()(const pair<T1,T2> &p) const { + return __fh(p.first) ^ __sh(p.second); + } + }; +} + +void test01() +{ + const int Size = 5; + bool test __attribute__((unused)) = true; + + using std::string; + using std::pair; + using std::vector; + using __gnu_cxx::hash_map; + + for (int i = 0; i < 10; i++) + { + hash_map<string, int> a; + hash_map<string, int> b; + + vector<pair<string, int> > contents (Size); + for (int j = 0; j < Size; j++) + { + string s; + for (int k = 0; k < 10; k++) + { + s += 'a' + (rand() % 26); + } + contents[j] = make_pair(s,j); + } + for (int j = 0; j < Size; j++) + { + a[contents[j].first] = contents[j].second; + int k = Size - 1 - j; + b[contents[k].first] = contents[k].second; + } + VERIFY( a == b ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/14648.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/14648.cc new file mode 100644 index 000000000..8c73b2d79 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/14648.cc @@ -0,0 +1,41 @@ +// { dg-options "-Wno-deprecated" } + +// Copyright (C) 2004, 2005, 2007 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <iostream> +#include <hash_map> +#include <ext/rope> + +// libstdc++/14648 +void test01() +{ + using namespace __gnu_cxx; + + typedef hash_map<char, crope, hash<char>, std::equal_to<char> > maptype; + maptype m; + m['l'] = "50"; + m['x'] = "10"; + std::cout << "m['x'] = " << m['x'] << std::endl; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/23528.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/23528.cc new file mode 100644 index 000000000..42908eb31 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/23528.cc @@ -0,0 +1,44 @@ +// { dg-options "-Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <hash_map> + +// libstdc++/23528 +void test01() +{ + __gnu_cxx::hash_map<int, int> m; + m[888] = 999; + + __gnu_cxx::hash_map<int, int>::allocator_type a = m.get_allocator(); + + __gnu_cxx::hash_map<int, int>::value_type *y = a.allocate(1); + + a.construct(y, *m.begin()); + + a.destroy(y); + a.deallocate(y, 1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/requirements/explicit_instantiation.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..84df423ea --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_map/requirements/explicit_instantiation.cc @@ -0,0 +1,35 @@ +// { dg-options "-Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2004, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <hash_map> + +template class __gnu_cxx::hash_map<int, char>; diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/1.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/1.cc new file mode 100644 index 000000000..b54f022b2 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/1.cc @@ -0,0 +1,41 @@ +// { dg-options "-Wno-deprecated" } + +// 2002-04-28 Paolo Carlini <pcarlini@unitus.it> +// Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> + +// Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// hash_set (SGI extension) + +#include <hash_set> + +void +test01() +{ + bool test __attribute__((unused)) = true; + const int werte[] = { 1, 25, 9, 16, -36}; + const int anzahl = sizeof(werte) / sizeof(int); + __gnu_cxx::hash_set<int> intTable(werte, werte + anzahl); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc new file mode 100644 index 000000000..0e9a37569 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc @@ -0,0 +1,93 @@ +// { dg-options "-Wno-deprecated" } + +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <hash_set> +#include <functional> +#include <iterator> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef __gnu_cxx::hash_set<int, __gnu_cxx::hash<int>, std::equal_to<int>, + tracker_allocator<int> > + Container; + + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + const int arr10a[10] = { 31, 23, 82, 46, 13, 17, 30, 71, 22, 51 }; + bool ok = true; + + int buckets; + + tracker_allocator_counter::reset(); + { + Container c; + buckets = c.bucket_count(); + ok = check_construct_destroy("empty container", buckets, 0) && ok; + } + ok = check_construct_destroy("empty container", buckets, buckets) && ok; + + + tracker_allocator_counter::reset(); + { + Container c(arr10, arr10 + 10); + ok = check_construct_destroy("Construct from range", buckets+10, 0) && ok; + } + ok = check_construct_destroy("Construct from range", buckets+10, buckets+10) && ok; + + tracker_allocator_counter::reset(); + { + Container c(arr10, arr10 + 10); + c.insert(arr10a[0]); + ok = check_construct_destroy("Insert element", buckets+11, 0) && ok; + } + ok = check_construct_destroy("Insert element", buckets+11, buckets+11) && ok; + + tracker_allocator_counter::reset(); + { + Container c(arr10, arr10 + 10); + c.insert(arr10a, arr10a+3); + ok = check_construct_destroy("Insert short range", buckets+13, 0) && ok; + } + ok = check_construct_destroy("Insert short range", buckets+13, buckets+13) && ok; + + tracker_allocator_counter::reset(); + { + Container c(arr10, arr10 + 10); + c.insert(arr10a, arr10a+10); + ok = check_construct_destroy("Insert long range", buckets+20, 0) && ok; + } + ok = check_construct_destroy("Insert long range", buckets+20, buckets+20) && ok; + + return ok ? 0 : 1; +} + diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/requirements/explicit_instantiation.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..8d01bae37 --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/hash_set/requirements/explicit_instantiation.cc @@ -0,0 +1,35 @@ +// { dg-options "-Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2004, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <hash_set> + +template class __gnu_cxx::hash_set<int>; diff --git a/gcc-4.3.1/libstdc++-v3/testsuite/backward/strstream_members.cc b/gcc-4.3.1/libstdc++-v3/testsuite/backward/strstream_members.cc new file mode 100644 index 000000000..7d8b3eddf --- /dev/null +++ b/gcc-4.3.1/libstdc++-v3/testsuite/backward/strstream_members.cc @@ -0,0 +1,47 @@ +// { dg-options "-Wno-deprecated" } +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// backward strstream members + +#include <strstream> +#include <testsuite_hooks.h> + +void test01() +{ + std::strstream s; + for (unsigned i=0 ; i!= 1000 ; ++i) + s << i << std::endl; + s << std::ends; +} + + +void test02() +{ + std::ostrstream buf; + buf << std::ends; + char *s = buf.str (); + delete [] s; +} + +int main() +{ + test01(); + test02(); + return 0; +} |