From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/23_containers/vector/bool/1.cc | 36 ++++ .../testsuite/23_containers/vector/bool/21244.cc | 35 ++++ .../testsuite/23_containers/vector/bool/23632.cc | 39 ++++ .../testsuite/23_containers/vector/bool/6886.cc | 53 ++++++ .../23_containers/vector/bool/capacity/1.cc | 137 ++++++++++++++ .../23_containers/vector/bool/capacity/29134.cc | 53 ++++++ .../23_containers/vector/bool/clear_allocator.cc | 87 +++++++++ .../testsuite/23_containers/vector/bool/cons/1.cc | 178 ++++++++++++++++++ .../testsuite/23_containers/vector/bool/cons/2.cc | 180 +++++++++++++++++++ .../testsuite/23_containers/vector/bool/hash/1.cc | 45 +++++ .../23_containers/vector/bool/modifiers/erase/1.cc | 136 ++++++++++++++ .../vector/bool/modifiers/insert/1.cc | 171 ++++++++++++++++++ .../vector/bool/modifiers/insert/31370.cc | 199 +++++++++++++++++++++ .../23_containers/vector/bool/modifiers/swap/1.cc | 145 +++++++++++++++ .../23_containers/vector/bool/modifiers/swap/2.cc | 174 ++++++++++++++++++ .../vector/bool/requirements/citerators.cc | 30 ++++ .../vector/bool/requirements/dr438/constructor.cc | 27 +++ 17 files changed, 1725 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc (limited to 'libstdc++-v3/testsuite/23_containers/vector/bool') diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc new file mode 100644 index 000000000..8728985e8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc @@ -0,0 +1,36 @@ +// 2002-03-05 Stephen M. Webb + +// Copyright (C) 2002, 2003, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 class vector + +#include +#include + +void test01() +{ + std::vector::iterator i; + if (false) + ++i; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc new file mode 100644 index 000000000..f8baba1be --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + +#include + +// { dg-do compile } + +class Foo +{ +}; + +template Foo operator/(const Foo& arg1, T arg2) +{ + return Foo(); +} + +// libstdc++/21244 +void foo() +{ + std::vector bar(1); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc new file mode 100644 index 000000000..9b5023f98 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + +// { dg-do compile } + +#include + +// libstdc++/23632 +void test01() +{ + std::vector v(100); + const std::vector::iterator fu = v.begin(); + if (!fu[0]) + fu[0] = true; + + const std::vector::const_iterator cfu = v.begin(); + if (cfu[0]) + ; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc new file mode 100644 index 000000000..c3a2995ae --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc @@ -0,0 +1,53 @@ +// 2002-03-05 Stephen M. Webb + +// Copyright (C) 2002, 2003, 2004, 2005, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 class vector + +#include +#include + +// libstdc++/6886 +void test02() +{ + bool test __attribute__((unused)) = true; + typedef std::vector bvec; + int i, num = 0; + bvec v; + + v.resize(66); + + for (i = 0 ; i < 66 ; ++i) + v[i] = 0; + + v[1] = 1; + v[33] = 1; + v[49] = 1; + v[65] = 1; + + for (bvec::iterator j = v.begin() ; j != v.end() ; j++) + if (bool(*j)) ++num; + + VERIFY( num == 4 ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc new file mode 100644 index 000000000..c38ac7115 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc @@ -0,0 +1,137 @@ +// 2006-08-05 Paolo Carlini + +// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector resize + +#include +#include + +const bool A1[] = {0}; +const bool A2[] = {0, 0, 0}; +const bool A3[] = {0, 0}; +const bool A4[] = {0, 0, 1, 1, 1, 1, 1}; +const bool A5[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const bool A6[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1}; +const bool A7[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}; +const bool A8[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +const bool A9[] = {0, 0, 1, 1, 1, 1, 1, 0, 0,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izeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); +const unsigned N10 = sizeof(A10) / sizeof(bool); +const unsigned N11 = sizeof(A11) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + vec_type v; + + v.resize(1); + VERIFY( v.size() == 1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + v.resize(3); + VERIFY( v.size() == 3 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + v.resize(2); + VERIFY( v.size() == 2 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + v.resize(7, true); + VERIFY( v.size() == 7 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + v.resize(18, false); + VERIFY( v.size() == 18 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + v.resize(40, true); + VERIFY( v.size() == 40 ); + VERIFY( std::equal(v.begin(), v.end(), A6) ); + + v.resize(80, false); + VERIFY( v.size() == 80 ); + VERIFY( std::equal(v.begin(), v.end(), A7) ); + + v.resize(90, true); + VERIFY( v.size() == 90 ); + VERIFY( std::equal(v.begin(), v.end(), A8) ); + + v.resize(100, false); + VERIFY( v.size() == 100 ); + VERIFY( std::equal(v.begin(), v.end(), A9) ); + + v.resize(200, true); + VERIFY( v.size() == 200 ); + VERIFY( std::equal(v.begin(), v.end(), A10) ); + + v.resize(13, true); + VERIFY( v.size() == 13 ); + VERIFY( std::equal(v.begin(), v.end(), A11) ); + + v.resize(13, false); + VERIFY( v.size() == 13 ); + VERIFY( std::equal(v.begin(), v.end(), A11) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc new file mode 100644 index 000000000..f6d0e15ed --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2006, 2007, 2009, 2010 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 class vector [lib.vector.bool] + +#include +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::vector; + using std::numeric_limits; + +#ifdef _GLIBCXX_DEBUG + using std::_GLIBCXX_STD_C::_S_word_bit; +#elif defined(_GLIBCXX_PROFILE) + using std::_GLIBCXX_STD_C::_S_word_bit; +#else + using std::_S_word_bit; +#endif + + // Actually, vector is special, see libstdc++/31370. + vector vb; + typedef vector::difference_type difference_type; + typedef vector::size_type size_type; + VERIFY( vb.max_size() + == size_type(numeric_limits::max() + - int(_S_word_bit) + 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc new file mode 100644 index 000000000..934f1be33 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see +// . + +#include +#include + +using namespace std; +using __gnu_cxx::new_allocator; + +template + class clear_alloc : public new_allocator + { + public: + + template + struct rebind + { typedef clear_alloc other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator() + { } + + template + clear_alloc(clear_alloc const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator::size_type n) + { + this->clear(); + new_allocator::deallocate(ptr, n); + } + }; + +template + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } + + +int main() +{ + Check_Container > >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc new file mode 100644 index 000000000..ce377b466 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc @@ -0,0 +1,178 @@ +// 2006-08-09 Paolo Carlini + +// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector copy construct + +#include +#include + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + const vec_type v1_ref(A1, A1 + N1); + vec_type v1(v1_ref); + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + vec_type v2(v2_ref); + VERIFY( v2.size() == v2_ref.size() ); + VERIFY( std::equal(v2.begin(), v2.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + vec_type v3(v3_ref); + VERIFY( v3.size() == v3_ref.size() ); + VERIFY( std::equal(v3.begin(), v3.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + vec_type v4(v4_ref); + VERIFY( v4.size() == v4_ref.size() ); + VERIFY( std::equal(v4.begin(), v4.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + vec_type v5(v5_ref); + VERIFY( v5.size() == v5_ref.size() ); + VERIFY( std::equal(v5.begin(), v5.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + vec_type v6(v6_ref); + VERIFY( v6.size() == v6_ref.size() ); + VERIFY( std::equal(v6.begin(), v6.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + vec_type v7(v7_ref); + VERIFY( v7.size() == v7_ref.size() ); + VERIFY( std::equal(v7.begin(), v7.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + vec_type v8(v8_ref); + VERIFY( v8.size() == v8_ref.size() ); + VERIFY( std::equal(v8.begin(), v8.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + vec_type v9(v9_ref); + VERIFY( v9.size() == v9_ref.size() ); + VERIFY( std::equal(v9.begin(), v9.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc new file mode 100644 index 000000000..34ac3a0fd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc @@ -0,0 +1,180 @@ +// 2006-08-09 Paolo Carlini + +// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector assignment operator + +#include +#include + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + vec_type v1; + + const vec_type v1_ref(A1, A1 + N1); + v1 = v1_ref; + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + v1 = v2_ref; + VERIFY( v1.size() == v2_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + v1 = v3_ref; + VERIFY( v1.size() == v3_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + v1 = v4_ref; + VERIFY( v1.size() == v4_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + v1 = v5_ref; + VERIFY( v1.size() == v5_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + v1 = v6_ref; + VERIFY( v1.size() == v6_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + v1 = v7_ref; + VERIFY( v1.size() == v7_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + v1 = v8_ref; + VERIFY( v1.size() == v8_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + v1 = v9_ref; + VERIFY( v1.size() == v9_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc new file mode 100644 index 000000000..85e91e98e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 3, 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 COPYING3. If not see +// . + +#include + +void test01() +{ + std::vector b0; + std::hash> h0; + h0(b0); + + std::vector b1(10); + std::hash> h1; + h1(b1); + + std::vector b2(100); + std::hash> h2; + h2(b2); + + std::vector b3(1000); + std::hash> h3; + h3(b3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc new file mode 100644 index 000000000..2a21fcf9e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc @@ -0,0 +1,136 @@ +// 2005-12-23 Paolo Carlini + +// Copyright (C) 2005, 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector modifiers + +#include +#include + +const bool A[] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; +const bool A1[] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; +const bool A2[] = {0, 0, 1, 0, 0, 1, 0, 1, 0, 1}; +const bool A3[] = {0, 0, 1, 0, 0, 1}; +const bool A4[] = {0, 0, 1}; +const bool A5[] = {0, 0}; + +const unsigned N = sizeof(A) / sizeof(bool); +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v(A, A + N); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector > vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v, v1, v2, v3, v4, v5; + for (unsigned i = 0; i < N; ++i) + v.push_back(std::vector(1, A[i])); + for (unsigned i = 0; i < N1; ++i) + v1.push_back(std::vector(1, A1[i])); + for (unsigned i = 0; i < N2; ++i) + v2.push_back(std::vector(1, A2[i])); + for (unsigned i = 0; i < N3; ++i) + v3.push_back(std::vector(1, A3[i])); + for (unsigned i = 0; i < N4; ++i) + v4.push_back(std::vector(1, A4[i])); + for (unsigned i = 0; i < N5; ++i) + v5.push_back(std::vector(1, A5[i])); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), v1.begin()) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), v2.begin()) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), v3.begin()) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), v4.begin()) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), v5.begin()) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc new file mode 100644 index 000000000..06fe0be97 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc @@ -0,0 +1,171 @@ +// 2006-08-05 Paolo Carlini + +// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector insert + +#include +#include + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1}; +const bool A2[] = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A3[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1}; +const bool A4[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1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0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + vec_type v; + + v.insert(v.begin(), 7, true); + VERIFY( v.size() == 7 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + v.insert(v.begin() + 5, 10, false); + VERIFY( v.size() == 17 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + v.insert(v.begin(), 20, false); + VERIFY( v.size() == 37 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + v.insert(v.begin(), 40, true); + VERIFY( v.size() == 77 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + v.insert(v.begin() + 18, 80, false); + VERIFY( v.size() == 157 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + v.insert(v.begin() + 54, 80, true); + VERIFY( v.size() == 237 ); + VERIFY( std::equal(v.begin(), v.end(), A6) ); + + v.insert(v.end(), 1, false); + VERIFY( v.size() == 238 ); + VERIFY( std::equal(v.begin(), v.end(), A7) ); + + v.insert(v.begin(), 1, false); + VERIFY( v.size() == 239 ); + VERIFY( std::equal(v.begin(), v.end(), A8) ); + + v.insert(v.begin(), 180, true); + VERIFY( v.size() == 419 ); + VERIFY( std::equal(v.begin(), v.end(), A9) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc new file mode 100644 index 000000000..9f5643ef9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc @@ -0,0 +1,199 @@ +// Copyright (C) 2007, 2009, 2010 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 class vector [lib.vector.bool] + +// { dg-do run { xfail *-*-darwin8.[0-4].* } } + +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG + using std::_GLIBCXX_STD_C::_S_word_bit; +#elif defined(_GLIBCXX_PROFILE) + using std::_GLIBCXX_STD_C::_S_word_bit; +#else + using std::_S_word_bit; +#endif + +inline void +check_cap_ge_size(const std::vector& x) +{ + if (x.capacity() < x.size()) + throw std::logic_error(""); +} + +inline void +check_cap_eq_maxsize(const std::vector& x) +{ + if (x.capacity() != x.max_size()) + throw std::logic_error(""); +} + +// libstdc++/31370 +void test01() +{ + bool test __attribute__((unused)) = true; + int myexit = 0; + + try + { + std::vector x; + x.reserve(x.max_size()); + check_cap_eq_maxsize(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // When doubling is too big, but smaller is sufficient, the resize + // should do smaller and be happy. It certainly shouldn't throw + // other exceptions or crash. + try + { + std::vector x; + x.resize(x.max_size() / 2 + 1, false); + for(int i = 0; i < _S_word_bit; ++i) + x.push_back(false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() / 2 + 1, false); + x.insert(x.end(), _S_word_bit, false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() / 2 + 1, false); + std::vector y(_S_word_bit, false); + x.insert(x.end(), y.begin(), y.end()); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // These tests are currently only relevant to bool: don't get burned + // by the attempt to round up when near the max size. + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + for(int i = 0; i < _S_word_bit; ++i) + x.push_back(false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + x.insert(x.end(), _S_word_bit, false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + std::vector y(_S_word_bit, false); + x.insert(x.end(), y.begin(), y.end()); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // Attempts to put in more than max_size() items should result in a + // length error. + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + for(int i = 0; i < _S_word_bit + 1; ++i) + x.push_back(false); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + x.insert(x.end(), _S_word_bit + 1, false); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + try + { + std::vector x; + x.resize(x.max_size() - _S_word_bit, false); + std::vector y(_S_word_bit + 1, false); + x.insert(x.end(), y.begin(), y.end()); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + VERIFY( !myexit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc new file mode 100644 index 000000000..31152845b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc @@ -0,0 +1,145 @@ +// 2005-12-23 Paolo Carlini + +// Copyright (C) 2005, 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector::swap + +#include +#include +#include + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator my_alloc; + typedef vector my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + vector vec01_ref; + for (size_t i = 0; i < N1; ++i) + vec01_ref.push_back(bool(title01[i] > 96 ? 1 : 0)); + vector vec02_ref; + for (size_t i = 0; i < N2; ++i) + vec02_ref.push_back(bool(title02[i] > 96 ? 1 : 0)); + vector vec03_ref; + for (size_t i = 0; i < N3; ++i) + vec03_ref.push_back(bool(title03[i] > 96 ? 1 : 0)); + vector vec04_ref; + for (size_t i = 0; i < N4; ++i) + vec04_ref.push_back(bool(title04[i] > 96 ? 1 : 0)); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1); + + my_vector vec01(alloc01); + size01 = vec01.size(); + my_vector vec02(alloc01); + size02 = vec02.size(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + + my_vector vec03(alloc01); + size01 = vec03.size(); + my_vector vec04(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec04.size(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), vec02_ref.begin()) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + + my_vector vec05(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec05.size(); + my_vector vec06(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec06.size(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), vec02_ref.begin()) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), vec01_ref.begin()) ); + + my_vector vec07(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec07.size(); + my_vector vec08(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec08.size(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), vec03_ref.begin()) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), vec01_ref.begin()) ); + + my_vector vec09(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec09.size(); + my_vector vec10(vec04_ref.begin(), vec04_ref.end(), alloc01); + size02 = vec10.size(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), vec04_ref.begin()) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), vec03_ref.begin()) ); + + my_vector vec11(vec04_ref.begin(), vec04_ref.end(), alloc01); + size01 = vec11.size(); + my_vector vec12(vec01_ref.begin(), vec01_ref.end(), alloc01); + size02 = vec12.size(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), vec01_ref.begin()) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), vec04_ref.begin()) ); + + my_vector vec13(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec13.size(); + my_vector vec14(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec14.size(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), vec03_ref.begin()) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), vec03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc new file mode 100644 index 000000000..f63b6a257 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc @@ -0,0 +1,174 @@ +// 2005-12-23 Paolo Carlini + +// Copyright (C) 2005, 2006, 2009 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 3, 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 COPYING3. If not see +// . + +// 23.2.5 vector::swap + +#include +#include +#include + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator my_alloc; + typedef vector my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + vector vec01_ref; + for (size_t i = 0; i < N1; ++i) + vec01_ref.push_back(bool(title01[i] > 96 ? 1 : 0)); + vector vec02_ref; + for (size_t i = 0; i < N2; ++i) + vec02_ref.push_back(bool(title02[i] > 96 ? 1 : 0)); + vector vec03_ref; + for (size_t i = 0; i < N3; ++i) + vec03_ref.push_back(bool(title03[i] > 96 ? 1 : 0)); + vector vec04_ref; + for (size_t i = 0; i < N4; ++i) + vec04_ref.push_back(bool(title04[i] > 96 ? 1 : 0)); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_vector vec01(alloc01); + size01 = vec01.size(); + personality01 = vec01.get_allocator().get_personality(); + my_vector vec02(alloc02); + size02 = vec02.size(); + personality02 = vec02.get_allocator().get_personality(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + VERIFY( vec01.get_allocator().get_personality() == personality02 ); + VERIFY( vec02.get_allocator().get_personality() == personality01 ); + + my_vector vec03(alloc02); + size01 = vec03.size(); + personality01 = vec03.get_allocator().get_personality(); + my_vector vec04(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec04.size(); + personality02 = vec04.get_allocator().get_personality(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), vec02_ref.begin()) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + VERIFY( vec03.get_allocator().get_personality() == personality02 ); + VERIFY( vec04.get_allocator().get_personality() == personality01 ); + + my_vector vec05(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec05.size(); + personality01 = vec05.get_allocator().get_personality(); + my_vector vec06(vec02_ref.begin(), vec02_ref.end(), alloc02); + size02 = vec06.size(); + personality02 = vec06.get_allocator().get_personality(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), vec02_ref.begin()) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), vec01_ref.begin()) ); + VERIFY( vec05.get_allocator().get_personality() == personality02 ); + VERIFY( vec06.get_allocator().get_personality() == personality01 ); + + my_vector vec07(vec01_ref.begin(), vec01_ref.end(), alloc02); + size01 = vec07.size(); + personality01 = vec07.get_allocator().get_personality(); + my_vector vec08(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec08.size(); + personality02 = vec08.get_allocator().get_personality(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), vec03_ref.begin()) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), vec01_ref.begin()) ); + VERIFY( vec07.get_allocator().get_personality() == personality02 ); + VERIFY( vec08.get_allocator().get_personality() == personality01 ); + + my_vector vec09(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec09.size(); + personality01 = vec09.get_allocator().get_personality(); + my_vector vec10(vec04_ref.begin(), vec04_ref.end(), alloc02); + size02 = vec10.size(); + personality02 = vec10.get_allocator().get_personality(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), vec04_ref.begin()) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), vec03_ref.begin()) ); + VERIFY( vec09.get_allocator().get_personality() == personality02 ); + VERIFY( vec10.get_allocator().get_personality() == personality01 ); + + my_vector vec11(vec04_ref.begin(), vec04_ref.end(), alloc02); + size01 = vec11.size(); + personality01 = vec11.get_allocator().get_personality(); + my_vector vec12(vec01_ref.begin(), vec01_ref.end(), alloc01); + size02 = vec12.size(); + personality02 = vec12.get_allocator().get_personality(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), vec01_ref.begin()) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), vec04_ref.begin()) ); + VERIFY( vec11.get_allocator().get_personality() == personality02 ); + VERIFY( vec12.get_allocator().get_personality() == personality01 ); + + my_vector vec13(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec13.size(); + personality01 = vec13.get_allocator().get_personality(); + my_vector vec14(vec03_ref.begin(), vec03_ref.end(), alloc02); + size02 = vec14.size(); + personality02 = vec14.get_allocator().get_personality(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), vec03_ref.begin()) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), vec03_ref.begin()) ); + VERIFY( vec13.get_allocator().get_personality() == personality02 ); + VERIFY( vec14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc new file mode 100644 index 000000000..9f4783b74 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini + +// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see +// . + +#include +#include + +int main() +{ + typedef std::vector test_type; + __gnu_test::citerator test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc new file mode 100644 index 000000000..9a815ec7d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see +// . + +// { dg-do compile } + +#include + +void f() +{ + std::vector vb(10, 1); +} -- cgit v1.2.3