From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/23_containers/deque/14340.cc | 35 ++ .../testsuite/23_containers/deque/18604.cc | 42 ++ .../23_containers/deque/capacity/29134-2.cc | 50 ++ .../23_containers/deque/capacity/29134.cc | 37 ++ .../23_containers/deque/capacity/moveable.cc | 55 +++ .../23_containers/deque/capacity/resize_size.cc | 43 ++ .../23_containers/deque/capacity/shrink_to_fit.cc | 42 ++ .../23_containers/deque/check_construct_destroy.cc | 73 +++ .../testsuite/23_containers/deque/cons/1.cc | 50 ++ .../testsuite/23_containers/deque/cons/2.cc | 522 +++++++++++++++++++++ .../testsuite/23_containers/deque/cons/assign/1.cc | 51 ++ .../23_containers/deque/cons/clear_allocator.cc | 87 ++++ .../23_containers/deque/cons/cons_size.cc | 40 ++ .../testsuite/23_containers/deque/cons/moveable.cc | 42 ++ .../23_containers/deque/cons/moveable2.cc | 55 +++ .../23_containers/deque/debug/assign1_neg.cc | 33 ++ .../23_containers/deque/debug/assign2_neg.cc | 33 ++ .../23_containers/deque/debug/assign3_neg.cc | 33 ++ .../23_containers/deque/debug/assign4_neg.cc | 32 ++ .../23_containers/deque/debug/construct1_neg.cc | 33 ++ .../23_containers/deque/debug/construct2_neg.cc | 33 ++ .../23_containers/deque/debug/construct3_neg.cc | 33 ++ .../23_containers/deque/debug/construct4_neg.cc | 32 ++ .../23_containers/deque/debug/insert1_neg.cc | 33 ++ .../23_containers/deque/debug/insert2_neg.cc | 33 ++ .../23_containers/deque/debug/insert3_neg.cc | 33 ++ .../23_containers/deque/debug/insert4_neg.cc | 32 ++ .../23_containers/deque/debug/invalidation/1.cc | 52 ++ .../23_containers/deque/debug/invalidation/2.cc | 52 ++ .../23_containers/deque/debug/invalidation/3.cc | 62 +++ .../23_containers/deque/debug/invalidation/4.cc | 74 +++ .../testsuite/23_containers/deque/init-list.cc | 60 +++ .../23_containers/deque/modifiers/erase/1.cc | 135 ++++++ .../23_containers/deque/modifiers/erase/2.cc | 114 +++++ .../23_containers/deque/modifiers/erase/3.cc | 53 +++ .../23_containers/deque/modifiers/erase/50529.cc | 38 ++ .../deque/modifiers/erase/moveable.cc | 62 +++ .../23_containers/deque/modifiers/moveable.cc | 134 ++++++ .../23_containers/deque/modifiers/swap/1.cc | 62 +++ .../23_containers/deque/modifiers/swap/2.cc | 132 ++++++ .../23_containers/deque/modifiers/swap/3.cc | 161 +++++++ .../testsuite/23_containers/deque/operators/1.cc | 62 +++ .../testsuite/23_containers/deque/operators/2.cc | 50 ++ .../testsuite/23_containers/deque/range_access.cc | 31 ++ .../23_containers/deque/requirements/citerators.cc | 30 ++ .../deque/requirements/dr438/assign_neg.cc | 35 ++ .../deque/requirements/dr438/constructor.cc | 27 ++ .../deque/requirements/dr438/constructor_1_neg.cc | 29 ++ .../deque/requirements/dr438/constructor_2_neg.cc | 30 ++ .../deque/requirements/dr438/insert_neg.cc | 36 ++ .../deque/requirements/exception/basic.cc | 40 ++ .../exception/generation_prohibited.cc | 34 ++ .../exception/propagation_consistent.cc | 35 ++ .../deque/requirements/explicit_instantiation/1.cc | 25 + .../requirements/explicit_instantiation/1_c++0x.cc | 25 + .../deque/requirements/explicit_instantiation/2.cc | 30 ++ .../deque/requirements/explicit_instantiation/3.cc | 26 + .../deque/requirements/explicit_instantiation/4.cc | 30 ++ .../deque/requirements/partial_specialization/1.cc | 33 ++ .../23_containers/deque/requirements/typedefs.cc | 25 + .../testsuite/23_containers/deque/types/1.cc | 52 ++ 61 files changed, 3493 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/deque/14340.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/18604.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/init-list.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/operators/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/operators/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/range_access.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/types/1.cc (limited to 'libstdc++-v3/testsuite/23_containers/deque') diff --git a/libstdc++-v3/testsuite/23_containers/deque/14340.cc b/libstdc++-v3/testsuite/23_containers/deque/14340.cc new file mode 100644 index 000000000..b3f7ca5dc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/14340.cc @@ -0,0 +1,35 @@ +// -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::deque container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/18604.cc b/libstdc++-v3/testsuite/23_containers/deque/18604.cc new file mode 100644 index 000000000..69e49e085 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/18604.cc @@ -0,0 +1,42 @@ +// 2005-05-09 Paolo Carlini + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/18604 +struct less; +struct allocator; +struct pair; +struct binary_function; +struct iterator; +struct iterator_traits; +struct bidirectional_iterator_tag; +struct forward_iterator_tag; +struct input_iterator_tag; +struct random_access_iterator_tag; +struct ios_base; +struct basic_string; +struct basic_istream; +struct basic_ostream; +struct char_traits; + +#include diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc new file mode 100644 index 000000000..c5d70dcf7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque d; + + try + { + d.resize(size_t(-1)); + } + catch(const std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc new file mode 100644 index 000000000..23d4dfc70 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque d; + + VERIFY( d.max_size() == d.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc new file mode 100644 index 000000000..475880888 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using namespace __gnu_test; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::deque a; + copycounter::copycount = 0; + a.resize(10); + a.resize(98); + a.resize(99); + a.resize(100); + VERIFY( copycounter::copycount == 0 ); + + a.resize(99); + a.resize(0); + VERIFY( copycounter::copycount == 0 ); + + a.resize(100); + VERIFY( copycounter::copycount == 0 ); + + a.clear(); + VERIFY( copycounter::copycount == 0 ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc new file mode 100644 index 000000000..229a0eb60 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<__gnu_test::NonCopyConstructible> d; + VERIFY( std::distance(d.begin(), d.end()) == 0 ); + + d.resize(1000); + VERIFY( std::distance(d.begin(), d.end()) == 1000 ); + for(auto it = d.begin(); it != d.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc new file mode 100644 index 000000000..4cd556456 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/42573 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector d(100); + d.push_back(1); + d.push_back(1); + // VERIFY( d.size() < d.capacity() ); + d.shrink_to_fit(); + // VERIFY( d.size() == d.capacity() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc new file mode 100644 index 000000000..23e319dfe --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc @@ -0,0 +1,73 @@ +// 2004-07-26 Matt Austern +// +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +using namespace __gnu_test; + +int main() +{ + typedef std::deque > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + Container c; + ok = check_construct_destroy("empty container", 0, 0) && ok; + } + ok = check_construct_destroy("empty container", 0, 0) && ok; + + + tracker_allocator_counter::reset(); + { + Container c(arr10, arr10 + 10); + ok = check_construct_destroy("Construct from range", 10, 0) && ok; + } + ok = check_construct_destroy("Construct from range", 10, 10) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin(), arr10[0]); + ok = check_construct_destroy("Insert element", 1, 0) && ok; + } + ok = check_construct_destroy("Insert element", 1, 11) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin() + 5, arr10, arr10+3); + ok = check_construct_destroy("Insert short range", 3, 0) && ok; + } + ok = check_construct_destroy("Insert short range", 3, 13) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin() + 7, arr10, arr10+10); + ok = check_construct_destroy("Insert long range", 10, 0) && ok; + } + ok = check_construct_destroy("Insert long range", 10, 20) && ok; + + return ok ? 0 : 1;; +} + 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 000000000..579521582 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc @@ -0,0 +1,50 @@ +// 2001-12-27 pme +// +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.1 deque constructors, copy, and assignment + +#include +#include +#include +#include +#include + +typedef std::deque<__gnu_test::object_counter> gdeque; + +bool test __attribute__((unused)) = 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/cons/2.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc new file mode 100644 index 000000000..4df44f8eb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc @@ -0,0 +1,522 @@ +// 2001-12-27 pme +// +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.1 deque constructors, copy, and assignment + +#include +#include +#include +#include +#include + +using __gnu_test::copy_tracker; +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; +using __gnu_test::copy_constructor; +using __gnu_test::assignment_operator; +using __gnu_test::object_counter; +using __gnu_test::destructor; + +typedef std::deque gdeque; + +bool test __attribute__((unused)) = true; + +// 23.2.1 required types +// +// A missing required type will cause a compile failure. +// +void +requiredTypesCheck() +{ + typedef int T; + typedef std::deque X; + + typedef X::reference reference; + typedef X::const_reference const_reference; + typedef X::iterator iterator; + typedef X::const_iterator const_iterator; + typedef X::size_type size_type; + typedef X::difference_type difference_type; + typedef X::value_type value_type; + typedef X::allocator_type allocator_type; + typedef X::pointer pointer; + typedef X::const_pointer const_pointer; + typedef X::reverse_iterator reverse_iterator; + typedef X::const_reverse_iterator const_reverse_iterator; +} + + +// @fn defaultConstructorCheck +// Explicitly checks the default deque constructor and destructor for both +// trivial and non-trivial types. In addition, the size() and empty() +// member functions are explicitly checked here since it should be their +// first use. Checking those functions means checking the begin() and +// end() and their const brethren functions as well. +// +// @verbatim +// 23.2.1.1 default ctor/dtor +// effects: +// 23.2.1.1 constructs an empty deque using the specified allocator +// postconditions: +// 23.1 table 65 u.size() == 0 +// throws: +// complexity: +// 23.1 table 65 constant +// +// 23.2.1.2 bool empty() const +// semantics: +// 23.1 table 65 a.size() == 0 +// 23.1 (7) a.begin() == a.end() +// throws: +// complexity: +// 23.1 table 65 constant +// +// 23.2.1.2 size_type size() const +// semantics: +// 23.1 table 65 a.end() - a.begin() +// throws: +// complexity: +// 23.1 table 65(A) should be constant +// +// 23.2.1 iterator begin() +// const_iterator begin() const +// iterator end() +// const_iterator end() const +// throws: +// 23.1 (10) pt. 4 does not throw +// complexity: +// 23.1 table 65 constant +// @endverbatim +void +defaultConstructorCheckPOD() +{ + // setup + typedef int T; + typedef std::deque X; + + // run test + X u; + + // assert postconditions + VERIFY(u.empty()); + VERIFY(0 == u.size()); + VERIFY(u.begin() == u.end()); + VERIFY(0 == std::distance(u.begin(), u.end())); + + // teardown +} + + +void +defaultConstructorCheck() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + copy_tracker::reset(); + + // run test + const X u; + + // assert postconditions + VERIFY(u.empty()); + VERIFY(0 == u.size()); + VERIFY(u.begin() == u.end()); + VERIFY(0 == std::distance(u.begin(), u.end())); + + // teardown +} + + +// @fn copyConstructorCheck() +// Explicitly checks the deque copy constructor. Continues verificaton of +// ancillary member functions documented under defaultConstructorCheck(). +// +// This check also tests the push_back() member function. +// +// @verbatim +// 23.2.1 copy constructor +// effects: +// postconditions: +// 22.1.1 table 65 a == X(a) +// u == a +// throws: +// complexity: +// 22.1.1 table 65 linear +// @endverbatim +void +copyConstructorCheck() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + const std::size_t copyBaseSize = 17; // arbitrary + + X a; + for (std::size_t i = 0; i < copyBaseSize; ++i) + a.push_back(i); + copy_tracker::reset(); + + // assert preconditions + VERIFY(!a.empty()); + VERIFY(copyBaseSize == a.size()); + VERIFY(a.begin() != a.end()); + VERIFY( copyBaseSize == static_cast(std::distance(a.begin(), a.end())) ); + + // run test + X u = a; + + // assert postconditions + VERIFY(u == a); + VERIFY(copyBaseSize == copy_constructor::count()); + + // teardown +} + + +// @fn fillConstructorCheck() +// This test explicitly verifies the basic fill constructor. Like the default +// constructor, later tests depend on the fill constructor working correctly. +// That means this explicit test should preceed the later tests so the error +// message given on assertion failure can be more helpful n tracking the +// problem. +// +// 23.2.1.1 fill constructor +// complexity: +// 23.2.1.1 linear in N +void +fillConstructorCheck() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + const X::size_type n(23); + const X::value_type t(111); + + copy_tracker::reset(); + + // run test + X a(n, t); + + // assert postconditions + VERIFY(n == a.size()); + VERIFY(n == copy_constructor::count()); + + // teardown +} + + +// @fn fillConstructorCheck2() +// Explicit check for fill constructors masqueraded as range constructors as +// elucidated in clause 23.1.1 paragraph 9 of the standard. +// +// 23.1.1 (9) fill constructor looking like a range constructor +void +fillConstructorCheck2() +{ + typedef copy_tracker T; + typedef std::deque X; + + const std::size_t f = 23; + const std::size_t l = 111; + + copy_tracker::reset(); + + X a(f, l); + + VERIFY(f == a.size()); + VERIFY(f == copy_constructor::count()); +} + + +// @fn rangeConstructorCheckForwardIterator() +// This test copies from one deque to another to force the copy +// constructor for T to be used because the compiler will kindly +// elide copies if the default constructor can be used with +// type conversions. Trust me. +// +// 23.2.1.1 range constructor, forward iterators +void +rangeConstructorCheckForwardIterator() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + const X::size_type n(726); + const X::value_type t(307); + X source(n, t); + X::iterator i = source.begin(); + X::iterator j = source.end(); + X::size_type rangeSize = std::distance(i, j); + + copy_tracker::reset(); + + // test + X a(i, j); + + // assert postconditions + VERIFY(rangeSize == a.size()); + VERIFY(copy_constructor::count() <= rangeSize); +} + + +// @fn rangeConstructorCheckInputIterator() +// An explicit check for range construction on an input iterator +// range, which the standard expounds upon as having a different +// complexity than forward iterators. +// +// 23.2.1.1 range constructor, input iterators +void +rangeConstructorCheckInputIterator() +{ + typedef copy_tracker T; + typedef std::deque X; + + std::istringstream ibuf("1234567890123456789"); + const X::size_type rangeSize = ibuf.str().size(); + std::istream_iterator i(ibuf); + std::istream_iterator j; + + copy_tracker::reset(); + + X a(i, j); + + VERIFY(rangeSize == a.size()); + VERIFY(copy_constructor::count() <= (2 * rangeSize)); +} + + +// 23.2.1 copy assignment +void +copyAssignmentCheck() +{ + typedef copy_tracker T; + typedef std::deque X; + + const X::size_type n(18); + const X::value_type t(1023); + X a(n, t); + X r; + + copy_tracker::reset(); + + r = a; + + VERIFY(r == a); + VERIFY(n == copy_constructor::count()); +} + + +// 23.2.1.1 fill assignment +// +// The complexity check must check dtors+copyAssign and +// copyCtor+copyAssign because that's the way the SGI implementation +// works. Dunno if it's true standard compliant (which specifies fill +// assignment in terms of erase and insert only), but it should work +// as (most) users expect and is more efficient. +void +fillAssignmentCheck() +{ + typedef copy_tracker T; + typedef std::deque X; + + const X::size_type starting_size(10); + const X::value_type starting_value(66); + const X::size_type n(23); + const X::value_type t(111); + + X a(starting_size, starting_value); + copy_tracker::reset(); + + // preconditions + VERIFY(starting_size == a.size()); + + // test + a.assign(n, t); + + // postconditions + VERIFY(n == a.size()); + VERIFY(n == (copy_constructor::count() + assignment_operator::count())); + VERIFY(starting_size == (destructor::count() + assignment_operator::count())); +} + + +// @verbatim +// 23.2.1 range assignment +// 23.2.1.1 deque constructors, copy, and assignment +// effects: +// Constructs a deque equal to the range [first, last), using the +// specified allocator. +// +// template +// assign(InputIterator first, InputIterator last); +// +// is equivalent to +// +// erase(begin(), end()); +// insert(begin(), first, last); +// +// postconditions: +// throws: +// complexity: +// forward iterators: N calls to the copy constructor, 0 reallocations +// input iterators: 2N calls to the copy constructor, log(N) reallocations +// @endverbatim +void +rangeAssignmentCheck() +{ + typedef copy_tracker T; + typedef std::deque X; + + const X::size_type source_size(726); + const X::value_type source_value(307); + const X::size_type starting_size(10); + const X::value_type starting_value(66); + + X source(source_size, source_value); + X::iterator i = source.begin(); + X::iterator j = source.end(); + X::size_type rangeSize = std::distance(i, j); + + X a(starting_size, starting_value); + VERIFY(starting_size == a.size()); + + copy_tracker::reset(); + + a.assign(i, j); + + VERIFY(source == a); + VERIFY(rangeSize == (copy_constructor::count() + assignment_operator::count())); + VERIFY(starting_size == (destructor::count() + assignment_operator::count())); +} + + +// 23.1 (10) range assignment +// 23.2.1.3 with exception +void +rangeAssignmentCheckWithException() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + // test + // What does "no effects" mean? +} + + +// 23.1.1 (9) fill assignment looking like a range assignment +void +fillAssignmentCheck2() +{ + // setup + typedef copy_tracker T; + typedef std::deque X; + + // test + // What does "no effects" mean? +} + +// Verify that the default deque constructor offers the basic exception +// guarantee. +void +test_default_ctor_exception_safety() +{ + // setup + typedef copy_tracker T; + typedef std::deque > X; + + T::reset(); + copy_constructor::throw_on(3); + tracker_allocator_counter::reset(); + + // test + try + { + T ref; + X a(7, ref); + VERIFY( false ); + } + catch (...) + { + } + + // assert postconditions + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown +} + +// Verify that the copy constructor offers the basic exception guarantee. +void +test_copy_ctor_exception_safety() +{ + // setup + typedef copy_tracker T; + typedef std::deque > X; + + tracker_allocator_counter::reset(); + { + X a(7); + T::reset(); + copy_constructor::throw_on(3); + + + // test + try + { + X u(a); + VERIFY(false); + } + catch (...) + { + } + } + + // assert postconditions + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown +} + +int main() +{ + // basic functionality and standard conformance checks + requiredTypesCheck(); + defaultConstructorCheckPOD(); + defaultConstructorCheck(); + test_default_ctor_exception_safety(); + copyConstructorCheck(); + test_copy_ctor_exception_safety(); + fillConstructorCheck(); + fillConstructorCheck2(); + rangeConstructorCheckInputIterator(); + rangeConstructorCheckForwardIterator(); + copyAssignmentCheck(); + fillAssignmentCheck(); + fillAssignmentCheck2(); + rangeAssignmentCheck(); + rangeAssignmentCheckWithException(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc new file mode 100644 index 000000000..31387777e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc @@ -0,0 +1,51 @@ +// 2005-12-12 Paolo Carlini +// +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.1 deque constructors, copy, and assignment + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + int data3[1000]; + fill(data3, data3 + 1000, 3); + + int data5[1000]; + fill(data5, data5 + 1000, 5); + + for (deque::size_type i = 0; i < 1000; ++i) + { + deque d(rand() % 500, 1); + d.assign(i, i % 2 ? 3 : 5); + + VERIFY( d.size() == i ); + VERIFY( equal(d.begin(), d.end(), i % 2 ? data3 : data5) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc new file mode 100644 index 000000000..d545f01a3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using namespace std; +using __gnu_cxx::new_allocator; + +template + class clear_alloc : public new_allocator + { + public: + + template + struct rebind + { typedef clear_alloc other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator() + { } + + template + clear_alloc(clear_alloc const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator::size_type n) + { + this->clear(); + new_allocator::deallocate(ptr, n); + } + }; + +template + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } + + +int main() +{ + Check_Container > >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc new file mode 100644 index 000000000..0207fd717 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<__gnu_test::NonCopyConstructible> d(1000); + VERIFY( std::distance(d.begin(), d.end()) == 1000 ); + for(auto it = d.begin(); it != d.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc new file mode 100644 index 000000000..57113f5fb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on deque (via swap). If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +int main() +{ + bool test __attribute__((unused)) = true; + + std::deque a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); + + std::deque c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == 1 ); + VERIFY( b.size() == 0 ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc new file mode 100644 index 000000000..2d5edb4c2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include +#include + +using namespace __gnu_test; +typedef std::deque test_type; + +// Empty constructor doesn't require a copy constructor +void +test01() +{ test_type d; } + +// Constructing from a range that returns rvalue references doesn't +// require a copy constructor. +void +test02(rvalstruct* begin, rvalstruct* end) +{ + test_type d(std::make_move_iterator(begin), std::make_move_iterator(end)); +} + +// Constructing from a input iterator range that returns rvalue +// references doesn't require a copy constructor either. +void +test03(input_iterator_wrapper begin, + input_iterator_wrapper end) +{ + test_type d(std::make_move_iterator(begin), std::make_move_iterator(end)); +} + +// Neither does destroying one. +void +test04(test_type* d) +{ delete d; } diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc new file mode 100644 index 000000000..9a4d7d439 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc new file mode 100644 index 000000000..32eda8794 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc new file mode 100644 index 000000000..3d2b15e94 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc new file mode 100644 index 000000000..7b6204158 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::deque >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc new file mode 100644 index 000000000..6268951d7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc new file mode 100644 index 000000000..3b8d77547 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc new file mode 100644 index 000000000..1187cf8b1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc new file mode 100644 index 000000000..7d7906d05 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::deque >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc new file mode 100644 index 000000000..38b4f554a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc new file mode 100644 index 000000000..5aa7efae6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc new file mode 100644 index 000000000..bd854ad87 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc new file mode 100644 index 000000000..ff88760ad --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::deque >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc new file mode 100644 index 000000000..6af6697ea --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc @@ -0,0 +1,52 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using __gnu_debug::deque; + +bool test = true; + +// Assignment +void test01() +{ + deque v1; + deque v2; + + deque::iterator i = v1.end(); + VERIFY(!i._M_dereferenceable() && !i._M_singular()); + + v1 = v2; + VERIFY(i._M_singular()); + + i = v1.end(); + v1.assign(v2.begin(), v2.end()); + VERIFY(i._M_singular()); + + i = v1.end(); + v1.assign(17, 42); + VERIFY(i._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc new file mode 100644 index 000000000..abbf47e93 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc @@ -0,0 +1,52 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using __gnu_debug::deque; + +bool test = true; + +// Resize +void test02() +{ + deque v(10, 17); + + deque::iterator before = v.begin() + 6; + deque::iterator at = before + 1; + deque::iterator after = at + 1; + + // Shrink + v.resize(7); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_singular()); + + // Grow + before = v.begin() + 6; + v.resize(17); + VERIFY(before._M_singular()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc new file mode 100644 index 000000000..c5a936a5b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc @@ -0,0 +1,62 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using __gnu_debug::deque; + +bool test = true; + +// Insert +void test03() +{ + deque v(10, 17); + + // Insert a single element + deque::iterator before = v.begin() + 6; + deque::iterator at = before + 1; + deque::iterator after = at; + at = v.insert(at, 42); + VERIFY(before._M_singular()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Insert multiple copies + before = v.begin() + 6; + at = before + 1; + + v.insert(at, 3, 42); + VERIFY(before._M_singular()); + VERIFY(at._M_singular()); + + // Insert iterator range + static int data[] = { 2, 3, 5, 7 }; + before = v.begin() + 6; + at = before + 1; + v.insert(at, &data[0], &data[0] + 4); + VERIFY(before._M_singular()); + VERIFY(at._M_singular()); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc new file mode 100644 index 000000000..342f5ead7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc @@ -0,0 +1,74 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using __gnu_debug::deque; + +bool test = true; + +// Erase +void test04() +{ + deque v(20, 42); + + // Single element erase (middle) + deque::iterator before = v.begin(); + deque::iterator at = before + 3; + deque::iterator after = at; + at = v.erase(at); + VERIFY(before._M_singular()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Single element erase (end) + before = v.begin(); + at = before; + after = at + 1; + at = v.erase(at); + VERIFY(before._M_singular()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before + 3; + v.erase(at, at + 3); + VERIFY(before._M_singular()); + VERIFY(at._M_singular()); + + // Multiple element erase at end + before = v.begin(); + at = before + 3; + v.erase(at, v.end()); + *before; + + // clear() + before = v.begin(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/init-list.cc b/libstdc++-v3/testsuite/23_containers/deque/init-list.cc new file mode 100644 index 000000000..8e25d3006 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/init-list.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +// { dg-options "-std=gnu++0x" } + +#include +#include + +using namespace __gnu_test; + +int main() +{ + typedef std::deque > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + Container c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + ok &= (c[0] == 2); + ok &= (c[1] == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin() + 7, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 3, 0) && ok; + ok &= (c[7] == 234); + } + ok = check_construct_destroy("Insert init-list", 3, 13) && ok; + + { + Container c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + ok &= (c[0] == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1;; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc new file mode 100644 index 000000000..2da37a9f0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc @@ -0,0 +1,135 @@ +// 2005-11-25 Paolo Carlini + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.3 deque modifiers + +#include +#include + +const int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +const int A1[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +const int A2[] = {0, 2, 3, 4, 10, 11, 12, 13, 14, 15}; +const int A3[] = {0, 2, 3, 4, 10, 11}; +const int A4[] = {4, 10, 11}; +const int A5[] = {4, 10}; +const unsigned N = sizeof(A) / sizeof(int); +const unsigned N1 = sizeof(A1) / sizeof(int); +const unsigned N2 = sizeof(A2) / sizeof(int); +const unsigned N3 = sizeof(A3) / sizeof(int); +const unsigned N4 = sizeof(A4) / sizeof(int); +const unsigned N5 = sizeof(A5) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::deque deque_type; + typedef deque_type::iterator iterator_type; + + deque_type v(A, A + N); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::deque > deque_type; + typedef deque_type::iterator iterator_type; + + deque_type v, v1, v2, v3, v4, v5; + for (unsigned i = 0; i < N; ++i) + v.push_back(std::deque(1, A[i])); + for (unsigned i = 0; i < N1; ++i) + v1.push_back(std::deque(1, A1[i])); + for (unsigned i = 0; i < N2; ++i) + v2.push_back(std::deque(1, A2[i])); + for (unsigned i = 0; i < N3; ++i) + v3.push_back(std::deque(1, A3[i])); + for (unsigned i = 0; i < N4; ++i) + v4.push_back(std::deque(1, A4[i])); + for (unsigned i = 0; i < N5; ++i) + v5.push_back(std::deque(1, A5[i])); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), v1.begin()) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), v2.begin()) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), v3.begin()) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), v4.begin()) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), v5.begin()) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc new file mode 100644 index 000000000..2d592d7b4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc @@ -0,0 +1,114 @@ +// 2005-11-25 Paolo Carlini + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.3 deque modifiers + +#include +#include + +const int A[] = {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15}; +const int A0[] = {-5, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +const int A1[] = {-5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +const int A2[] = {-5, 0, 1, 2, 8, 9, 10, 11, 12, 13, 14, 15}; +const int A3[] = {-5, 0, 1, 2, 8, 9, 10, 11}; +const int A4[] = {2, 8, 9, 10, 11}; +const int A5[] = {2, 8, 10, 11}; +const int A6[] = {2, 8, 10}; +const unsigned N = sizeof(A) / sizeof(int); +const unsigned N0 = sizeof(A0) / sizeof(int); +const unsigned N1 = sizeof(A1) / sizeof(int); +const unsigned N2 = sizeof(A2) / sizeof(int); +const unsigned N3 = sizeof(A3) / sizeof(int); +const unsigned N4 = sizeof(A4) / sizeof(int); +const unsigned N5 = sizeof(A5) / sizeof(int); +const unsigned N6 = sizeof(A6) / sizeof(int); + +template + class My_class + { + double dummy[Size]; + int data; + + public: + My_class(int num) + : data(num) { } + + operator int() const + { return data; } + }; + +template + void + test01() + { + bool test __attribute__((unused)) = true; + + typedef std::deque deque_type; + typedef typename deque_type::iterator iterator_type; + + deque_type v(A, A + N); + + iterator_type it0 = v.erase(v.begin() + 1, v.begin() + 4); + VERIFY( it0 == v.begin() + 1 ); + VERIFY( v.size() == N0 ); + VERIFY( std::equal(v.begin(), v.end(), A0) ); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 8, v.end()); + VERIFY( it3 == v.begin() + 8 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin() + 3, v.end()); + VERIFY( it6 == v.begin() + 3 ); + VERIFY( v.size() == N6 ); + VERIFY( std::equal(v.begin(), v.end(), A6) ); + + iterator_type it7 = v.erase(v.begin(), v.end()); + VERIFY( it7 == v.begin() ); + VERIFY( v.empty() ); + } + +int main() +{ + test01 >(); + test01 >(); + test01 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc new file mode 100644 index 000000000..79a046ed7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.3 deque modifiers + +#include +#include + +void erase(size_t num_elm, size_t elm_strt, size_t elm_end) +{ + bool test __attribute__((unused)) = true; + using __gnu_test::copy_tracker; + using __gnu_test::assignment_operator; + + std::deque x(num_elm); + copy_tracker::reset(); + + x.erase(x.begin() + elm_strt, x.begin() + elm_end); + + const size_t min_num_cpy + = elm_strt == elm_end ? 0 : std::min(elm_strt, num_elm - elm_end); + + VERIFY( assignment_operator::count() == min_num_cpy ); +} + +// http://gcc.gnu.org/ml/libstdc++/2007-01/msg00098.html +void test01() +{ + for (size_t num_elm = 0; num_elm <= 10; ++num_elm) + for (size_t elm_strt = 0; elm_strt <= num_elm; ++elm_strt) + for (size_t elm_end = elm_strt; elm_end <= num_elm; ++elm_end) + erase(num_elm, elm_strt, elm_end); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc new file mode 100644 index 000000000..f534758a9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-09-26 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/50529 +void test01() +{ + std::deque<__gnu_test::rvalstruct> d(10); + + for (auto it = d.begin(); it != d.end(); ++it) + d.erase(it, it); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc new file mode 100644 index 000000000..e631000f6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-28 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::deque a(40); + copycounter::copycount = 0; + + a.erase(a.begin() + 20); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.begin()); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.end() - 1); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.begin() + 10, a.end() - 10); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.begin(), a.begin() + 5); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.end() - 5, a.end()); + VERIFY( copycounter::copycount == 0 ); + + a.erase(a.begin(), a.end()); + VERIFY( copycounter::copycount == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc new file mode 100644 index 000000000..6519600fb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +using namespace __gnu_test; + +// Test deque::push_back makes no unneeded copies. +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::deque a; + copycounter c(1); + copycounter::copycount = 0; + for(int i = 0; i < 1000; ++i) + a.push_back(c); + VERIFY(copycounter::copycount == 1000); +} + +// Test deque::push_front makes no unneeded copies. +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::deque a; + copycounter c(1); + copycounter::copycount = 0; + for(int i = 0; i < 1000; ++i) + a.push_front(c); + VERIFY(copycounter::copycount == 1000); +} + +// Test deque::insert makes no unneeded copies. +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::deque a(1000); + copycounter c(1); + copycounter::copycount = 0; + a.insert(a.begin(),c); + a.insert(a.end(),c); + for(int i = 0; i < 500; ++i) + a.insert(a.begin() + i, c); + VERIFY(copycounter::copycount == 502); +} + +// Test deque::insert(iterator, count, value) makes no unneeded copies +// when it has to also reallocate the deque's internal buffer. +void +test04() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::deque a(10, c); + copycounter::copycount = 0; + a.insert(a.begin(), 20, c); + VERIFY(copycounter::copycount == 20); + a.insert(a.end(), 50, c); + VERIFY(copycounter::copycount == 70); + // NOTE : These values are each one higher than might be expected, as + // deque::insert(iterator, count, value) copies the value it is given + // when it has to move elements in the deque in case that value is + // in the deque. + + // Near the start + a.insert(a.begin() + 10, 100, c); + VERIFY(copycounter::copycount == 170 + 1); + // Near the end + a.insert(a.end() - 10, 1000, c); + VERIFY(copycounter::copycount == 1170 + 2); +} + +// Test deque::insert(iterator, count, value) makes no unneeded copies +// when it doesn't have to reallocate the deque's internal buffer. +void +test05() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::deque a(10, c); + copycounter::copycount = 0; + //a.reserve(1000); + a.insert(a.begin(), 20, c); + VERIFY(copycounter::copycount == 20 ); + a.insert(a.end(), 50, c); + VERIFY(copycounter::copycount == 70 ); + + // NOTE : These values are each one higher than might be expected, as + // deque::insert(iterator, count, value) copies the value it is given + // when it has to move elements in the deque in case that value is + // in the deque. + // Near the start + a.insert(a.begin() + 10, 100, c); + VERIFY(copycounter::copycount == 170 + 1); + // Near the end + a.insert(a.end() - 10, 200, c); + VERIFY(copycounter::copycount == 370 + 2); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc new file mode 100644 index 000000000..3b176c869 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct T { int i; }; + +int swap_calls; + +namespace std +{ + template<> + void + deque >::swap(deque >&) + { ++swap_calls; } +} + +// Should use deque specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::deque A; + std::deque B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use deque specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + deque A; + deque B; + swap_calls = 0; + swap(A, B); + VERIFY(1 == swap_calls); +} + +// See c++/13658 for background info. +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc new file mode 100644 index 000000000..5721e2a53 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc @@ -0,0 +1,132 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.3 deque::swap + +#include +#include +#include + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator my_alloc; + typedef deque my_deque; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + my_deque::size_type size01, size02; + + my_alloc alloc01(1); + + my_deque deq01(alloc01); + size01 = deq01.size(); + my_deque deq02(alloc01); + size02 = deq02.size(); + + deq01.swap(deq02); + VERIFY( deq01.size() == size02 ); + VERIFY( deq01.empty() ); + VERIFY( deq02.size() == size01 ); + VERIFY( deq02.empty() ); + + my_deque deq03(alloc01); + size01 = deq03.size(); + my_deque deq04(title02, title02 + N2, alloc01); + size02 = deq04.size(); + + deq03.swap(deq04); + VERIFY( deq03.size() == size02 ); + VERIFY( equal(deq03.begin(), deq03.end(), title02) ); + VERIFY( deq04.size() == size01 ); + VERIFY( deq04.empty() ); + + my_deque deq05(title01, title01 + N1, alloc01); + size01 = deq05.size(); + my_deque deq06(title02, title02 + N2, alloc01); + size02 = deq06.size(); + + deq05.swap(deq06); + VERIFY( deq05.size() == size02 ); + VERIFY( equal(deq05.begin(), deq05.end(), title02) ); + VERIFY( deq06.size() == size01 ); + VERIFY( equal(deq06.begin(), deq06.end(), title01) ); + + my_deque deq07(title01, title01 + N1, alloc01); + size01 = deq07.size(); + my_deque deq08(title03, title03 + N3, alloc01); + size02 = deq08.size(); + + deq07.swap(deq08); + VERIFY( deq07.size() == size02 ); + VERIFY( equal(deq07.begin(), deq07.end(), title03) ); + VERIFY( deq08.size() == size01 ); + VERIFY( equal(deq08.begin(), deq08.end(), title01) ); + + my_deque deq09(title03, title03 + N3, alloc01); + size01 = deq09.size(); + my_deque deq10(title04, title04 + N4, alloc01); + size02 = deq10.size(); + + deq09.swap(deq10); + VERIFY( deq09.size() == size02 ); + VERIFY( equal(deq09.begin(), deq09.end(), title04) ); + VERIFY( deq10.size() == size01 ); + VERIFY( equal(deq10.begin(), deq10.end(), title03) ); + + my_deque deq11(title04, title04 + N4, alloc01); + size01 = deq11.size(); + my_deque deq12(title01, title01 + N1, alloc01); + size02 = deq12.size(); + + deq11.swap(deq12); + VERIFY( deq11.size() == size02 ); + VERIFY( equal(deq11.begin(), deq11.end(), title01) ); + VERIFY( deq12.size() == size01 ); + VERIFY( equal(deq12.begin(), deq12.end(), title04) ); + + my_deque deq13(title03, title03 + N3, alloc01); + size01 = deq13.size(); + my_deque deq14(title03, title03 + N3, alloc01); + size02 = deq14.size(); + + deq13.swap(deq14); + VERIFY( deq13.size() == size02 ); + VERIFY( equal(deq13.begin(), deq13.end(), title03) ); + VERIFY( deq14.size() == size01 ); + VERIFY( equal(deq14.begin(), deq14.end(), title03) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc new file mode 100644 index 000000000..e4e1cba7e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc @@ -0,0 +1,161 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1.3 deque::swap + +#include +#include +#include + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator my_alloc; + typedef deque my_deque; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + my_deque::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_deque deq01(alloc01); + size01 = deq01.size(); + personality01 = deq01.get_allocator().get_personality(); + my_deque deq02(alloc02); + size02 = deq02.size(); + personality02 = deq02.get_allocator().get_personality(); + + deq01.swap(deq02); + VERIFY( deq01.size() == size02 ); + VERIFY( deq01.empty() ); + VERIFY( deq02.size() == size01 ); + VERIFY( deq02.empty() ); + VERIFY( deq01.get_allocator().get_personality() == personality02 ); + VERIFY( deq02.get_allocator().get_personality() == personality01 ); + + my_deque deq03(alloc02); + size01 = deq03.size(); + personality01 = deq03.get_allocator().get_personality(); + my_deque deq04(title02, title02 + N2, alloc01); + size02 = deq04.size(); + personality02 = deq04.get_allocator().get_personality(); + + deq03.swap(deq04); + VERIFY( deq03.size() == size02 ); + VERIFY( equal(deq03.begin(), deq03.end(), title02) ); + VERIFY( deq04.size() == size01 ); + VERIFY( deq04.empty() ); + VERIFY( deq03.get_allocator().get_personality() == personality02 ); + VERIFY( deq04.get_allocator().get_personality() == personality01 ); + + my_deque deq05(title01, title01 + N1, alloc01); + size01 = deq05.size(); + personality01 = deq05.get_allocator().get_personality(); + my_deque deq06(title02, title02 + N2, alloc02); + size02 = deq06.size(); + personality02 = deq06.get_allocator().get_personality(); + + deq05.swap(deq06); + VERIFY( deq05.size() == size02 ); + VERIFY( equal(deq05.begin(), deq05.end(), title02) ); + VERIFY( deq06.size() == size01 ); + VERIFY( equal(deq06.begin(), deq06.end(), title01) ); + VERIFY( deq05.get_allocator().get_personality() == personality02 ); + VERIFY( deq06.get_allocator().get_personality() == personality01 ); + + my_deque deq07(title01, title01 + N1, alloc02); + size01 = deq07.size(); + personality01 = deq07.get_allocator().get_personality(); + my_deque deq08(title03, title03 + N3, alloc01); + size02 = deq08.size(); + personality02 = deq08.get_allocator().get_personality(); + + deq07.swap(deq08); + VERIFY( deq07.size() == size02 ); + VERIFY( equal(deq07.begin(), deq07.end(), title03) ); + VERIFY( deq08.size() == size01 ); + VERIFY( equal(deq08.begin(), deq08.end(), title01) ); + VERIFY( deq07.get_allocator().get_personality() == personality02 ); + VERIFY( deq08.get_allocator().get_personality() == personality01 ); + + my_deque deq09(title03, title03 + N3, alloc01); + size01 = deq09.size(); + personality01 = deq09.get_allocator().get_personality(); + my_deque deq10(title04, title04 + N4, alloc02); + size02 = deq10.size(); + personality02 = deq10.get_allocator().get_personality(); + + deq09.swap(deq10); + VERIFY( deq09.size() == size02 ); + VERIFY( equal(deq09.begin(), deq09.end(), title04) ); + VERIFY( deq10.size() == size01 ); + VERIFY( equal(deq10.begin(), deq10.end(), title03) ); + VERIFY( deq09.get_allocator().get_personality() == personality02 ); + VERIFY( deq10.get_allocator().get_personality() == personality01 ); + + my_deque deq11(title04, title04 + N4, alloc02); + size01 = deq11.size(); + personality01 = deq11.get_allocator().get_personality(); + my_deque deq12(title01, title01 + N1, alloc01); + size02 = deq12.size(); + personality02 = deq12.get_allocator().get_personality(); + + deq11.swap(deq12); + VERIFY( deq11.size() == size02 ); + VERIFY( equal(deq11.begin(), deq11.end(), title01) ); + VERIFY( deq12.size() == size01 ); + VERIFY( equal(deq12.begin(), deq12.end(), title04) ); + VERIFY( deq11.get_allocator().get_personality() == personality02 ); + VERIFY( deq12.get_allocator().get_personality() == personality01 ); + + my_deque deq13(title03, title03 + N3, alloc01); + size01 = deq13.size(); + personality01 = deq13.get_allocator().get_personality(); + my_deque deq14(title03, title03 + N3, alloc02); + size02 = deq14.size(); + personality02 = deq14.get_allocator().get_personality(); + + deq13.swap(deq14); + VERIFY( deq13.size() == size02 ); + VERIFY( equal(deq13.begin(), deq13.end(), title03) ); + VERIFY( deq14.size() == size01 ); + VERIFY( equal(deq14.begin(), deq14.end(), title03) ); + VERIFY( deq13.get_allocator().get_personality() == personality02 ); + VERIFY( deq14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc b/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc new file mode 100644 index 000000000..5db862186 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc @@ -0,0 +1,62 @@ +// 2002-05-18 Paolo Carlini + +// Copyright (C) 2002, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1 deque operators + +#include +#include + +// libstdc++/6503 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque d(2); + typedef std::deque::iterator iter; + typedef std::deque::const_iterator constiter; + + iter beg = d.begin(); + iter end = d.end(); + constiter constbeg = d.begin(); + constiter constend = d.end(); + + VERIFY( beg == constbeg ); + VERIFY( constend == end ); + + VERIFY( beg != constend ); + VERIFY( constbeg != end ); + + VERIFY( beg < constend ); + VERIFY( constbeg < end ); + + VERIFY( end > constbeg ); + VERIFY( constend > beg ); + + VERIFY( end >= constend ); + VERIFY( constbeg >= beg ); + + VERIFY( beg <= constbeg ); + VERIFY( constend <= end ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc b/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc new file mode 100644 index 000000000..4db5e0ee2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc @@ -0,0 +1,50 @@ +// 2002-05-18 Paolo Carlini + +// Copyright (C) 2002, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 23.2.1 deque operators + +#include +#include + +// libstdc++/7186 +void test02() +{ + bool test __attribute__((unused)) = true; + + std::deque d(2); + typedef std::deque::iterator iter; + typedef std::deque::const_iterator constiter; + + iter beg = d.begin(); + iter end = d.end(); + constiter constbeg = d.begin(); + constiter constend = d.end(); + + VERIFY( beg - constbeg == 0 ); + VERIFY( constend - end == 0 ); + + VERIFY( end - constbeg > 0 ); + VERIFY( constend - beg > 0 ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/range_access.cc b/libstdc++-v3/testsuite/23_containers/deque/range_access.cc new file mode 100644 index 000000000..7c7588954 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 24.6.5, range access [iterator.range] + +#include + +void +test01() +{ + std::deque d{1, 2, 3}; + std::begin(d); + std::end(d); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc new file mode 100644 index 000000000..4a05e6060 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + typedef std::deque test_type; + __gnu_test::citerator test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..ecd115e3a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -0,0 +1,35 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1661 } +// { dg-excess-errors "" } + +#include + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::deque d; + d.assign(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc new file mode 100644 index 000000000..e7a4a2be8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } + +#include + +void f() +{ + std::deque v(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..4de01c826 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,29 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1594 } +// { dg-excess-errors "" } + +#include + +void f() +{ + std::deque > d(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..78eeb8dbc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,30 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1594 } +// { dg-excess-errors "" } + +#include +#include + +void f() +{ + std::deque > > d('a', 'b'); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..f29152cb7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -0,0 +1,36 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1745 } +// { dg-excess-errors "" } + +#include + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::deque d; + d.insert(d.begin(), 10, 1); +} + diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc new file mode 100644 index 000000000..25629c156 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::deque test_type; + __gnu_test::basic_safety test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..aa3a8ba87 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random allocator_type; + typedef std::deque test_type; + __gnu_test::generation_prohibited test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..14892344e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-do run { xfail *-*-* } } + +// 2009-09-09 Benjamin Kosnik + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::deque test_type; + __gnu_test::propagation_consistent test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..c672777ba --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers + +#include + +// { dg-do compile } + +template class std::deque; diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..219970082 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// This file tests explicit instantiation of library containers + +#include + +template class std::deque; diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..82efd2605 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers + +#include +#include + +// { dg-do compile } + +// N.B. In C++0x mode we cannot instantiate with T == NonDefaultConstructible +// because of 23.3.2.1.4 +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +template class std::deque<__gnu_test::NonDefaultConstructible>; +#endif diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..8307e21d6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers + +#include + +// { dg-do compile } + +// libstdc++/21770 +template class std::deque >; diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..4685ae142 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc @@ -0,0 +1,30 @@ +// 2010-05-20 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers + +#include +#include +#include + +// { dg-do compile } + +// libstdc++/41792 +template class std::deque<__gnu_test::OverloadedAddress>; diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..bc0c9823c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc @@ -0,0 +1,33 @@ +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// This file tests user specialization of library containers + +#include +#include + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template + class deque {}; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc new file mode 100644 index 000000000..6263951fe --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// Check container for required typedefs. +__gnu_test::types > t; diff --git a/libstdc++-v3/testsuite/23_containers/deque/types/1.cc b/libstdc++-v3/testsuite/23_containers/deque/types/1.cc new file mode 100644 index 000000000..eed7f8735 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/types/1.cc @@ -0,0 +1,52 @@ +// 2005-12-18 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } + +#include +#include + +int main() +{ + std::deque d(5); + const std::deque e(1); + + d[0]; + e[0]; + d.size(); + d.erase(d.begin()); + d.resize(1); + d.assign(1, greedy_ops::X()); + d.insert(d.begin(), greedy_ops::X()); + d.insert(d.begin(), 1, greedy_ops::X()); + d.insert(d.begin(), e.begin(), e.end()); + d = e; + + std::deque::iterator it; + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + it + 1; + + return 0; +} -- cgit v1.2.3