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. --- .../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 ++++++++++ 5 files changed, 402 insertions(+) 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 (limited to 'libstdc++-v3/testsuite/23_containers/deque/modifiers/erase') 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; +} -- cgit v1.2.3