From 17472bb623e869846f6d555995686bc54e499c10 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 31 Jul 2003 18:48:48 +0000 Subject: [PATCH] Reshuffle 23_containers testsuite. 2003-07-31 Benjamin Kosnik Reshuffle 23_containers testsuite. * 23_containers/adaptors.cc, bitset_ctor.cc,bitset_members.cc, bitset_shift.cc, deque_ctor.cc, deque_operators.cc, list_capacity.cc, list_ctor.cc, list_modifiers.cc, list_operators.cc, map_insert.cc, map_operators.cc, map_operators_neg.cc, multiset.cc, set_operators_neg.cc, vector_bool.cc, vector_capacity.cc, vector_ctor.cc, vector_element_access.cc, vector_modifiers.cc, vector_resize.cc: Split into... * 23_containers/bitset/cons/1.cc: New. * 23_containers/bitset/cons/6282.cc: New. * 23_containers/bitset/count/6124.cc: New. * 23_containers/bitset/operations/1.cc: New. * 23_containers/bitset/operations/2.cc: New. * 23_containers/bitset/test/1.cc: New. * 23_containers/bitset/to_ulong/1.cc: New. * 23_containers/deque/cons/1.cc: New. * 23_containers/deque/cons/2.cc: New. * 23_containers/deque/operators/1.cc: New. * 23_containers/list/capacity/1.cc: New. * 23_containers/list/cons/1.cc: New. * 23_containers/list/cons/2.cc: New. * 23_containers/list/cons/3.cc: New. * 23_containers/list/cons/4.cc: New. * 23_containers/list/cons/5.cc: New. * 23_containers/list/cons/6.cc: New. * 23_containers/list/cons/7.cc: New. * 23_containers/list/cons/8.cc: New. * 23_containers/list/cons/9.cc: New. * 23_containers/list/modifiers/1.cc: New. * 23_containers/list/modifiers/2.cc: New. * 23_containers/list/modifiers/3.cc: New. * 23_containers/list/operators/1.cc: New. * 23_containers/list/operators/2.cc: New. * 23_containers/list/operators/3.cc: New. * 23_containers/list/operators/4.cc: New. * 23_containers/map/insert/1.cc: New. * 23_containers/map/operators/1.cc: New. * 23_containers/map/operators/1_neg.cc: New. * 23_containers/multiset/insert/1.cc: New. * 23_containers/priority_queue/members/7161.cc: New. * 23_containers/queue/members/7157.cc: New. * 23_containers/set/operators/1_neg.cc: New. * 23_containers/stack/members/7158.cc: New. * 23_containers/vector/bool/1.cc: New. * 23_containers/vector/bool/6886.cc: New. * 23_containers/vector/capacity/1.cc: New. * 23_containers/vector/capacity/2.cc: New. * 23_containers/vector/capacity/8230.cc: New. * 23_containers/vector/cons/1.cc: New. * 23_containers/vector/cons/2.cc: New. * 23_containers/vector/cons/3.cc: New. * 23_containers/vector/cons/4.cc: New. * 23_containers/vector/cons/6513.cc: New. * 23_containers/vector/element_access/1.cc: New. * 23_containers/vector/modifiers/1.cc: New. * 23_containers/vector/modifiers/2.cc: New. * 23_containers/vector/resize/1.cc: New. From-SVN: r70011 --- libstdc++-v3/ChangeLog | 60 ++++ .../{bitset_ctor.cc => bitset/cons/1.cc} | 34 -- .../23_containers/bitset/cons/6282.cc | 64 ++++ .../23_containers/bitset/count/6124.cc | 39 ++ .../operations/1.cc} | 17 +- .../23_containers/bitset/operations/2.cc | 42 +++ .../{bitset_members.cc => bitset/test/1.cc} | 26 -- .../23_containers/bitset/to_ulong/1.cc | 48 +++ .../testsuite/23_containers/deque/cons/1.cc | 51 +++ .../{deque_ctor.cc => deque/cons/2.cc} | 19 +- .../operators/1.cc} | 0 .../{list_capacity.cc => list/capacity/1.cc} | 5 +- .../testsuite/23_containers/list/cons/1.cc | 79 +++++ .../testsuite/23_containers/list/cons/2.cc | 83 +++++ .../testsuite/23_containers/list/cons/3.cc | 60 ++++ .../testsuite/23_containers/list/cons/4.cc | 66 ++++ .../testsuite/23_containers/list/cons/5.cc | 57 +++ .../testsuite/23_containers/list/cons/6.cc | 70 ++++ .../testsuite/23_containers/list/cons/7.cc | 71 ++++ .../testsuite/23_containers/list/cons/8.cc | 64 ++++ .../testsuite/23_containers/list/cons/9.cc | 64 ++++ .../23_containers/list/modifiers/1.cc | 120 +++++++ .../23_containers/list/modifiers/2.cc | 92 +++++ .../23_containers/list/modifiers/3.cc | 124 +++++++ .../23_containers/list/operators/1.cc | 74 ++++ .../23_containers/list/operators/2.cc | 60 ++++ .../23_containers/list/operators/3.cc | 74 ++++ .../23_containers/list/operators/4.cc | 94 +++++ .../testsuite/23_containers/list_ctor.cc | 332 ------------------ .../testsuite/23_containers/list_modifiers.cc | 273 -------------- .../testsuite/23_containers/list_operators.cc | 211 ----------- .../{map_insert.cc => map/insert/1.cc} | 0 .../{map_operators.cc => map/operators/1.cc} | 0 .../operators/1_neg.cc} | 0 .../{multiset.cc => multiset/insert/1.cc} | 0 .../members/7161.cc} | 29 -- .../23_containers/queue/members/7157.cc | 41 +++ .../operators/1_neg.cc} | 0 .../23_containers/stack/members/7158.cc | 41 +++ .../testsuite/23_containers/vector/bool/1.cc | 37 ++ .../{vector_bool.cc => vector/bool/6886.cc} | 8 - .../23_containers/vector/capacity/1.cc | 61 ++++ .../capacity/2.cc} | 75 ---- .../23_containers/vector/capacity/8230.cc | 78 ++++ .../testsuite/23_containers/vector/cons/1.cc | 48 +++ .../testsuite/23_containers/vector/cons/2.cc | 49 +++ .../testsuite/23_containers/vector/cons/3.cc | 54 +++ .../{vector_ctor.cc => vector/cons/4.cc} | 60 ---- .../23_containers/vector/cons/6513.cc | 40 +++ .../element_access/1.cc} | 0 .../23_containers/vector/modifiers/1.cc | 56 +++ .../modifiers/2.cc} | 28 +- .../{vector_resize.cc => vector/resize/1.cc} | 0 53 files changed, 2067 insertions(+), 1111 deletions(-) rename libstdc++-v3/testsuite/23_containers/{bitset_ctor.cc => bitset/cons/1.cc} (76%) create mode 100644 libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc create mode 100644 libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc rename libstdc++-v3/testsuite/23_containers/{bitset_shift.cc => bitset/operations/1.cc} (95%) create mode 100644 libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc rename libstdc++-v3/testsuite/23_containers/{bitset_members.cc => bitset/test/1.cc} (80%) create mode 100644 libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/1.cc rename libstdc++-v3/testsuite/23_containers/{deque_ctor.cc => deque/cons/2.cc} (98%) rename libstdc++-v3/testsuite/23_containers/{deque_operators.cc => deque/operators/1.cc} (100%) rename libstdc++-v3/testsuite/23_containers/{list_capacity.cc => list/capacity/1.cc} (98%) create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/5.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/6.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/7.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/8.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/9.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operators/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operators/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operators/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operators/4.cc delete mode 100644 libstdc++-v3/testsuite/23_containers/list_ctor.cc delete mode 100644 libstdc++-v3/testsuite/23_containers/list_modifiers.cc delete mode 100644 libstdc++-v3/testsuite/23_containers/list_operators.cc rename libstdc++-v3/testsuite/23_containers/{map_insert.cc => map/insert/1.cc} (100%) rename libstdc++-v3/testsuite/23_containers/{map_operators.cc => map/operators/1.cc} (100%) rename libstdc++-v3/testsuite/23_containers/{map_operators_neg.cc => map/operators/1_neg.cc} (100%) rename libstdc++-v3/testsuite/23_containers/{multiset.cc => multiset/insert/1.cc} (100%) rename libstdc++-v3/testsuite/23_containers/{adaptors.cc => priority_queue/members/7161.cc} (83%) create mode 100644 libstdc++-v3/testsuite/23_containers/queue/members/7157.cc rename libstdc++-v3/testsuite/23_containers/{set_operators_neg.cc => set/operators/1_neg.cc} (100%) create mode 100644 libstdc++-v3/testsuite/23_containers/stack/members/7158.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/1.cc rename libstdc++-v3/testsuite/23_containers/{vector_bool.cc => vector/bool/6886.cc} (94%) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc rename libstdc++-v3/testsuite/23_containers/{vector_capacity.cc => vector/capacity/2.cc} (70%) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/cons/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/cons/3.cc rename libstdc++-v3/testsuite/23_containers/{vector_ctor.cc => vector/cons/4.cc} (91%) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc rename libstdc++-v3/testsuite/23_containers/{vector_element_access.cc => vector/element_access/1.cc} (100%) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc rename libstdc++-v3/testsuite/23_containers/{vector_modifiers.cc => vector/modifiers/2.cc} (78%) rename libstdc++-v3/testsuite/23_containers/{vector_resize.cc => vector/resize/1.cc} (100%) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c2d58f8c10c5..4c19dd4ff600 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,63 @@ +2003-07-31 Benjamin Kosnik + + Reshuffle 23_containers testsuite. + * 23_containers/adaptors.cc, bitset_ctor.cc,bitset_members.cc, + bitset_shift.cc, deque_ctor.cc, deque_operators.cc, + list_capacity.cc, list_ctor.cc, list_modifiers.cc, list_operators.cc, + map_insert.cc, map_operators.cc, map_operators_neg.cc, multiset.cc, + set_operators_neg.cc, vector_bool.cc, vector_capacity.cc, + vector_ctor.cc, vector_element_access.cc, vector_modifiers.cc, + vector_resize.cc: Split into... + * 23_containers/bitset/cons/1.cc: New. + * 23_containers/bitset/cons/6282.cc: New. + * 23_containers/bitset/count/6124.cc: New. + * 23_containers/bitset/operations/1.cc: New. + * 23_containers/bitset/operations/2.cc: New. + * 23_containers/bitset/test/1.cc: New. + * 23_containers/bitset/to_ulong/1.cc: New. + * 23_containers/deque/cons/1.cc: New. + * 23_containers/deque/cons/2.cc: New. + * 23_containers/deque/operators/1.cc: New. + * 23_containers/list/capacity/1.cc: New. + * 23_containers/list/cons/1.cc: New. + * 23_containers/list/cons/2.cc: New. + * 23_containers/list/cons/3.cc: New. + * 23_containers/list/cons/4.cc: New. + * 23_containers/list/cons/5.cc: New. + * 23_containers/list/cons/6.cc: New. + * 23_containers/list/cons/7.cc: New. + * 23_containers/list/cons/8.cc: New. + * 23_containers/list/cons/9.cc: New. + * 23_containers/list/modifiers/1.cc: New. + * 23_containers/list/modifiers/2.cc: New. + * 23_containers/list/modifiers/3.cc: New. + * 23_containers/list/operators/1.cc: New. + * 23_containers/list/operators/2.cc: New. + * 23_containers/list/operators/3.cc: New. + * 23_containers/list/operators/4.cc: New. + * 23_containers/map/insert/1.cc: New. + * 23_containers/map/operators/1.cc: New. + * 23_containers/map/operators/1_neg.cc: New. + * 23_containers/multiset/insert/1.cc: New. + * 23_containers/priority_queue/members/7161.cc: New. + * 23_containers/queue/members/7157.cc: New. + * 23_containers/set/operators/1_neg.cc: New. + * 23_containers/stack/members/7158.cc: New. + * 23_containers/vector/bool/1.cc: New. + * 23_containers/vector/bool/6886.cc: New. + * 23_containers/vector/capacity/1.cc: New. + * 23_containers/vector/capacity/2.cc: New. + * 23_containers/vector/capacity/8230.cc: New. + * 23_containers/vector/cons/1.cc: New. + * 23_containers/vector/cons/2.cc: New. + * 23_containers/vector/cons/3.cc: New. + * 23_containers/vector/cons/4.cc: New. + * 23_containers/vector/cons/6513.cc: New. + * 23_containers/vector/element_access/1.cc: New. + * 23_containers/vector/modifiers/1.cc: New. + * 23_containers/vector/modifiers/2.cc: New. + * 23_containers/vector/resize/1.cc: New. + 2003-07-31 Rainer Orth * testsuite/thread/pthread1.cc: Add alpha*-*-osf* to dg-do run, diff --git a/libstdc++-v3/testsuite/23_containers/bitset_ctor.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc similarity index 76% rename from libstdc++-v3/testsuite/23_containers/bitset_ctor.cc rename to libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc index 10ec016dfcdb..5d5064de4d6e 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset_ctor.cc +++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc @@ -76,42 +76,8 @@ bool test01(void) return test; } -// boundary condition: a zero-sized set -// libstdc++/6282 -bool test02(void) -{ - using std::char_traits; using std::allocator; - bool test = true; - - std::bitset<0> z1; - VERIFY( z1.any() == false ); - - std::bitset<0> z2(12345); - VERIFY( z2.any() == false ); - - std::bitset<0> z3(std::string("10101010101")); - VERIFY( z3.any() == false ); - - try { - z1.set(0); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - VERIFY( z1.to_ulong() == 0 ); - VERIFY( (z1.to_string,allocator >().empty() )); - return test; -} - int main() { test01(); - test02(); - return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc new file mode 100644 index 000000000000..92f9695ab47e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc @@ -0,0 +1,64 @@ +// 1999-06-08 bkoz + +// Copyright (C) 1999, 2000, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.3.5.1 bitset constructors + +#include +#include +#include +#include + +// boundary condition: a zero-sized set +// libstdc++/6282 +bool test02(void) +{ + using std::char_traits; using std::allocator; + bool test = true; + + std::bitset<0> z1; + VERIFY( z1.any() == false ); + + std::bitset<0> z2(12345); + VERIFY( z2.any() == false ); + + std::bitset<0> z3(std::string("10101010101")); + VERIFY( z3.any() == false ); + + try { + z1.set(0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + VERIFY( z1.to_ulong() == 0 ); + VERIFY( (z1.to_string,allocator >().empty() )); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc b/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc new file mode 100644 index 000000000000..df01a9f8b7de --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc @@ -0,0 +1,39 @@ +// 2001-06-03 pme + +// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.3.5.2 bitset members + +#include +#include +#include +#include + +// libstdc++/6124 +void test02() +{ + std::bitset<1> bs; + bs.count(); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/bitset_shift.cc b/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc similarity index 95% rename from libstdc++-v3/testsuite/23_containers/bitset_shift.cc rename to libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc index c022ca6ff4a3..8d21a9f5521f 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset_shift.cc +++ b/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc @@ -21,7 +21,6 @@ #include #include #include - #include static char original_bits[1024]; @@ -102,21 +101,9 @@ test01() { return test; } -bool -test02() -{ - bool test = true; - - std::bitset<66> b; - b <<= 400; - VERIFY( b.count() == 0 ); - return test; -} - int -main() { +main() +{ test01(); - test02(); - return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc b/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc new file mode 100644 index 000000000000..fd5c1929b13a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc @@ -0,0 +1,42 @@ +// 2000-01-15 Anders Widell + +// Copyright (C) 2000, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include +#include +#include +#include + +bool +test02() +{ + bool test = true; + + std::bitset<66> b; + b <<= 400; + VERIFY( b.count() == 0 ); + return test; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/bitset_members.cc b/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc similarity index 80% rename from libstdc++-v3/testsuite/23_containers/bitset_members.cc rename to libstdc++-v3/testsuite/23_containers/bitset/test/1.cc index 82e3a487ea35..40f4f42d8ea6 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset_members.cc +++ b/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc @@ -46,34 +46,8 @@ test01(void) VERIFY( test ); } -// libstdc++/6124 -void test02() -{ - std::bitset<1> bs; - bs.count(); -} - -void test03() -{ - bool test = true; - std::bitset<5> b; - std::stringstream ss ("101"); - - ss.exceptions(std::ios_base::eofbit); - - try - { - ss >> b; - } - catch (std::exception&) {} - - VERIFY( b.to_ulong() == 5 ); -} - int main() { test01(); - test02(); - test03(); return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc b/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc new file mode 100644 index 000000000000..40e54efbde60 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc @@ -0,0 +1,48 @@ +// 2001-06-03 pme + +// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.3.5.2 bitset members + +#include +#include +#include +#include + +void test03() +{ + bool test = true; + std::bitset<5> b; + std::stringstream ss("101"); + ss.exceptions(std::ios_base::eofbit); + + try + { + ss >> b; + } + catch (std::exception&) { } + + VERIFY( b.to_ulong() == 5 ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc new file mode 100644 index 000000000000..92e94057a98b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc @@ -0,0 +1,51 @@ +// 2001-12-27 pme +// +// Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.1.1 deque constructors, copy, and assignment + +#include +#include +#include +#include +#include + +typedef std::deque<__gnu_test::counter> gdeque; + +bool test = true; + +// see http://gcc.gnu.org/ml/libstdc++/2001-11/msg00139.html +void +test01() +{ + assert_count (0); + { + gdeque d(10); + assert_count (10); + } + assert_count (0); +} + + +int main() +{ + // specific bug fix checks + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque_ctor.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc similarity index 98% rename from libstdc++-v3/testsuite/23_containers/deque_ctor.cc rename to libstdc++-v3/testsuite/23_containers/deque/cons/2.cc index cb20e56fbc23..bc5a180fc19a 100644 --- a/libstdc++-v3/testsuite/23_containers/deque_ctor.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc @@ -38,19 +38,6 @@ typedef std::deque gdeque; bool test = true; -// see http://gcc.gnu.org/ml/libstdc++/2001-11/msg00139.html -void -test01() -{ - assert_count (0); - { - gdeque d(10); - assert_count (10); - } - assert_count (0); -} - - // 23.2.1 required types // // A missing required type will cause a compile failure. @@ -531,9 +518,5 @@ int main() fillAssignmentCheck2(); rangeAssignmentCheck(); rangeAssignmentCheckWithException(); - - // specific bug fix checks - test01(); - - return !test; + return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/deque_operators.cc b/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/deque_operators.cc rename to libstdc++-v3/testsuite/23_containers/deque/operators/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/list_capacity.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc similarity index 98% rename from libstdc++-v3/testsuite/23_containers/list_capacity.cc rename to libstdc++-v3/testsuite/23_containers/list/capacity/1.cc index 133fecd5423b..e675760cb933 100644 --- a/libstdc++-v3/testsuite/23_containers/list_capacity.cc +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc @@ -62,9 +62,8 @@ test01() int main(int argc, char* argv[]) { - test01(); - - return !test; + test01(); + return 0; } // vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/1.cc b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc new file mode 100644 index 000000000000..dfa8ce2bfa05 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C { + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Default constructor, basic properties +// +// This test verifies the following. +// 23.2.2.1 explicit list(const a& = Allocator()) +// 23.1 (7) iterator behaviour of empty containers +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 existence of required typedefs +// +void +test01() +{ + std::list< A > list0101; + VERIFY(list0101.begin() == list0101.end()); + VERIFY(list0101.size() == 0); + + // check type definitions -- will fail compile if missing + typedef std::list< A >::reference reference; + typedef std::list< A >::const_reference const_reference; + typedef std::list< A >::iterator iterator; + typedef std::list< A >::const_iterator const_iterator; + typedef std::list< A >::size_type size_type; + typedef std::list< A >::difference_type difference_type; + typedef std::list< A >::value_type value_type; + typedef std::list< A >::allocator_type allocator_type; + typedef std::list< A >::pointer pointer; + typedef std::list< A >::const_pointer const_pointer; + typedef std::list< A >::reverse_iterator reverse_iterator; + typedef std::list< A >::const_reverse_iterator const_reverse_iterator; + + // allocator checks? +} + +int main() +{ + test01(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc new file mode 100644 index 000000000000..50dc68e38d37 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc @@ -0,0 +1,83 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C { + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill constructor +// +// This test verifies the following. +// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +void +test02() +{ + const int LIST_SIZE = 5; + const int INIT_VALUE = 7; + int count; + std::list::const_iterator i; + + // nontrivial value_type + std::list< A > list0201(LIST_SIZE); + + // default value + std::list list0202(LIST_SIZE); + for (i = list0202.begin(), count = 0; + i != list0202.end(); + ++i, ++count) + VERIFY(*i == 0); + VERIFY(count == LIST_SIZE); + VERIFY(list0202.size() == LIST_SIZE); + + // explicit value + std::list list0203(LIST_SIZE, INIT_VALUE); + for (i = list0203.begin(), count = 0; + i != list0203.end(); + ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0203.size() == LIST_SIZE); +} + +int main() +{ + test02(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/3.cc b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc new file mode 100644 index 000000000000..8baa8627c58f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C { + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill constructor disguised as a range constructor +void +test02D() +{ + const int LIST_SIZE = 5; + const int INIT_VALUE = 7; + int count = 0; + std::list list0204(LIST_SIZE, INIT_VALUE); + std::list::iterator i = list0204.begin(); + for (; i != list0204.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0204.size() == LIST_SIZE); +} + +int main() +{ + test02D(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/4.cc b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc new file mode 100644 index 000000000000..30395671cbb4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// Range constructor +// +// This test verifies the following. +// 23.2.2.1 template list(InputIterator f, InputIterator l, const Allocator& a = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +void +test03() +{ + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + int count; + std::list::const_iterator i; + + // construct from a dissimilar range + std::list list0301(A, A + N); + for (i = list0301.begin(), count = 0; + i != list0301.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0301.size() == N); + + // construct from a similar range + std::list list0302(list0301.begin(), list0301.end()); + for (i = list0302.begin(), count = 0; + i != list0302.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0302.size() == N); +} + +int main() +{ + test03(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/5.cc b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc new file mode 100644 index 000000000000..64f17118a479 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// Copy constructor +// +// This test verifies the following. +// 23.2.2.1 list(const list& x) +// 23.2.2 reverse_iterator rbegin() +// 23.2.2 reverse_iterator rend() +// 23.2.2 size_type size() const +// +void +test04() +{ + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + int count; + std::list::reverse_iterator i; + std::list list0401(A, A + N); + + std::list list0402(list0401); + for (i = list0401.rbegin(), count = N - 1; + i != list0401.rend(); + ++i, --count) + VERIFY(*i == A[count]); + VERIFY(count == -1); + VERIFY(list0401.size() == N); +} + +int main() +{ + test04(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/6.cc b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc new file mode 100644 index 000000000000..6742c75e1b46 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// Range assign +// +// This test verifies the following. +// 23.2.2.1 void assign(InputIterator f, InputIterator l) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +void +test05() +{ + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {101, 102, 103, 104, 105}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + int count; + std::list::const_iterator i; + + std::list list0501; + + // make it bigger + list0501.assign(A, A + N); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0501.size() == N); + + // make it smaller + list0501.assign(B, B + M); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == B[count]); + VERIFY(count == M); + VERIFY(list0501.size() == M); +} + +int main() +{ + test05(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/7.cc b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc new file mode 100644 index 000000000000..f600fbbcbdca --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// Fill assign +// +// This test verifies the following. +// 23.2.2.1 void assign(size_type n, const T& v) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +void +test06() +{ + const int BIG_LIST_SIZE = 11; + const int BIG_INIT_VALUE = 7; + const int SMALL_LIST_SIZE = 5; + const int SMALL_INIT_VALUE = 17; + int count; + std::list::const_iterator i; + + std::list list0601; + VERIFY(list0601.size() == 0); + + // make it bigger + list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == BIG_INIT_VALUE); + VERIFY(count == BIG_LIST_SIZE); + VERIFY(list0601.size() == BIG_LIST_SIZE); + + // make it shrink + list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == SMALL_INIT_VALUE); + VERIFY(count == SMALL_LIST_SIZE); + VERIFY(list0601.size() == SMALL_LIST_SIZE); +} + +int main() +{ + test06(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/8.cc b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc new file mode 100644 index 000000000000..17eb0c48ade8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C { + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill Assignment disguised as a Range Assignment +void +test06D() +{ + const int LIST_SIZE = 5; + const int INIT_VALUE = 7; + int count = 0; + std::list list0604; + VERIFY(list0604.size() == 0); + + list0604.assign(LIST_SIZE, INIT_VALUE); + std::list::iterator i = list0604.begin(); + for (; i != list0604.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0604.size() == LIST_SIZE); +} + +int main() +{ + test06D(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/9.cc b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc new file mode 100644 index 000000000000..0fa066aabdfc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.1 list constructors, copy, and assignment + +#include +#include + +bool test = true; + +// Assignment operator +// +// This test verifies the following. +// 23.2.2 operator=(const list& x) +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 bool operator==(const list& x, const list& y) +// +void +test07() +{ + const int A[] = {701, 702, 703, 704, 705}; + const int N = sizeof(A) / sizeof(int); + int count; + std::list::iterator i; + + std::list list0701(A, A + N); + VERIFY(list0701.size() == N); + + std::list list0702; + VERIFY(list0702.size() == 0); + + list0702 = list0701; + VERIFY(list0702.size() == N); + for (i = list0702.begin(), count = 0; + i != list0702.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0702 == list0701); +} + +int main() +{ + test07(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc new file mode 100644 index 000000000000..c5bb6d7dad0d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc @@ -0,0 +1,120 @@ +// Copyright (C) 2001, 2003 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include +#include + +typedef __gnu_test::copy_tracker T; + +bool test = true; + +// range and fill insert/erase + clear +// missing: o fill insert disguised as a range insert in all its variants +// o exception effects +void +test03() +{ + std::list list0301; + T::reset(); + + // fill insert at beginning of list / empty list + list0301.insert(list0301.begin(), 3, T(11)); // should be [11 11 11] + VERIFY(list0301.size() == 3); + VERIFY(T::copyCount() == 3); + + // save iterators to verify post-insert validity + std::list::iterator b = list0301.begin(); + std::list::iterator m = list0301.end(); --m; + std::list::iterator e = list0301.end(); + + // fill insert at end of list + T::reset(); + list0301.insert(list0301.end(), 3, T(13)); // should be [11 11 11 13 13 13] + VERIFY(list0301.size() == 6); + VERIFY(T::copyCount() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 11); + + // fill insert in the middle of list + ++m; + T::reset(); + list0301.insert(m, 3, T(12)); // should be [11 11 11 12 12 12 13 13 13] + VERIFY(list0301.size() == 9); + VERIFY(T::copyCount() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // single erase + T::reset(); + m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13] + VERIFY(list0301.size() == 8); + VERIFY(T::dtorCount() == 1); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range erase + T::reset(); + m = list0301.erase(list0301.begin(), m); // should be [13 13] + VERIFY(list0301.size() == 2); + VERIFY(T::dtorCount() == 6); + VERIFY(m->id() == 13); + + // range fill at beginning + const int A[] = {321, 322, 333}; + const int N = sizeof(A) / sizeof(int); + T::reset(); + b = list0301.begin(); + list0301.insert(b, A, A + N); // should be [321 322 333 13 13] + VERIFY(list0301.size() == 5); + VERIFY(T::copyCount() == 3); + VERIFY(m->id() == 13); + + // range fill at end + T::reset(); + list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] + VERIFY(list0301.size() == 8); + VERIFY(T::copyCount() == 3); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range fill in middle + T::reset(); + list0301.insert(m, A, A + N); + VERIFY(list0301.size() == 11); + VERIFY(T::copyCount() == 3); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + T::reset(); + list0301.clear(); + VERIFY(list0301.size() == 0); + VERIFY(T::dtorCount() == 11); + VERIFY(e == list0301.end()); +} + +int main() +{ + test03(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc new file mode 100644 index 000000000000..24eff6707507 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2001, 2003 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include +#include + +typedef __gnu_test::copy_tracker T; + +bool test = true; + +// general single insert/erase + swap +void +test02() +{ + std::list list0201; + T::reset(); + + list0201.insert(list0201.begin(), T(1)); // list should be [1] + VERIFY(list0201.size() == 1); + VERIFY(T::copyCount() == 1); + + list0201.insert(list0201.end(), T(2)); // list should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(T::copyCount() == 2); + + std::list::iterator i = list0201.begin(); + std::list::const_iterator j = i; + VERIFY(i->id() == 1); ++i; + VERIFY(i->id() == 2); + + list0201.insert(i, T(3)); // list should be [1 3 2] + VERIFY(list0201.size() == 3); + VERIFY(T::copyCount() == 3); + + std::list::const_iterator k = i; + VERIFY(i->id() == 2); --i; + VERIFY(i->id() == 3); --i; + VERIFY(i->id() == 1); + VERIFY(j->id() == 1); + + ++i; // will point to '3' + T::reset(); + list0201.erase(i); // should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(T::dtorCount() == 1); + VERIFY(k->id() == 2); + VERIFY(j->id() == 1); + + std::list list0202; + T::reset(); + VERIFY(list0202.size() == 0); + VERIFY(T::copyCount() == 0); + VERIFY(T::dtorCount() == 0); + + // member swap + list0202.swap(list0201); + VERIFY(list0201.size() == 0); + VERIFY(list0202.size() == 2); + VERIFY(T::copyCount() == 0); + VERIFY(T::dtorCount() == 0); + + // specialized swap + swap(list0201, list0202); + VERIFY(list0201.size() == 2); + VERIFY(list0202.size() == 0); + VERIFY(T::copyCount() == 0); + VERIFY(T::dtorCount() == 0); +} + +int main() +{ + test02(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc new file mode 100644 index 000000000000..ee4a93c6f0aa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc @@ -0,0 +1,124 @@ +// Copyright (C) 2001, 2003 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include +#include + +typedef __gnu_test::copy_tracker T; + +bool test = true; + + +// This test verifies the following. +// +// 23.2.2.3 void push_front(const T& x) +// 23.2.2.3 void push_back(const T& x) +// 23.2.2.3 (1) iterator and reference non-invalidation +// 23.2.2.3 (1) exception effects +// 23.2.2.3 (2) complexity requirements +// +// 23.2.2.3 void pop_front() +// 23.2.2.3 void pop_back() +// 23.2.2.3 (3) iterator and reference non-invalidation +// 23.2.2.3 (5) complexity requirements +// +// 23.2.2 const_iterator begin() const +// 23.2.2 iterator end() +// 23.2.2 const_reverse_iterator rbegin() const +// 23.2.2 _reference front() +// 23.2.2 const_reference front() const +// 23.2.2 reference back() +// 23.2.2 const_reference back() const +// +void +test01() +{ + std::list list0101; + std::list::const_iterator i; + std::list::const_reverse_iterator j; + std::list::iterator k; + T::reset(); + + list0101.push_back(T(1)); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(T::copyCount() == 1); + + k = list0101.end(); + --k; + VERIFY(k->id() == 1); + VERIFY(k->id() == list0101.front().id()); + VERIFY(k->id() == list0101.back().id()); + + list0101.push_front(T(2)); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(T::copyCount() == 2); + VERIFY(k->id() == 1); + + list0101.push_back(T(3)); // list should be [2 1 3] + VERIFY(list0101.size() == 3); + VERIFY(T::copyCount() == 3); + VERIFY(k->id() == 1); + + try + { + list0101.push_back(T(4, true)); + VERIFY(("no exception thrown", false)); + } + catch (...) + { + VERIFY(list0101.size() == 3); + VERIFY(T::copyCount() == 4); + } + + i = list0101.begin(); + VERIFY(i->id() == 2); + VERIFY(i->id() == list0101.front().id()); + + j = list0101.rbegin(); + VERIFY(j->id() == 3); + VERIFY(j->id() == list0101.back().id()); + + ++i; + VERIFY(i->id() == 1); + + ++j; + VERIFY(j->id() == 1); + + T::reset(); + + list0101.pop_back(); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(T::dtorCount() == 1); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); + + list0101.pop_front(); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(T::dtorCount() == 2); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); +} + +int main() +{ + test01(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/operators/1.cc b/libstdc++-v3/testsuite/23_containers/list/operators/1.cc new file mode 100644 index 000000000000..a695b28f8bcc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operators/1.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2001 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.4 list operations [lib.list.ops] + +#include +#include + +bool test = true; + +// splice(p, x) + remove + reverse +void +test01() +{ + const int K = 417; + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {K, K, K, K, K}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + + std::list list0101(A, A + N); + std::list list0102(B, B + M); + std::list::iterator p = list0101.begin(); + + VERIFY(list0101.size() == N); + VERIFY(list0102.size() == M); + + ++p; + list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5] + VERIFY(list0101.size() == N + M); + VERIFY(list0102.size() == 0); + + // remove range from middle + list0101.remove(K); + VERIFY(list0101.size() == N); + + // remove first element + list0101.remove(1); + VERIFY(list0101.size() == N - 1); + + // remove last element + list0101.remove(5); + VERIFY(list0101.size() == N - 2); + + // reverse + list0101.reverse(); + p = list0101.begin(); + VERIFY(*p == 4); ++p; + VERIFY(*p == 3); ++p; + VERIFY(*p == 2); ++p; + VERIFY(p == list0101.end()); +} + +main(int argc, char* argv[]) +{ + test01(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/operators/2.cc b/libstdc++-v3/testsuite/23_containers/list/operators/2.cc new file mode 100644 index 000000000000..09dc0f1c74f5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operators/2.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2001 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.4 list operations [lib.list.ops] + +#include +#include + +bool test = true; + +// splice(p, x, i) + remove_if + operator== +void +test02() +{ + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {2, 1, 3, 4, 5}; + const int C[] = {1, 3, 4, 5, 2}; + const int N = sizeof(A) / sizeof(int); + std::list list0201(A, A + N); + std::list list0202(A, A + N); + std::list list0203(B, B + N); + std::list list0204(C, C + N); + std::list::iterator i = list0201.begin(); + + // result should be unchanged + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 == list0202); + + // result should be [2 1 3 4 5] + ++i; + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 != list0202); + VERIFY(list0201 == list0203); + + // result should be [1 3 4 5 2] + list0201.splice(list0201.end(), list0201, i); + VERIFY(list0201 == list0204); +} + +main(int argc, char* argv[]) +{ + test02(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/operators/3.cc b/libstdc++-v3/testsuite/23_containers/list/operators/3.cc new file mode 100644 index 000000000000..c12286c62441 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operators/3.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2001 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.4 list operations [lib.list.ops] + +#include +#include + +bool test = true; + +// splice(p, x, f, l) + sort + merge + unique +void +test03() +{ + const int A[] = {103, 203, 603, 303, 403, 503}; + const int B[] = {417, 417, 417, 417, 417}; + const int E[] = {103, 417, 417, 203, 603, 303, 403, 503}; + const int F[] = {103, 203, 303, 403, 417, 417, 503, 603}; + const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603}; + const int D[] = {103, 203, 303, 403, 417, 503, 603}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int P = sizeof(C) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + const int R = sizeof(E) / sizeof(int); + + std::list list0301(A, A + N); + std::list list0302(B, B + M); + std::list list0303(C, C + P); + std::list list0304(D, D + Q); + std::list list0305(E, E + R); + std::list list0306(F, F + R); + std::list::iterator p = list0301.begin(); + std::list::iterator q = list0302.begin(); + + ++p; ++q; ++q; + list0301.splice(p, list0302, list0302.begin(), q); + VERIFY(list0301 == list0305); + VERIFY(list0301.size() == N + 2); + VERIFY(list0302.size() == M - 2); + + list0301.sort(); + VERIFY(list0301 == list0306); + + list0301.merge(list0302); + VERIFY(list0301.size() == N + M); + VERIFY(list0302.size() == 0); + VERIFY(list0301 == list0303); + + list0301.unique(); + VERIFY(list0301 == list0304); +} + +main(int argc, char* argv[]) +{ + test03(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list/operators/4.cc b/libstdc++-v3/testsuite/23_containers/list/operators/4.cc new file mode 100644 index 000000000000..6a0b36e38797 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operators/4.cc @@ -0,0 +1,94 @@ +// Copyright (C) 2001 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.2.4 list operations [lib.list.ops] + +#include +#include + +bool test = true; + +// A comparison predicate to order by rightmost digit. Tracks call counts for +// performance checks. +struct CompLastLt +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 < y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastLt::itsCount; + +struct CompLastEq +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 == y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastEq::itsCount; + +// sort(pred) + merge(pred) + unique(pred) +// also checks performance requirements +void +test04() +{ + const int A[] = {1, 2, 3, 4, 5, 6}; + const int B[] = {12, 15, 13, 14, 11}; + const int C[] = {11, 12, 13, 14, 15}; + const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + + std::list list0401(A, A + N); + std::list list0402(B, B + M); + std::list list0403(C, C + M); + std::list list0404(D, D + Q); + std::list list0405(A, A + N); + + // sort B + CompLastLt lt; + + CompLastLt::reset(); + list0402.sort(lt); + VERIFY(list0402 == list0403); + + CompLastLt::reset(); + list0401.merge(list0402, lt); + VERIFY(list0401 == list0404); + VERIFY(lt.count() <= (N + M - 1)); + + CompLastEq eq; + + CompLastEq::reset(); + list0401.unique(eq); + VERIFY(list0401 == list0405); + VERIFY(eq.count() == (N + M - 1)); +} + +main(int argc, char* argv[]) +{ + test04(); + return 0; +} +// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list_ctor.cc b/libstdc++-v3/testsuite/23_containers/list_ctor.cc deleted file mode 100644 index e358e7a9fe4b..000000000000 --- a/libstdc++-v3/testsuite/23_containers/list_ctor.cc +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// 23.2.2.1 list constructors, copy, and assignment - -#include -#include - -bool test = true; - -// A nontrivial type. -template - struct A { }; - -// Another nontrivial type -struct B { }; - -// A nontrivial type convertible from an int -struct C { - C(int i) : i_(i) { } - bool operator==(const C& rhs) { return i_ == rhs.i_; } - int i_; -}; - -// Default constructor, basic properties -// -// This test verifies the following. -// 23.2.2.1 explicit list(const a& = Allocator()) -// 23.1 (7) iterator behaviour of empty containers -// 23.2.2 iterator begin() -// 23.2.2 iterator end() -// 23.2.2 size_type size() const -// 23.2.2 existence of required typedefs -// -void -test01() -{ - std::list< A > list0101; - VERIFY(list0101.begin() == list0101.end()); - VERIFY(list0101.size() == 0); - - // check type definitions -- will fail compile if missing - typedef std::list< A >::reference reference; - typedef std::list< A >::const_reference const_reference; - typedef std::list< A >::iterator iterator; - typedef std::list< A >::const_iterator const_iterator; - typedef std::list< A >::size_type size_type; - typedef std::list< A >::difference_type difference_type; - typedef std::list< A >::value_type value_type; - typedef std::list< A >::allocator_type allocator_type; - typedef std::list< A >::pointer pointer; - typedef std::list< A >::const_pointer const_pointer; - typedef std::list< A >::reverse_iterator reverse_iterator; - typedef std::list< A >::const_reverse_iterator const_reverse_iterator; - - // allocator checks? -} - -// Fill constructor -// -// This test verifies the following. -// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) -// 23.2.2 const_iterator begin() const -// 23.2.2 const_iterator end() const -// 23.2.2 size_type size() const -// -void -test02() -{ - const int LIST_SIZE = 5; - const int INIT_VALUE = 7; - int count; - std::list::const_iterator i; - - // nontrivial value_type - std::list< A > list0201(LIST_SIZE); - - // default value - std::list list0202(LIST_SIZE); - for (i = list0202.begin(), count = 0; - i != list0202.end(); - ++i, ++count) - VERIFY(*i == 0); - VERIFY(count == LIST_SIZE); - VERIFY(list0202.size() == LIST_SIZE); - - // explicit value - std::list list0203(LIST_SIZE, INIT_VALUE); - for (i = list0203.begin(), count = 0; - i != list0203.end(); - ++i, ++count) - VERIFY(*i == INIT_VALUE); - VERIFY(count == LIST_SIZE); - VERIFY(list0203.size() == LIST_SIZE); -} - -// Fill constructor disguised as a range constructor -void -test02D() -{ - const int LIST_SIZE = 5; - const int INIT_VALUE = 7; - int count = 0; - std::list list0204(LIST_SIZE, INIT_VALUE); - std::list::iterator i = list0204.begin(); - for (; i != list0204.end(); ++i, ++count) - VERIFY(*i == INIT_VALUE); - VERIFY(count == LIST_SIZE); - VERIFY(list0204.size() == LIST_SIZE); -} - -// Range constructor -// -// This test verifies the following. -// 23.2.2.1 template list(InputIterator f, InputIterator l, const Allocator& a = Allocator()) -// 23.2.2 const_iterator begin() const -// 23.2.2 const_iterator end() const -// 23.2.2 size_type size() const -// -void -test03() -{ - const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; - const int N = sizeof(A) / sizeof(int); - int count; - std::list::const_iterator i; - - // construct from a dissimilar range - std::list list0301(A, A + N); - for (i = list0301.begin(), count = 0; - i != list0301.end(); - ++i, ++count) - VERIFY(*i == A[count]); - VERIFY(count == N); - VERIFY(list0301.size() == N); - - // construct from a similar range - std::list list0302(list0301.begin(), list0301.end()); - for (i = list0302.begin(), count = 0; - i != list0302.end(); - ++i, ++count) - VERIFY(*i == A[count]); - VERIFY(count == N); - VERIFY(list0302.size() == N); -} - -// Copy constructor -// -// This test verifies the following. -// 23.2.2.1 list(const list& x) -// 23.2.2 reverse_iterator rbegin() -// 23.2.2 reverse_iterator rend() -// 23.2.2 size_type size() const -// -void -test04() -{ - const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; - const int N = sizeof(A) / sizeof(int); - int count; - std::list::reverse_iterator i; - std::list list0401(A, A + N); - - std::list list0402(list0401); - for (i = list0401.rbegin(), count = N - 1; - i != list0401.rend(); - ++i, --count) - VERIFY(*i == A[count]); - VERIFY(count == -1); - VERIFY(list0401.size() == N); -} - -// Range assign -// -// This test verifies the following. -// 23.2.2.1 void assign(InputIterator f, InputIterator l) -// 23.2.2 const_iterator begin() const -// 23.2.2 const_iterator end() const -// 23.2.2 size_type size() const -// -void -test05() -{ - const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; - const int B[] = {101, 102, 103, 104, 105}; - const int N = sizeof(A) / sizeof(int); - const int M = sizeof(B) / sizeof(int); - int count; - std::list::const_iterator i; - - std::list list0501; - - // make it bigger - list0501.assign(A, A + N); - for (i = list0501.begin(), count = 0; - i != list0501.end(); - ++i, ++count) - VERIFY(*i == A[count]); - VERIFY(count == N); - VERIFY(list0501.size() == N); - - // make it smaller - list0501.assign(B, B + M); - for (i = list0501.begin(), count = 0; - i != list0501.end(); - ++i, ++count) - VERIFY(*i == B[count]); - VERIFY(count == M); - VERIFY(list0501.size() == M); -} - -// Fill assign -// -// This test verifies the following. -// 23.2.2.1 void assign(size_type n, const T& v) -// 23.2.2 const_iterator begin() const -// 23.2.2 const_iterator end() const -// 23.2.2 size_type size() const -// -void -test06() -{ - const int BIG_LIST_SIZE = 11; - const int BIG_INIT_VALUE = 7; - const int SMALL_LIST_SIZE = 5; - const int SMALL_INIT_VALUE = 17; - int count; - std::list::const_iterator i; - - std::list list0601; - VERIFY(list0601.size() == 0); - - // make it bigger - list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE); - for (i = list0601.begin(), count = 0; - i != list0601.end(); - ++i, ++count) - VERIFY(*i == BIG_INIT_VALUE); - VERIFY(count == BIG_LIST_SIZE); - VERIFY(list0601.size() == BIG_LIST_SIZE); - - // make it shrink - list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE); - for (i = list0601.begin(), count = 0; - i != list0601.end(); - ++i, ++count) - VERIFY(*i == SMALL_INIT_VALUE); - VERIFY(count == SMALL_LIST_SIZE); - VERIFY(list0601.size() == SMALL_LIST_SIZE); -} - -// Fill Assignment disguised as a Range Assignment -void -test06D() -{ - const int LIST_SIZE = 5; - const int INIT_VALUE = 7; - int count = 0; - std::list list0604; - VERIFY(list0604.size() == 0); - - list0604.assign(LIST_SIZE, INIT_VALUE); - std::list::iterator i = list0604.begin(); - for (; i != list0604.end(); ++i, ++count) - VERIFY(*i == INIT_VALUE); - VERIFY(count == LIST_SIZE); - VERIFY(list0604.size() == LIST_SIZE); -} - -// Assignment operator -// -// This test verifies the following. -// 23.2.2 operator=(const list& x) -// 23.2.2 iterator begin() -// 23.2.2 iterator end() -// 23.2.2 size_type size() const -// 23.2.2 bool operator==(const list& x, const list& y) -// -void -test07() -{ - const int A[] = {701, 702, 703, 704, 705}; - const int N = sizeof(A) / sizeof(int); - int count; - std::list::iterator i; - - std::list list0701(A, A + N); - VERIFY(list0701.size() == N); - - std::list list0702; - VERIFY(list0702.size() == 0); - - list0702 = list0701; - VERIFY(list0702.size() == N); - for (i = list0702.begin(), count = 0; - i != list0702.end(); - ++i, ++count) - VERIFY(*i == A[count]); - VERIFY(count == N); - VERIFY(list0702 == list0701); -} - -int main() -{ - test01(); - test02(); - test02D(); - test03(); - test04(); - test05(); - test06(); - test06D(); - test07(); - - return !test; -} -// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list_modifiers.cc b/libstdc++-v3/testsuite/23_containers/list_modifiers.cc deleted file mode 100644 index 3e9fa498b84b..000000000000 --- a/libstdc++-v3/testsuite/23_containers/list_modifiers.cc +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright (C) 2001, 2003 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// 23.2.2.3 list modifiers [lib.list.modifiers] - -#include -#include - -typedef __gnu_test::copy_tracker T; - -bool test = true; - - -// This test verifies the following. -// -// 23.2.2.3 void push_front(const T& x) -// 23.2.2.3 void push_back(const T& x) -// 23.2.2.3 (1) iterator and reference non-invalidation -// 23.2.2.3 (1) exception effects -// 23.2.2.3 (2) complexity requirements -// -// 23.2.2.3 void pop_front() -// 23.2.2.3 void pop_back() -// 23.2.2.3 (3) iterator and reference non-invalidation -// 23.2.2.3 (5) complexity requirements -// -// 23.2.2 const_iterator begin() const -// 23.2.2 iterator end() -// 23.2.2 const_reverse_iterator rbegin() const -// 23.2.2 _reference front() -// 23.2.2 const_reference front() const -// 23.2.2 reference back() -// 23.2.2 const_reference back() const -// -void -test01() -{ - std::list list0101; - std::list::const_iterator i; - std::list::const_reverse_iterator j; - std::list::iterator k; - T::reset(); - - list0101.push_back(T(1)); // list should be [1] - VERIFY(list0101.size() == 1); - VERIFY(T::copyCount() == 1); - - k = list0101.end(); - --k; - VERIFY(k->id() == 1); - VERIFY(k->id() == list0101.front().id()); - VERIFY(k->id() == list0101.back().id()); - - list0101.push_front(T(2)); // list should be [2 1] - VERIFY(list0101.size() == 2); - VERIFY(T::copyCount() == 2); - VERIFY(k->id() == 1); - - list0101.push_back(T(3)); // list should be [2 1 3] - VERIFY(list0101.size() == 3); - VERIFY(T::copyCount() == 3); - VERIFY(k->id() == 1); - - try - { - list0101.push_back(T(4, true)); - VERIFY(("no exception thrown", false)); - } - catch (...) - { - VERIFY(list0101.size() == 3); - VERIFY(T::copyCount() == 4); - } - - i = list0101.begin(); - VERIFY(i->id() == 2); - VERIFY(i->id() == list0101.front().id()); - - j = list0101.rbegin(); - VERIFY(j->id() == 3); - VERIFY(j->id() == list0101.back().id()); - - ++i; - VERIFY(i->id() == 1); - - ++j; - VERIFY(j->id() == 1); - - T::reset(); - - list0101.pop_back(); // list should be [2 1] - VERIFY(list0101.size() == 2); - VERIFY(T::dtorCount() == 1); - VERIFY(i->id() == 1); - VERIFY(k->id() == 1); - - list0101.pop_front(); // list should be [1] - VERIFY(list0101.size() == 1); - VERIFY(T::dtorCount() == 2); - VERIFY(i->id() == 1); - VERIFY(k->id() == 1); -} - -// general single insert/erase + swap -void -test02() -{ - std::list list0201; - T::reset(); - - list0201.insert(list0201.begin(), T(1)); // list should be [1] - VERIFY(list0201.size() == 1); - VERIFY(T::copyCount() == 1); - - list0201.insert(list0201.end(), T(2)); // list should be [1 2] - VERIFY(list0201.size() == 2); - VERIFY(T::copyCount() == 2); - - std::list::iterator i = list0201.begin(); - std::list::const_iterator j = i; - VERIFY(i->id() == 1); ++i; - VERIFY(i->id() == 2); - - list0201.insert(i, T(3)); // list should be [1 3 2] - VERIFY(list0201.size() == 3); - VERIFY(T::copyCount() == 3); - - std::list::const_iterator k = i; - VERIFY(i->id() == 2); --i; - VERIFY(i->id() == 3); --i; - VERIFY(i->id() == 1); - VERIFY(j->id() == 1); - - ++i; // will point to '3' - T::reset(); - list0201.erase(i); // should be [1 2] - VERIFY(list0201.size() == 2); - VERIFY(T::dtorCount() == 1); - VERIFY(k->id() == 2); - VERIFY(j->id() == 1); - - std::list list0202; - T::reset(); - VERIFY(list0202.size() == 0); - VERIFY(T::copyCount() == 0); - VERIFY(T::dtorCount() == 0); - - // member swap - list0202.swap(list0201); - VERIFY(list0201.size() == 0); - VERIFY(list0202.size() == 2); - VERIFY(T::copyCount() == 0); - VERIFY(T::dtorCount() == 0); - - // specialized swap - swap(list0201, list0202); - VERIFY(list0201.size() == 2); - VERIFY(list0202.size() == 0); - VERIFY(T::copyCount() == 0); - VERIFY(T::dtorCount() == 0); -} - -// range and fill insert/erase + clear -// missing: o fill insert disguised as a range insert in all its variants -// o exception effects -void -test03() -{ - std::list list0301; - T::reset(); - - // fill insert at beginning of list / empty list - list0301.insert(list0301.begin(), 3, T(11)); // should be [11 11 11] - VERIFY(list0301.size() == 3); - VERIFY(T::copyCount() == 3); - - // save iterators to verify post-insert validity - std::list::iterator b = list0301.begin(); - std::list::iterator m = list0301.end(); --m; - std::list::iterator e = list0301.end(); - - // fill insert at end of list - T::reset(); - list0301.insert(list0301.end(), 3, T(13)); // should be [11 11 11 13 13 13] - VERIFY(list0301.size() == 6); - VERIFY(T::copyCount() == 3); - VERIFY(b == list0301.begin() && b->id() == 11); - VERIFY(e == list0301.end()); - VERIFY(m->id() == 11); - - // fill insert in the middle of list - ++m; - T::reset(); - list0301.insert(m, 3, T(12)); // should be [11 11 11 12 12 12 13 13 13] - VERIFY(list0301.size() == 9); - VERIFY(T::copyCount() == 3); - VERIFY(b == list0301.begin() && b->id() == 11); - VERIFY(e == list0301.end()); - VERIFY(m->id() == 13); - - // single erase - T::reset(); - m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13] - VERIFY(list0301.size() == 8); - VERIFY(T::dtorCount() == 1); - VERIFY(b == list0301.begin() && b->id() == 11); - VERIFY(e == list0301.end()); - VERIFY(m->id() == 13); - - // range erase - T::reset(); - m = list0301.erase(list0301.begin(), m); // should be [13 13] - VERIFY(list0301.size() == 2); - VERIFY(T::dtorCount() == 6); - VERIFY(m->id() == 13); - - // range fill at beginning - const int A[] = {321, 322, 333}; - const int N = sizeof(A) / sizeof(int); - T::reset(); - b = list0301.begin(); - list0301.insert(b, A, A + N); // should be [321 322 333 13 13] - VERIFY(list0301.size() == 5); - VERIFY(T::copyCount() == 3); - VERIFY(m->id() == 13); - - // range fill at end - T::reset(); - list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] - VERIFY(list0301.size() == 8); - VERIFY(T::copyCount() == 3); - VERIFY(e == list0301.end()); - VERIFY(m->id() == 13); - - // range fill in middle - T::reset(); - list0301.insert(m, A, A + N); - VERIFY(list0301.size() == 11); - VERIFY(T::copyCount() == 3); - VERIFY(e == list0301.end()); - VERIFY(m->id() == 13); - - T::reset(); - list0301.clear(); - VERIFY(list0301.size() == 0); - VERIFY(T::dtorCount() == 11); - VERIFY(e == list0301.end()); -} - -int main() -{ - test01(); - test02(); - test03(); - - return !test; -} -// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/list_operators.cc b/libstdc++-v3/testsuite/23_containers/list_operators.cc deleted file mode 100644 index 69a59943e1e7..000000000000 --- a/libstdc++-v3/testsuite/23_containers/list_operators.cc +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (C) 2001 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 Pred 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// 23.2.2.4 list operations [lib.list.ops] - -#include -#include - -bool test = true; - -// splice(p, x) + remove + reverse -void -test01() -{ - const int K = 417; - const int A[] = {1, 2, 3, 4, 5}; - const int B[] = {K, K, K, K, K}; - const int N = sizeof(A) / sizeof(int); - const int M = sizeof(B) / sizeof(int); - - std::list list0101(A, A + N); - std::list list0102(B, B + M); - std::list::iterator p = list0101.begin(); - - VERIFY(list0101.size() == N); - VERIFY(list0102.size() == M); - - ++p; - list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5] - VERIFY(list0101.size() == N + M); - VERIFY(list0102.size() == 0); - - // remove range from middle - list0101.remove(K); - VERIFY(list0101.size() == N); - - // remove first element - list0101.remove(1); - VERIFY(list0101.size() == N - 1); - - // remove last element - list0101.remove(5); - VERIFY(list0101.size() == N - 2); - - // reverse - list0101.reverse(); - p = list0101.begin(); - VERIFY(*p == 4); ++p; - VERIFY(*p == 3); ++p; - VERIFY(*p == 2); ++p; - VERIFY(p == list0101.end()); -} - -// splice(p, x, i) + remove_if + operator== -void -test02() -{ - const int A[] = {1, 2, 3, 4, 5}; - const int B[] = {2, 1, 3, 4, 5}; - const int C[] = {1, 3, 4, 5, 2}; - const int N = sizeof(A) / sizeof(int); - std::list list0201(A, A + N); - std::list list0202(A, A + N); - std::list list0203(B, B + N); - std::list list0204(C, C + N); - std::list::iterator i = list0201.begin(); - - // result should be unchanged - list0201.splice(list0201.begin(), list0201, i); - VERIFY(list0201 == list0202); - - // result should be [2 1 3 4 5] - ++i; - list0201.splice(list0201.begin(), list0201, i); - VERIFY(list0201 != list0202); - VERIFY(list0201 == list0203); - - // result should be [1 3 4 5 2] - list0201.splice(list0201.end(), list0201, i); - VERIFY(list0201 == list0204); -} - -// splice(p, x, f, l) + sort + merge + unique -void -test03() -{ - const int A[] = {103, 203, 603, 303, 403, 503}; - const int B[] = {417, 417, 417, 417, 417}; - const int E[] = {103, 417, 417, 203, 603, 303, 403, 503}; - const int F[] = {103, 203, 303, 403, 417, 417, 503, 603}; - const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603}; - const int D[] = {103, 203, 303, 403, 417, 503, 603}; - const int N = sizeof(A) / sizeof(int); - const int M = sizeof(B) / sizeof(int); - const int P = sizeof(C) / sizeof(int); - const int Q = sizeof(D) / sizeof(int); - const int R = sizeof(E) / sizeof(int); - - std::list list0301(A, A + N); - std::list list0302(B, B + M); - std::list list0303(C, C + P); - std::list list0304(D, D + Q); - std::list list0305(E, E + R); - std::list list0306(F, F + R); - std::list::iterator p = list0301.begin(); - std::list::iterator q = list0302.begin(); - - ++p; ++q; ++q; - list0301.splice(p, list0302, list0302.begin(), q); - VERIFY(list0301 == list0305); - VERIFY(list0301.size() == N + 2); - VERIFY(list0302.size() == M - 2); - - list0301.sort(); - VERIFY(list0301 == list0306); - - list0301.merge(list0302); - VERIFY(list0301.size() == N + M); - VERIFY(list0302.size() == 0); - VERIFY(list0301 == list0303); - - list0301.unique(); - VERIFY(list0301 == list0304); -} - -// A comparison predicate to order by rightmost digit. Tracks call counts for -// performance checks. -struct CompLastLt -{ - bool operator()(const int x, const int y) { ++itsCount; return x % 10 < y % 10; } - static int count() { return itsCount; } - static void reset() { itsCount = 0; } - static int itsCount; -}; - -int CompLastLt::itsCount; - -struct CompLastEq -{ - bool operator()(const int x, const int y) { ++itsCount; return x % 10 == y % 10; } - static int count() { return itsCount; } - static void reset() { itsCount = 0; } - static int itsCount; -}; - -int CompLastEq::itsCount; - -// sort(pred) + merge(pred) + unique(pred) -// also checks performance requirements -void -test04() -{ - const int A[] = {1, 2, 3, 4, 5, 6}; - const int B[] = {12, 15, 13, 14, 11}; - const int C[] = {11, 12, 13, 14, 15}; - const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6}; - const int N = sizeof(A) / sizeof(int); - const int M = sizeof(B) / sizeof(int); - const int Q = sizeof(D) / sizeof(int); - - std::list list0401(A, A + N); - std::list list0402(B, B + M); - std::list list0403(C, C + M); - std::list list0404(D, D + Q); - std::list list0405(A, A + N); - - // sort B - CompLastLt lt; - - CompLastLt::reset(); - list0402.sort(lt); - VERIFY(list0402 == list0403); - - CompLastLt::reset(); - list0401.merge(list0402, lt); - VERIFY(list0401 == list0404); - VERIFY(lt.count() <= (N + M - 1)); - - CompLastEq eq; - - CompLastEq::reset(); - list0401.unique(eq); - VERIFY(list0401 == list0405); - VERIFY(eq.count() == (N + M - 1)); -} - -main(int argc, char* argv[]) -{ - test01(); - test02(); - test03(); - test04(); - - return !test; -} -// vi:set sw=2 ts=2: diff --git a/libstdc++-v3/testsuite/23_containers/map_insert.cc b/libstdc++-v3/testsuite/23_containers/map/insert/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/map_insert.cc rename to libstdc++-v3/testsuite/23_containers/map/insert/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/map_operators.cc b/libstdc++-v3/testsuite/23_containers/map/operators/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/map_operators.cc rename to libstdc++-v3/testsuite/23_containers/map/operators/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/map_operators_neg.cc b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/map_operators_neg.cc rename to libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc diff --git a/libstdc++-v3/testsuite/23_containers/multiset.cc b/libstdc++-v3/testsuite/23_containers/multiset/insert/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/multiset.cc rename to libstdc++-v3/testsuite/23_containers/multiset/insert/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/adaptors.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc similarity index 83% rename from libstdc++-v3/testsuite/23_containers/adaptors.cc rename to libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc index e0bd8618300a..9cea073706db 100644 --- a/libstdc++-v3/testsuite/23_containers/adaptors.cc +++ b/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc @@ -21,33 +21,8 @@ // 23.2.3 container adaptros #include -#include #include -// libstdc++/7157 -void -test01() -{ - std::queue q; - - q.push(1); - q.front(); - q.pop(); -} - - -// libstdc++/7158 -void -test02() -{ - std::stack st; - - st.push(1); - st.top() = 42; - st.pop(); -} - - // libstdc++/7161 void test03() @@ -68,12 +43,8 @@ test03() pq.pop(); } - int main() { - test01(); - test02(); test03(); - return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc b/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc new file mode 100644 index 000000000000..f1da79580452 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc @@ -0,0 +1,41 @@ +// 2002-06-28 pme + +// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.3 container adaptros + +#include +#include + +// libstdc++/7157 +void +test01() +{ + std::queue q; + + q.push(1); + q.front(); + q.pop(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set_operators_neg.cc b/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/set_operators_neg.cc rename to libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc diff --git a/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc b/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc new file mode 100644 index 000000000000..4bfc10154867 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc @@ -0,0 +1,41 @@ +// 2002-06-28 pme + +// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.3 container adaptros + +#include +#include + +// libstdc++/7158 +void +test02() +{ + std::stack st; + + st.push(1); + st.top() = 42; + st.pop(); +} + +int main() +{ + test02(); + return 0; +} 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 000000000000..8d5564203578 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc @@ -0,0 +1,37 @@ +// 2002-03-05 Stephen M. Webb + +// Copyright (C) 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc similarity index 94% rename from libstdc++-v3/testsuite/23_containers/vector_bool.cc rename to libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc index 3deec4985d21..acc6e45f5453 100644 --- a/libstdc++-v3/testsuite/23_containers/vector_bool.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc @@ -23,13 +23,6 @@ #include #include -void test01() -{ - std::vector::iterator i; - if (false) - ++i; -} - // libstdc++/6886 void test02() { @@ -56,7 +49,6 @@ void test02() int main() { - test01(); test02(); return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc new file mode 100644 index 000000000000..af0eb93c9df1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc @@ -0,0 +1,61 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.2 vector capacity + +#include +#include +#include +#include + +template + struct A { }; + +struct B { }; + +void test01() +{ + // non POD types + bool test = true; + std::vector< A > vec01; + typedef std::vector< A >::size_type size_type; + + size_type sz01 = vec01.capacity(); + vec01.reserve(100); + size_type sz02 = vec01.capacity(); + VERIFY( sz02 >= sz01 ); + + sz01 = vec01.size() + 5; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY( sz01 == sz02 ); + + sz01 = vec01.size() - 5; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY( sz01 == sz02 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector_capacity.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc similarity index 70% rename from libstdc++-v3/testsuite/23_containers/vector_capacity.cc rename to libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc index 526e37e7635b..49cfbfa30bd6 100644 --- a/libstdc++-v3/testsuite/23_containers/vector_capacity.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc @@ -32,79 +32,6 @@ using __gnu_test::tracker_alloc; using __gnu_test::copy_constructor; using __gnu_test::assignment_operator; using __gnu_test::destructor; - -template - struct A { }; - -struct B { }; - -void test01() -{ - // non POD types - bool test = true; - std::vector< A > vec01; - typedef std::vector< A >::size_type size_type; - - size_type sz01 = vec01.capacity(); - vec01.reserve(100); - size_type sz02 = vec01.capacity(); - VERIFY( sz02 >= sz01 ); - - sz01 = vec01.size() + 5; - vec01.resize(sz01); - sz02 = vec01.size(); - VERIFY( sz01 == sz02 ); - - sz01 = vec01.size() - 5; - vec01.resize(sz01); - sz02 = vec01.size(); - VERIFY( sz01 == sz02 ); -} - -// libstdc++/8230 -void test02() -{ - bool test = true; - { - std::vector array; - const std::size_t size = array.max_size(); - try - { - array.reserve(size); - } - catch (const std::length_error& error) - { - test &= false; - } - catch (const std::bad_alloc& error) - { - test &= true; - } - catch (...) - { - test &= false; - } - VERIFY( test ); - } - - { - std::vector array; - const std::size_t size = array.max_size() + 1; - try - { - array.reserve(size); - } - catch (const std::length_error& error) - { - test &= true; - } - catch (...) - { - test &= false; - } - VERIFY( test ); - } -} // Verifies basic functionality of reserve() with forced reallocation. void @@ -170,8 +97,6 @@ test_reserve_exception_guarantee() int main() { - test01(); - test02(); test_reserve(); test_reserve_exception_guarantee(); return 0; diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc new file mode 100644 index 000000000000..df7e4b20b440 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc @@ -0,0 +1,78 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.2 vector capacity + +#include +#include +#include +#include + +// libstdc++/8230 +void test02() +{ + bool test = true; + { + std::vector array; + const std::size_t size = array.max_size(); + try + { + array.reserve(size); + } + catch (const std::length_error& error) + { + test &= false; + } + catch (const std::bad_alloc& error) + { + test &= true; + } + catch (...) + { + test &= false; + } + VERIFY( test ); + } + + { + std::vector array; + const std::size_t size = array.max_size() + 1; + try + { + array.reserve(size); + } + catch (const std::length_error& error) + { + test &= true; + } + catch (...) + { + test &= false; + } + VERIFY( test ); + } +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc new file mode 100644 index 000000000000..e2f6587ab008 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc @@ -0,0 +1,48 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include +#include +#include +#include + +template + struct A { }; + +struct B { }; + +void test01() +{ + // 1 + std::vector< A > vec01; + std::vector< A > vec02(5); + typedef std::vector< A >::size_type size_type; + + vec01 = vec02; +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc new file mode 100644 index 000000000000..03f84d8b2317 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc @@ -0,0 +1,49 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include +#include +#include +#include + +template + struct A { }; + +struct B { }; + +// 2 +template class std::vector; +template class std::vector< A >; + +// libstdc++/102 +void test02() +{ + std::vector v1; + std::vector v2(v1); +} + +int main() +{ + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc new file mode 100644 index 000000000000..53afe8f7fdb3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc @@ -0,0 +1,54 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include +#include +#include +#include + +// test range constructors and range-fill constructor +void +test03() +{ + bool test = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {7, 7, 7, 7, 7}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + + std::vector v3(A, A + N); + VERIFY(std::equal(v3.begin(), v3.end(), A)); + + std::vector v4(v3.begin(), v3.end()); + VERIFY(std::equal(v4.begin(), v4.end(), A)); + + std::vector v5(M, 7); + VERIFY(std::equal(v5.begin(), v5.end(), B)); + VERIFY(std::equal(B, B + M, v5.begin())); +} + +int main() +{ + test03(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector_ctor.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc similarity index 91% rename from libstdc++-v3/testsuite/23_containers/vector_ctor.cc rename to libstdc++-v3/testsuite/23_containers/vector/cons/4.cc index 24b013b29899..af7556517f60 100644 --- a/libstdc++-v3/testsuite/23_containers/vector_ctor.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc @@ -30,62 +30,6 @@ using __gnu_test::allocation_tracker; using __gnu_test::tracker_alloc; using __gnu_test::copy_constructor; using __gnu_test::assignment_operator; - -template - struct A { }; - -struct B { }; - -void test01() -{ - // 1 - std::vector< A > vec01; - std::vector< A > vec02(5); - typedef std::vector< A >::size_type size_type; - - vec01 = vec02; -} - -// 2 -template class std::vector; -template class std::vector< A >; - - -// libstdc++/102 -void test02() -{ - std::vector v1; - std::vector v2 (v1); -} - -// test range constructors and range-fill constructor -void -test03() -{ - bool test = true; - const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; - const int B[] = {7, 7, 7, 7, 7}; - const int N = sizeof(A) / sizeof(int); - const int M = sizeof(B) / sizeof(int); - - std::vector v3(A, A + N); - VERIFY(std::equal(v3.begin(), v3.end(), A)); - - std::vector v4(v3.begin(), v3.end()); - VERIFY(std::equal(v4.begin(), v4.end(), A)); - - std::vector v5(M, 7); - VERIFY(std::equal(v5.begin(), v5.end(), B)); - VERIFY(std::equal(B, B + M, v5.begin())); -} - -// libstdc++/6513 -void test04() -{ - const char* c_strings[5] = { "1", "2", "3", "4", "5" }; - std::vector strings(c_strings, c_strings + 5); -} - // @fn test_default_ctor_exception_gurantee This test verifies that if // one of the vector's contained objects throws an exception from its @@ -625,10 +569,6 @@ test_range_assign_4_exception_guarantee() int main() { - test01(); - test02(); - test03(); - test04(); test_default_ctor_exception_gurantee(); test_copy_ctor_exception_gurantee(); test_assignment_operator_1(); diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc new file mode 100644 index 000000000000..76801831cf35 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc @@ -0,0 +1,40 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include +#include +#include +#include + +// libstdc++/6513 +void test04() +{ + const char* c_strings[5] = { "1", "2", "3", "4", "5" }; + std::vector strings(c_strings, c_strings + 5); +} + +int main() +{ + test04(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector_element_access.cc b/libstdc++-v3/testsuite/23_containers/vector/element_access/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/vector_element_access.cc rename to libstdc++-v3/testsuite/23_containers/vector/element_access/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc new file mode 100644 index 000000000000..c8321b3bd0ff --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc @@ -0,0 +1,56 @@ +// 1999-11-09 bkoz + +// Copyright (C) 1999, 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.2.4.3 vector modifiers + +#include +#include "testsuite_hooks.h" + +bool test = true; + +template + struct A { }; + +struct B { }; + +// vector::insert(iterator, inputiterator first, inputiterator last) +void +test01() +{ + // POD types + typedef std::vector vec_POD; + vec_POD vec01; + int i01 = 5; + int* pi01 = &i01; + vec01.insert(vec01.begin(), pi01, pi01 + 1); + + // non POD types + typedef std::vector< A > vec_nonPOD; + vec_nonPOD vec02; + A np01; + A* pnp01 = &np01; + vec02.insert(vec02.begin(), pnp01, pnp01 + 1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector_modifiers.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc similarity index 78% rename from libstdc++-v3/testsuite/23_containers/vector_modifiers.cc rename to libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc index 1f0b338c3b75..cc8d36d41088 100644 --- a/libstdc++-v3/testsuite/23_containers/vector_modifiers.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc @@ -25,30 +25,6 @@ bool test = true; -template - struct A { }; - -struct B { }; - -// vector::insert(iterator, inputiterator first, inputiterator last) -void -test01() -{ - // POD types - typedef std::vector vec_POD; - vec_POD vec01; - int i01 = 5; - int* pi01 = &i01; - vec01.insert(vec01.begin(), pi01, pi01 + 1); - - // non POD types - typedef std::vector< A > vec_nonPOD; - vec_nonPOD vec02; - A np01; - A* pnp01 = &np01; - vec02.insert(vec02.begin(), pnp01, pnp01 + 1); -} - // test the assign() function void test03() @@ -81,8 +57,6 @@ test03() int main() { - test01(); test03(); - - return !test; + return 0; } diff --git a/libstdc++-v3/testsuite/23_containers/vector_resize.cc b/libstdc++-v3/testsuite/23_containers/vector/resize/1.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/vector_resize.cc rename to libstdc++-v3/testsuite/23_containers/vector/resize/1.cc -- 2.39.2