diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/testsuite/23_containers | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/23_containers')
1063 files changed, 54312 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/constexpr_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/constexpr_functions.cc new file mode 100644 index 000000000..0e6e06d97 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/constexpr_functions.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr _Ttesttype a = { }; + constexpr auto v1 __attribute__((unused)) = a.size(); + constexpr auto v2 __attribute__((unused)) = a.max_size(); + constexpr auto v3 __attribute__((unused)) = a.empty(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()<std::array<long, 60>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/empty.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/empty.cc new file mode 100644 index 000000000..9f610f184 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/empty.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.empty() == false ); + } + + { + bool test __attribute__((unused)) = true; + + const size_t len = 0; + typedef std::array<int, len> array_type; + array_type a; + + VERIFY( a.empty() == true ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/max_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/max_size.cc new file mode 100644 index 000000000..87f8d5376 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/max_size.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.max_size() == len ); + } + + { + bool test __attribute__((unused)) = true; + + const size_t len = 0; + typedef std::array<int, len> array_type; + array_type a; + + VERIFY( a.max_size() == len ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/size.cc new file mode 100644 index 000000000..e7b16c863 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/capacity/size.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.size() == len ); + } + + { + bool test __attribute__((unused)) = true; + + const size_t len = 0; + typedef std::array<int, len> array_type; + array_type a; + + VERIFY( a.size() == len ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/equal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/equal.cc new file mode 100644 index 000000000..31e9989c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/equal.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3 } }; + + VERIFY( a == b ); + VERIFY( !(a == c) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater.cc new file mode 100644 index 000000000..ea40fde30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( !(a > b) ); + VERIFY( c > a ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater_or_equal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater_or_equal.cc new file mode 100644 index 000000000..af1a120a9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/greater_or_equal.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( a >= b ); + VERIFY( c >= a ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less.cc new file mode 100644 index 000000000..599ef141b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( !(a < b) ); + VERIFY( a < c ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less_or_equal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less_or_equal.cc new file mode 100644 index 000000000..6741f8d63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/less_or_equal.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( a <= b ); + VERIFY( a <= c ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/not_equal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/not_equal.cc new file mode 100644 index 000000000..7018989e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/comparison_operators/not_equal.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3 } }; + + VERIFY( !(a != b) ); + VERIFY( a != c ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/53361.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/53361.cc new file mode 100644 index 000000000..a11cadf4e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/53361.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++11 -Wno-missing-braces" } +// { dg-do compile } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +void function(std::array<unsigned int, 3>); + +int main() +{ + function({0,0,0}); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/aggregate_initialization.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/aggregate_initialization.cc new file mode 100644 index 000000000..606fdae65 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/cons/aggregate_initialization.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +void +test01() +{ + typedef std::array<int, 5> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3 } }; + + a = b; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc new file mode 100644 index 000000000..c9f756e38 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + std::array<int, 0> a; + a.back(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc new file mode 100644 index 000000000..7cd5b362e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + constexpr std::array<int, 0> a; + a.back(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc new file mode 100644 index 000000000..100689f10 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + std::array<int, 0> a; + a.front(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc new file mode 100644 index 000000000..8d066b393 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + constexpr std::array<int, 0> a; + a.front(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc new file mode 100644 index 000000000..23e115737 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + std::array<int, 0> a; + a[0]; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc new file mode 100644 index 000000000..5a86b2006 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <array> + +void test01() +{ + constexpr std::array<int, 0> a; + a[0]; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc new file mode 100644 index 000000000..7679537b5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +struct A +{ + bool valid = true; + ~A() { valid = false; } +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::array<A, 1> a; + const A& aa = a.at(0); + VERIFY(aa.valid); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_neg.cc new file mode 100644 index 000000000..b3a01c205 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_neg.cc @@ -0,0 +1,31 @@ +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +int main() +{ + // Expected behavior is to either throw and have the uncaught + // exception end up in a terminate handler which eventually exits, + // or abort. (Depending on -fno-exceptions.) + constexpr std::array<int, 3> a{{1, 2, 3}}; + auto i __attribute__((unused)) = a.at(4); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_out_of_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_out_of_range.cc new file mode 100644 index 000000000..8fec64fe7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/at_out_of_range.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + try + { + a.at(len); + VERIFY( false ); + } + catch(std::out_of_range& obj) + { + // Expected. + VERIFY( true ); + } + catch(...) + { + // Failed. + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/back.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/back.cc new file mode 100644 index 000000000..9072cd6a2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/back.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int& ri = a.back(); + VERIFY( ri == 4 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int& cri = ca.back(); + VERIFY( cri == 0 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_element_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_element_access.cc new file mode 100644 index 000000000..9687cbf71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_element_access.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +int main() +{ + // array + typedef std::array<std::size_t, 6> array_type; + constexpr array_type a = { { 0, 55, 66, 99, 4115, 2 } }; + constexpr auto v1 __attribute__((unused)) = a[1]; + constexpr auto v2 __attribute__((unused)) = a.at(2); + constexpr auto v3 __attribute__((unused)) = a.front(); + constexpr auto v4 __attribute__((unused)) = a.back(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/data.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/data.cc new file mode 100644 index 000000000..830fdfe2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/data.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int* pi = a.data(); + VERIFY( *pi == 0 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int* pci = ca.data(); + VERIFY( *pci == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/front.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/front.cc new file mode 100644 index 000000000..a608f0b91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/element_access/front.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int& ri = a.front(); + VERIFY( ri == 0 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int& cri = ca.front(); + VERIFY( cri == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/iterators/end_is_one_past.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/iterators/end_is_one_past.cc new file mode 100644 index 000000000..178711ded --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/iterators/end_is_one_past.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + array_type::iterator b = a.begin(); + array_type::iterator e = a.end(); + + VERIFY( e != (b + a.size() - 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/range_access.cc new file mode 100644 index 000000000..d21daeb13 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <array> + +void +test01() +{ + std::array<int, 3> a{{1, 2, 3}}; + std::begin(a); + std::end(a); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/citerators.cc new file mode 100644 index 000000000..4ad7599a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_containers.h> + +int main() +{ + typedef std::array<int, 7> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/contiguous.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/contiguous.cc new file mode 100644 index 000000000..e76dd54f8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/contiguous.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + array_type a = { { 0, 1, 2, 3, 4 } }; + + // &a[n] == &a[0] + n for all 0 <= n < N. + for (size_t i = 0; i < len; ++i) + { + VERIFY( &a[i] == &a[0] + i ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..247c5ba89 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +template class std::array<int, 5>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..186938142 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/2.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <array> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +template class std::array<__gnu_test::NonDefaultConstructible, 3>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..3e4f213c9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/explicit_instantiation/3.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <array> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// libstdc++/41792 +template class std::array<__gnu_test::OverloadedAddress, 3>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc new file mode 100644 index 000000000..1d5425b4f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-13 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +// DR 776. Undescribed assign function of std::array. +void test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 3; + typedef std::array<int, len> array_type; + + array_type a = { { 0, 1, 2 } }; + const int value = 5; + + a.fill(value); + VERIFY( a[0] == value ); + VERIFY( a[1] == value ); + VERIFY( a[2] == value ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/member_swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/member_swap.cc new file mode 100644 index 000000000..43b0bdb7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/member_swap.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + const array_type a_ref = a; + + array_type b = { { 4, 3, 2, 1, 0 } }; + const array_type b_ref = b; + + a.swap(b); + VERIFY( a == b_ref ); + VERIFY( b == a_ref ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/non_default_constructible.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/non_default_constructible.cc new file mode 100644 index 000000000..89f9e1abf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/non_default_constructible.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <typeindex> +#include <typeinfo> + +template < typename ...Types > +union super_union; + +template < > +union super_union<> +{ + static auto optioned_types() -> std::array<std::type_index, 0> + { return std::array<std::type_index, 0>{ {} }; } +}; + +template < typename Head, typename ...Tail > +union super_union<Head, Tail...> +{ + static + auto optioned_types() -> std::array<std::type_index, 1 + sizeof...(Tail)> + { + using std::type_index; + + return { {type_index(typeid(Head)), type_index(typeid(Tail))...} }; + } + + Head data; + super_union<Tail...> rest; +}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/typedefs.cc new file mode 100644 index 000000000..e346f5941 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <array> + +// Check container for required typedefs. +__gnu_test::types<std::array<int, 10> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/zero_sized_arrays.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/zero_sized_arrays.cc new file mode 100644 index 000000000..2caab8828 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/requirements/zero_sized_arrays.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 0; + typedef std::array<int, len> array_type; + + // 1: ? + array_type a = { }; + + // 2 + array_type b; + + // 3 + // begin() == end() + VERIFY( a.begin() == a.end() ); + VERIFY( b.begin() == b.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/specialized_algorithms/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/specialized_algorithms/swap.cc new file mode 100644 index 000000000..77cfecbaf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/specialized_algorithms/swap.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::array<int, len> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + const array_type a_ref = a; + + array_type b = { { 4, 3, 2, 1, 0 } }; + const array_type b_ref = b; + + std::swap(a, b); + VERIFY( a == b_ref ); + VERIFY( b == a_ref ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/constexpr_get.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/constexpr_get.cc new file mode 100644 index 000000000..a21937428 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/constexpr_get.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <array> + +std::array<int, 5> ai; +const std::array<int, 5> cai(ai); + +constexpr const int& cri = std::get<0>(cai); +constexpr int& ri = std::get<0>(ai); +constexpr int&& rri = std::get<0>(std::move(ai)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get.cc new file mode 100644 index 000000000..0a5bd79c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +void test01() +{ + std::array<int, 2> a; + + int&& aone __attribute__((unused)) = std::get<0>(std::move(a)); + int&& atwo __attribute__((unused)) = std::get<1>(std::move(a)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc new file mode 100644 index 000000000..1e39da327 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +std::array<int, 1> a{}; +const std::array<int, 1> ca{}; + +int n1 = std::get<1>(a); +int n2 = std::get<1>(std::move(a)); +int n3 = std::get<1>(ca); + +// { dg-error "static assertion failed" "" { target *-*-* } 271 } +// { dg-error "static assertion failed" "" { target *-*-* } 280 } +// { dg-error "static assertion failed" "" { target *-*-* } 288 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc new file mode 100644 index 000000000..979d7f6b5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-normal-mode "" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +std::array<int, 1> a{}; +const std::array<int, 1> ca{}; + +int n1 = std::get<1>(a); +int n2 = std::get<1>(std::move(a)); +int n3 = std::get<1>(ca); + +// { dg-error "static assertion failed" "" { target *-*-* } 274 } +// { dg-error "static assertion failed" "" { target *-*-* } 283 } +// { dg-error "static assertion failed" "" { target *-*-* } 291 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element.cc new file mode 100644 index 000000000..ae677d2b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <type_traits> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const size_t len = 3; + typedef array<int, len> array_type; + VERIFY( (is_same<tuple_element<0, array_type>::type, int>::value == true) ); + VERIFY( (is_same<tuple_element<1, array_type>::type, int>::value == true) ); + VERIFY( (is_same<tuple_element<2, array_type>::type, int>::value == true) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc new file mode 100644 index 000000000..5ce9724e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +typedef std::tuple_element<1, std::array<int, 1>>::type type; + +// { dg-error "static assertion failed" "" { target *-*-* } 305 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc new file mode 100644 index 000000000..f80798c91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-normal-mode "" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +typedef std::tuple_element<1, std::array<int, 1>>::type type; + +// { dg-error "static assertion failed" "" { target *-*-* } 320 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_size.cc new file mode 100644 index 000000000..1cef443d9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_size.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + { + const size_t len = 5; + typedef array<int, len> array_type; + VERIFY( tuple_size<array_type>::value == 5 ); + } + + { + const size_t len = 0; + typedef array<float, len> array_type; + VERIFY( tuple_size<array_type>::value == 0 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/18604.cc new file mode 100644 index 000000000..640d864ff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/18604.cc @@ -0,0 +1,41 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <bitset> diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/45713.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/45713.cc new file mode 100644 index 000000000..3cab17e31 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/45713.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// The testcase requires bitsizetype to be wider than sizetype, +// otherwise types/vars with (e.g. for 32-bit sizetype) 0x20000000 +// bytes or larger can't be used. See http://gcc.gnu.org/PR54897 +// { dg-do compile { target { ! { avr*-*-* cris*-*-* h8300*-*-* hppa*64*-*-* mcore*-*-* moxie*-*-* mmix-*-* } } } } + +#include <bitset> + +// libstdc++/45713 +int test[sizeof(std::bitset<__SIZE_MAX__>) != 1 ? 1 : -1]; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc new file mode 100644 index 000000000..d627a9639 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc @@ -0,0 +1,80 @@ +// 2007-11-23 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <testsuite_hooks.h> + +// DR 693. std::bitset::all() missing. +void test01() +{ + bool test __attribute__((unused)) = true; + + std::bitset<0> z1; + VERIFY( z1.all() ); + z1.set(); + VERIFY( z1.all() ); + + std::bitset<8> z2; + VERIFY( !z2.all() ); + z2.set(); + VERIFY( z2.all() ); + + std::bitset<16> z3; + VERIFY( !z3.all() ); + z3.set(); + VERIFY( z3.all() ); + + std::bitset<32> z4; + VERIFY( !z4.all() ); + z4.set(); + VERIFY( z4.all() ); + + std::bitset<64> z5; + VERIFY( !z5.all() ); + z5.set(); + VERIFY( z5.all() ); + + std::bitset<96> z6; + VERIFY( !z6.all() ); + z6.set(); + VERIFY( z6.all() ); + + std::bitset<128> z7; + VERIFY( !z7.all() ); + z7.set(); + VERIFY( z7.all() ); + + std::bitset<192> z8; + VERIFY( !z8.all() ); + z8.set(); + VERIFY( z8.all() ); + + std::bitset<1024> z9; + VERIFY( !z9.all() ); + z9.set(); + VERIFY( z9.all() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc new file mode 100644 index 000000000..ca325e251 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc @@ -0,0 +1,83 @@ +// 1999-06-08 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.1 bitset constructors + +#include <string> +#include <bitset> +#include <algorithm> // std::reverse +#include <stdexcept> +#include <testsuite_hooks.h> + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + + // bitset() + const size_t n1 = 5; + std::bitset<n1> bit01; + for (size_t i = 0; i < n1; ++i) + VERIFY( !bit01.test(i) ); + + // bitset(unsigned long) + const size_t n2 = 32; + unsigned long ul1 = 2; + std::bitset<n2> bit02(ul1); + VERIFY( !bit02.test(0) ); + VERIFY( bit02.test(1) ); + VERIFY( !bit02.test(2) ); + + // template<_CharT, _Traits, _Alloc> + // explicit bitset(const basic_string<_C,_T,_A>&, size_type pos, size_type n) + std::string str01("stuff smith sessions"); + const size_t n3 = 128; + try { + std::bitset<n3> bit03(str01, 5); + } + catch(std::invalid_argument& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + std::string str02("010101000011"); + int sz = str02.size(); + try { + std::bitset<n3> bit03(str02, 0); + std::string str03; + for (int i = 0; i < sz; ++i) + str03 += (bit03.test(i) ? '1' : '0'); + std::reverse(str03.begin(), str03.end()); + VERIFY( str03 == str02 ); + } + catch(std::invalid_argument& fail) { + VERIFY( false ); + } + catch(...) { + VERIFY( false ); + } + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc new file mode 100644 index 000000000..64b13293f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/bitset> +#include <testsuite_hooks.h> + +// libstdc++/16020 +void test01() +{ + using __gnu_debug::bitset; + bool test __attribute__((unused)) = true; + + bitset<5> b(7); + bitset<5> c; + + bitset<5> bb(b); + c = bb; + + VERIFY( bb == b ); + VERIFY( c == bb ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc new file mode 100644 index 000000000..e76548f80 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <string> +#include <testsuite_hooks.h> + +struct X +{ + operator const char*() { return "10101010"; } +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + X x; + std::string s(x); + std::bitset<32> b1(static_cast<const char*>(x)); + std::bitset<32> b2(s); + VERIFY( b1 == b2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc new file mode 100644 index 000000000..f36268361 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-12-31 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + const unsigned long long num0 = 0ULL; + std::bitset<0> bs0(num0); + VERIFY( bs0.to_ullong() == num0 ); + + const unsigned long long num1 = 215ULL; + std::bitset<32> bs1(num1); + VERIFY( bs1.to_ullong() == num1 ); + + const unsigned long long num2 = 215ULL; + std::bitset<64> bs2(num2); + VERIFY( bs2.to_ullong() == num2 ); + + const unsigned long long num3 = 343353215ULL; + std::bitset<32> bs3(num3); + VERIFY( bs3.to_ullong() == num3 ); + + const unsigned long long num4 = 343353215ULL; + std::bitset<64> bs4(num4); + VERIFY( bs4.to_ullong() == num4 ); + + const unsigned long long num5 = 13008719539498589283ULL; + std::bitset<64> bs5(num5); + VERIFY( bs5.to_ullong() == num5 ); + + const unsigned long long num6 = 13008719539498589283ULL; + std::bitset<128> bs6(num6); + VERIFY( bs6.to_ullong() == num6 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc new file mode 100644 index 000000000..f1989e4d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <bitset> + +class C0 +{ + public: + C0() : b(0) { } + private: + std::bitset<1> b; +}; + +class C1 +{ + public: + C1() : b(1) { } + private: + std::bitset<1> b; +}; + +// libstdc++/38244 +void func() +{ + C0 val0; + C1 val1; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc new file mode 100644 index 000000000..1bb1b19dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc @@ -0,0 +1,84 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +// libstdc++/50268 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::bitset<1> b1(3ULL); + VERIFY( b1.count() == 1ULL ); + + std::bitset<3> b2(30ULL); + VERIFY( b2.count() == 2ULL ); + + std::bitset<6> b3(300ULL); + VERIFY( b3.count() == 3ULL ); + + std::bitset<9> b4(3000ULL); + VERIFY( b4.count() == 5ULL ); + + std::bitset<16> b5(300000ULL); + VERIFY( b5.count() == 7ULL ); + + std::bitset<24> b6(30000000ULL); + VERIFY( b6.count() == 9ULL ); + + std::bitset<32> b7(30000000000ULL); + VERIFY( b7.count() == 13ULL ); + + std::bitset<37> b8(3000000000000ULL); + VERIFY( b8.count() == 18ULL ); + + std::bitset<40> b9(30000000000000ULL); + VERIFY( b9.count() == 16ULL ); + + std::bitset<45> b10(30000000000000ULL); + VERIFY( b10.count() == 20ULL ); + + std::bitset<64> b11(30000000000000ULL); + VERIFY( b11.count() == 20ULL ); + + std::bitset<100> b12(30000000000000ULL); + VERIFY( b12.count() == 20ULL ); + + std::bitset<200> b13(30000000000000ULL); + VERIFY( b13.count() == 20ULL ); + + std::bitset<45> b14(18446744073709551615ULL); + VERIFY( b14.count() == 45ULL ); + + std::bitset<64> b15(18446744073709551615ULL); + VERIFY( b15.count() == 64ULL ); + + std::bitset<100> b16(18446744073709551615ULL); + VERIFY( b16.count() == 64ULL ); + + std::bitset<200> b17(18446744073709551615ULL); + VERIFY( b17.count() == 64ULL ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc new file mode 100644 index 000000000..5c1786767 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc @@ -0,0 +1,63 @@ +// 1999-06-08 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.1 bitset constructors + +#include <string> +#include <bitset> +#include <stdexcept> +#include <testsuite_hooks.h> + +// boundary condition: a zero-sized set +// libstdc++/6282 +bool test02(void) +{ + using std::char_traits; using std::allocator; + bool test __attribute__((unused)) = true; + + std::bitset<0> z1; + VERIFY( z1.any() == false ); + + std::bitset<0> z2(12345); + VERIFY( z2.any() == false ); + + std::bitset<0> z3(std::string("10101010101")); + VERIFY( z3.any() == false ); + + try { + z1.set(0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + VERIFY( z1.to_ulong() == 0 ); + VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() )); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc new file mode 100644 index 000000000..dec3d57f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()<std::bitset<0>>(); + test1.operator()<std::bitset<1>>(); + test1.operator()<std::bitset<256>>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<std::bitset<0>, unsigned long long>(); + test2.operator()<std::bitset<1>, unsigned long long>(); + test2.operator()<std::bitset<256>, unsigned long long>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc new file mode 100644 index 000000000..b2e876db2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> + +// DR 1325. +std::bitset<10> b(0); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc new file mode 100644 index 000000000..53496b4c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +template<std::size_t Nb, typename CharT> + std::bitset<Nb> + test01_ref(const CharT* str, + typename std::basic_string<CharT>::size_type n + = std::basic_string<CharT>::npos, + CharT zero = CharT('0'), CharT one = CharT('1')) + { + return std::bitset<Nb>(n == std::basic_string<CharT>::npos + ? std::basic_string<CharT>(str) + : std::basic_string<CharT>(str, n), + 0, n, zero, one); + } + +// DR 1325. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const char s1[4] = { '0', '1', '0', '1' }; + VERIFY( bitset<4>(s1, 4) == test01_ref<4>(s1, 4) ); + + const char s2[3] = { '1', '1', '0' }; + VERIFY( bitset<6>(s2, 3) == test01_ref<6>(s2, 3) ); + + const char* s3 = "1110110"; + VERIFY( bitset<7>(s3) == test01_ref<7>(s3) ); + + const char* s4 = "0011"; + VERIFY( bitset<10>(s4) == test01_ref<10>(s4) ); + + const char* s5 = "011110000111001"; + VERIFY( bitset<5>(s5) == test01_ref<5>(s5) ); + + const char* s6 = "1cc1c1"; + VERIFY( bitset<6>(s6, basic_string<char>::npos, 'c') + == test01_ref<6>(s6, basic_string<char>::npos, 'c') ); + + const char* s7 = "001011101"; + VERIFY( bitset<9>(s7, basic_string<char>::npos, '0', '1') + == test01_ref<9>(s7, basic_string<char>::npos, '0', '1') ); + + const char* s8 = "babb"; + VERIFY( bitset<4>(s8, basic_string<char>::npos, 'a', 'b') + == test01_ref<4>(s8, basic_string<char>::npos, 'a', 'b') ); + + const char* s9 = "bbabbbaaa"; + VERIFY( bitset<100>(s9, basic_string<char>::npos, 'a', 'b') + == test01_ref<100>(s9, basic_string<char>::npos, 'a', 'b') ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc new file mode 100644 index 000000000..182cd1443 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc @@ -0,0 +1,51 @@ +// 2009-09-23 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +// DR 396. what are characters zero and one. +void test01() +{ + bool test __attribute__((unused)) = true; + + std::bitset<4> z1(std::string("bbab"), 0, std::string::npos, 'a', 'b'); + VERIFY( z1.to_string('a', 'b') == "bbab" ); + + std::bitset<4> z2(std::string("11a1"), 0, std::string::npos, 'a'); + VERIFY( z2.to_string('a') == "11a1" ); + + std::bitset<8> z3(std::string("babb"), 0, std::string::npos, 'a', 'b'); + VERIFY( z3.to_string('a', 'b') == "aaaababb" ); + + std::bitset<8> z4(std::string("1a11"), 0, std::string::npos, 'a'); + VERIFY( z4.to_string('a') == "aaaa1a11" ); + + std::bitset<2> z5(std::string("bbab"), 0, std::string::npos, 'a', 'b'); + VERIFY( z5.to_string('a', 'b') == "bb" ); + + std::bitset<2> z6(std::string("11a1"), 0, std::string::npos, 'a'); + VERIFY( z6.to_string('a') == "11" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc new file mode 100644 index 000000000..27ee295c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc @@ -0,0 +1,38 @@ +// 2001-06-03 pme + +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <stdexcept> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/6124 +void test02() +{ + std::bitset<1> bs; + bs.count(); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/debug/invalidation/1.cc new file mode 100644 index 000000000..df0e30aab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/debug/invalidation/1.cc @@ -0,0 +1,47 @@ +// Bitset reference invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/bitset> +#include <testsuite_hooks.h> + +using __gnu_debug::bitset; + +bool test = true; + +// Disappear +void test01() +{ + bitset<32>::reference* i; + { + bitset<32> bs; + bs.flip(7); + i = new bitset<32>::reference(bs[7]); + VERIFY(*i); + } +#if __cplusplus < 201103L + VERIFY(i->_M_singular()); +#endif + delete i; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc new file mode 100644 index 000000000..9f9ddc0c2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +// libstdc++/15361 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<256> b; + b.set(225); + b.set(226); + + VERIFY( b._Find_first() == 225 ); + VERIFY( b._Find_next(225) == 226 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/hash/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/hash/1.cc new file mode 100644 index 000000000..4bee6fc9e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/hash/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> + +void test01() +{ + std::bitset<0> b0; + std::hash<std::bitset<0>> h0; + h0(b0); + + std::bitset<10> b1; + std::hash<std::bitset<10>> h1; + h1(b1); + + std::bitset<100> b2; + std::hash<std::bitset<100>> h2; + h2(b2); + + std::bitset<1000> b3; + std::hash<std::bitset<1000>> h3; + h3(b3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/input/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/input/1.cc new file mode 100644 index 000000000..ab119b28f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/input/1.cc @@ -0,0 +1,49 @@ +// 2003-12-03 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.3 bitset operators + +#include <bitset> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<5> b5; + bitset<0> b0; + stringstream ss; + + ss.str("*"); + ss >> b5; + VERIFY( ss.rdstate() == ios_base::failbit ); + + ss.clear(); + ss.str("*"); + ss >> b0; + VERIFY( ss.rdstate() == ios_base::goodbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc new file mode 100644 index 000000000..d32b02189 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc @@ -0,0 +1,108 @@ +// 2000-01-15 Anders Widell <awl@hem.passagen.se> + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <set> +#include <bitset> +#include <testsuite_hooks.h> + +static char original_bits[1024]; +static char left_shifted[1024]; +static char right_shifted[1024]; + +char +random_bit() { + static long x = 1; + return ((x = (3432L*x + 6789L) % 9973L) & 1) + '0'; +} + +void +initialise(size_t size) { + for (size_t i=0; i<size; i++) + original_bits[i] = random_bit(); + + original_bits[size] = '\0'; + left_shifted[size] = '\0'; + right_shifted[size] = '\0'; +} + +void +shift_arrays(size_t shift_step, size_t size) { + for (size_t i=shift_step; i<size; i++) { + right_shifted[i] = original_bits[i-shift_step]; + left_shifted[size-i-1] = original_bits[size+shift_step-i-1]; + } + for (size_t i=0; i<shift_step && i<size; i++) { + right_shifted[i] = '0'; + left_shifted[size-i-1] = '0'; + } +} + +template <size_t size> + bool + do_test() { + bool test __attribute__((unused)) = true; + + std::bitset<size> shifted; + std::bitset<size> correct; + + initialise(size); + + //std::bitset<size> original = std::string(original_bits); + std::bitset<size> original = std::bitset<size> (std::string(original_bits)); + + for (size_t shift_step=0; shift_step==0 || shift_step<size; shift_step++) { + shift_arrays(shift_step, size); + + shifted = original; + shifted <<= shift_step; + //correct = std::string(left_shifted); + correct = std::bitset<size> (std::string(left_shifted)); + VERIFY( shifted == correct ); + + shifted = original; + shifted >>= shift_step; + //correct = std::string(right_shifted); + correct = std::bitset<size> (std::string(right_shifted)); + VERIFY( shifted == correct ); + } + + return test; + } + +bool +test01() { + bool test __attribute__((unused)) = true; + + VERIFY( do_test<32>() ); + VERIFY( do_test<48>() ); + VERIFY( do_test<64>() ); + + VERIFY( do_test<511>() ); + VERIFY( do_test<513>() ); + VERIFY( do_test<997>() ); + return test; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/13838.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/13838.cc new file mode 100644 index 000000000..ee7405517 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/13838.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/bitset> +#include <testsuite_hooks.h> + +// libstdc++/13838 +void test01() +{ + using __gnu_debug::bitset; + bool test __attribute__((unused)) = true; + + bitset<4> b0, b1; + b0.set(1); + b0.set(3); + b1.set(2); + b1.set(3); + + b0 |= b1; + + bitset<4> br; + br.set(1); + br.set(2); + br.set(3); + + VERIFY( b0 == br ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc new file mode 100644 index 000000000..aba6d431b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc @@ -0,0 +1,41 @@ +// 2000-01-15 Anders Widell <awl@hem.passagen.se> + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <set> +#include <bitset> +#include <testsuite_hooks.h> + +bool +test02() +{ + bool test __attribute__((unused)) = true; + + std::bitset<66> b; + b <<= 400; + VERIFY( b.count() == 0 ); + return test; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc new file mode 100644 index 000000000..72dd948f8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> + +int main() +{ + // bitset base type + typedef std::_Base_bitset<6> bitset_base; + constexpr bitset_base base = bitset_base(); + + constexpr auto r1 __attribute__((unused)) = base._M_getword(2); + // constexpr auto r2 = base._M_getdata(); // error, pointer to this + auto r2 __attribute__((unused)) = base._M_getdata(); + constexpr auto r3 __attribute__((unused)) = base._M_hiword(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc new file mode 100644 index 000000000..0a3604824 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> + +int main() +{ + // bitset operators + typedef std::bitset<6> bitset_type; + constexpr bitset_type a = bitset_type(); + constexpr auto v __attribute__((unused)) = a[0]; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/constexpr_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/constexpr_functions.cc new file mode 100644 index 000000000..a90d80eb4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/constexpr_functions.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr _Ttesttype obj; + constexpr auto v1 __attribute__((unused)) = obj.size(); + // constexpr auto v2 = obj[4]; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()<std::bitset<0>>(); + test.operator()<std::bitset<1>>(); + test.operator()<std::bitset<64>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..34de15d2a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers. + +#include <bitset> + +template class std::bitset<10>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..fa33297dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers. + +#include <bitset> + +template class std::bitset<10>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc new file mode 100644 index 000000000..7a7ad1d20 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc @@ -0,0 +1,52 @@ +// 2001-06-03 pme + +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <stdexcept> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01(void) +{ + bool test __attribute__((unused)) = true; + const size_t n1 = 5; + + // the other 22 member functions should be in here too... + try { + std::bitset<n1> five_bits; + bool unused __attribute__((unused)) = five_bits.test(n1); // should throw + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc new file mode 100644 index 000000000..ff90f8b2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc @@ -0,0 +1,52 @@ +// 2004-11-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<5> b5; + string s0 = b5.to_string<char, char_traits<char>, allocator<char> >(); + VERIFY( s0 == "00000" ); + + // DR 434. bitset::to_string() hard to use. + b5.set(0); + string s1 = b5.to_string<char, char_traits<char> >(); + VERIFY( s1 == "00001" ); + + b5.set(2); + string s2 = b5.to_string<char>(); + VERIFY( s2 == "00101" ); + + b5.set(4); + string s3 = b5.to_string(); + VERIFY( s3 == "10101" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/dr396.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/dr396.cc new file mode 100644 index 000000000..780616e9f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_string/dr396.cc @@ -0,0 +1,64 @@ +// 2008-09-23 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <testsuite_hooks.h> + +// DR 396. what are characters zero and one. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<5> b5; + string s0 = b5.to_string<char, char_traits<char>, allocator<char> >('a', 'b'); + VERIFY( s0 == "aaaaa" ); + + string s1 = b5.to_string<char, char_traits<char>, allocator<char> >('b'); + VERIFY( s1 == "bbbbb" ); + + b5.set(0); + string s2 = b5.to_string<char, char_traits<char> >('c', 'd'); + VERIFY( s2 == "ccccd" ); + + string s3 = b5.to_string<char, char_traits<char> >('d'); + VERIFY( s3 == "dddd1" ); + + b5.set(2); + string s4 = b5.to_string<char>('e', 'f'); + VERIFY( s4 == "eefef" ); + + string s5 = b5.to_string<char>('f'); + VERIFY( s5 == "ff1f1" ); + + b5.set(4); + string s6 = b5.to_string('g', 'h'); + VERIFY( s6 == "hghgh" ); + + string s7 = b5.to_string('h'); + VERIFY( s7 == "1h1h1" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc new file mode 100644 index 000000000..b27175b34 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-12-29 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::bitset<0> bs0; + VERIFY( bs0.to_ullong() == 0 ); + + std::bitset<64> bs1("11010111"); + VERIFY( bs1.to_ullong() == 215 ); + + std::bitset<64> bs2("10110100100010000100000101111111" + "01111110011111110001110001100011"); + VERIFY( bs2.to_ullong() == 13008719539498589283ULL ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc new file mode 100644 index 000000000..5fa512369 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc @@ -0,0 +1,47 @@ +// 2001-06-03 pme + +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.5.2 bitset members + +#include <bitset> +#include <stdexcept> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + bool test __attribute__((unused)) = true; + std::bitset<5> b; + std::stringstream ss("101"); + ss.exceptions(std::ios_base::eofbit); + + try + { + ss >> b; + } + catch (std::exception&) { } + + VERIFY( b.to_ulong() == 5 ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/14340.cc new file mode 100644 index 000000000..750147753 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/14340.cc @@ -0,0 +1,34 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <testsuite_hooks.h> +#include <deque> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::deque<int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/18604.cc new file mode 100644 index 000000000..9d6de74ee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/18604.cc @@ -0,0 +1,41 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <deque> diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/58764.cc new file mode 100644 index 000000000..a1056aa71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <deque> + +void test01() +{ + std::deque<int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc new file mode 100644 index 000000000..7ce201cfb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include <deque> +#include <stdexcept> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque<int> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc new file mode 100644 index 000000000..a5377c4f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include <deque> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<int> d; + + VERIFY( d.max_size() == d.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc new file mode 100644 index 000000000..86e1678ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<copycounter> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc new file mode 100644 index 000000000..fd37e0f16 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc new file mode 100644 index 000000000..d6d9fb8a4 --- /dev/null +++ b/gcc-4.9/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 <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/42573 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc new file mode 100644 index 000000000..8356ab0f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc @@ -0,0 +1,73 @@ +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <deque> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::deque<int, tracker_allocator<int> > 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc new file mode 100644 index 000000000..5a274303d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/1.cc @@ -0,0 +1,49 @@ +// 2001-12-27 pme +// +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.1 deque constructors, copy, and assignment + +#include <deque> +#include <iterator> +#include <sstream> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc new file mode 100644 index 000000000..1596a9a9a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc @@ -0,0 +1,521 @@ +// 2001-12-27 pme +// +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.1 deque constructors, copy, and assignment + +#include <deque> +#include <iterator> +#include <sstream> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +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<object_counter> 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<T> 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<T> 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<T> 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<T> 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::size_t>(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 precede 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<T> 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<T> 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<T> 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<T> X; + + std::istringstream ibuf("1234567890123456789"); + const X::size_type rangeSize = ibuf.str().size(); + std::istream_iterator<char> i(ibuf); + std::istream_iterator<char> 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<T> 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<T> 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<typename InputIterator> +// 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<T> 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<T> 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<T> 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<T, tracker_allocator<T> > 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<T, tracker_allocator<T> > 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/55977.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/55977.cc new file mode 100644 index 000000000..b23371968 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/55977.cc @@ -0,0 +1,70 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <memory> +#include <utility> +#include <deque> +#include <iterator> + +template <class T> +struct MyAllocator +{ + std::allocator<T> base; + typedef T value_type; + + // FIXME: these types shouldn't be required. + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + template <typename U> + struct rebind + { typedef MyAllocator<U> other; }; + + MyAllocator() = default; + template <class U> + MyAllocator(const MyAllocator<U>& other) : base(other.base) {} + T* allocate(std::size_t n) { return base.allocate(n); } + void deallocate(T* p, std::size_t n) { return base.deallocate(p, n); } + template <class U, class... Args> + void construct(U* p, Args&&... args) + { + ::new (static_cast<void*>(p)) U(std::forward<Args>(args)...); + } +}; + +struct A +{ +private: + friend class MyAllocator<A>; + A(int value) : value(value) {} + int value; +public: + A() : value() {} + int get() const { return value; } +}; + +void foo() +{ + std::deque<A, MyAllocator<A>> v1; + const int i = 1; + v1.emplace_back(i); // OK + std::deque<A, MyAllocator<A>> v2(std::istream_iterator<int>(), {}); // ERROR +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc new file mode 100644 index 000000000..7b857aeb6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc @@ -0,0 +1,51 @@ +// 2005-12-12 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.1 deque constructors, copy, and assignment + +#include <deque> +#include <cstdlib> +#include <testsuite_hooks.h> + +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<int>::size_type i = 0; i < 1000; ++i) + { + deque<int> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc new file mode 100644 index 000000000..3927c857b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator<T>() + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + 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<std::deque<int, clear_alloc<int> > >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc new file mode 100644 index 000000000..206a4aea9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc new file mode 100644 index 000000000..7923597a6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// 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 <deque> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::deque<int> a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); + + std::deque<int> c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == 1 ); + VERIFY( b.size() == 0 ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc new file mode 100644 index 000000000..dd811ebc9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/cons/moveable2.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <deque> +#include <iterator> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; +typedef std::deque<rvalstruct> 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<rvalstruct> begin, + input_iterator_wrapper<rvalstruct> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc new file mode 100644 index 000000000..ae87aff35 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc new file mode 100644 index 000000000..14450ae5a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign2<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc new file mode 100644 index 000000000..859218a4a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign3<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc new file mode 100644 index 000000000..b5613d66e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc new file mode 100644 index 000000000..b5c36e47b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc new file mode 100644 index 000000000..94726e151 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc new file mode 100644 index 000000000..6e68e653c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc new file mode 100644 index 000000000..fa16e838f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc new file mode 100644 index 000000000..ec43171a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc new file mode 100644 index 000000000..1081ca22a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc new file mode 100644 index 000000000..60d904571 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc new file mode 100644 index 000000000..113114fdc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc new file mode 100644 index 000000000..ded326696 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <deque> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert4<std::deque<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc new file mode 100644 index 000000000..b0485b65f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/1.cc @@ -0,0 +1,52 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/deque> +#include <testsuite_hooks.h> + +using __gnu_debug::deque; + +bool test = true; + +// Assignment +void test01() +{ + deque<int> v1; + deque<int> v2; + + deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc new file mode 100644 index 000000000..57e19cc6a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/2.cc @@ -0,0 +1,52 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/deque> +#include <testsuite_hooks.h> + +using __gnu_debug::deque; + +bool test = true; + +// Resize +void test02() +{ + deque<int> v(10, 17); + + deque<int>::iterator before = v.begin() + 6; + deque<int>::iterator at = before + 1; + deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc new file mode 100644 index 000000000..5ef42df1b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/3.cc @@ -0,0 +1,62 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/deque> +#include <testsuite_hooks.h> + +using __gnu_debug::deque; + +bool test = true; + +// Insert +void test03() +{ + deque<int> v(10, 17); + + // Insert a single element + deque<int>::iterator before = v.begin() + 6; + deque<int>::iterator at = before + 1; + deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc new file mode 100644 index 000000000..04cb91a36 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/invalidation/4.cc @@ -0,0 +1,74 @@ +// Deque iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/deque> +#include <testsuite_hooks.h> + +using __gnu_debug::deque; + +bool test = true; + +// Erase +void test04() +{ + deque<int> v(20, 42); + + // Single element erase (middle) + deque<int>::iterator before = v.begin(); + deque<int>::iterator at = before + 3; + deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..c4ced23a5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <deque> + +void test01() +{ + std::deque<int> d1; + auto it1 = d1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..6a6238582 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <deque> + +void test01() +{ + std::deque<int> d1; + d1 = std::move(d1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc new file mode 100644 index 000000000..e3401aad4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <deque> + +void test01() +{ + using std::deque; + deque<int> d; + // Let's generate a hole at the beginning of the deque: + d.push_back(0); + d.push_back(1); + d.pop_front(); + deque<int>::iterator it; + do + { + d.push_back(2); + it = d.begin(); + auto old_abegin = &*d.begin(); + d.shrink_to_fit(); + if (&*d.begin() != old_abegin) + break; + } + while (true); + // Following line should assert + *it = 2; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/init-list.cc new file mode 100644 index 000000000..23a164e23 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/init-list.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <deque> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::deque<int, tracker_allocator<int> > 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc new file mode 100644 index 000000000..0460d7cbe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +// libstdc++/52799 +int main() +{ + std::deque<int> d; + d.emplace(d.begin()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc new file mode 100644 index 000000000..d9e11f6c0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +void test01() +{ + std::deque<int> d1; + d1.emplace(d1.cbegin(), 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc new file mode 100644 index 000000000..8ff077411 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/1.cc @@ -0,0 +1,135 @@ +// 2005-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.3 deque modifiers + +#include <deque> +#include <testsuite_hooks.h> + +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<int> 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<std::deque<int> > 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<int>(1, A[i])); + for (unsigned i = 0; i < N1; ++i) + v1.push_back(std::deque<int>(1, A1[i])); + for (unsigned i = 0; i < N2; ++i) + v2.push_back(std::deque<int>(1, A2[i])); + for (unsigned i = 0; i < N3; ++i) + v3.push_back(std::deque<int>(1, A3[i])); + for (unsigned i = 0; i < N4; ++i) + v4.push_back(std::deque<int>(1, A4[i])); + for (unsigned i = 0; i < N5; ++i) + v5.push_back(std::deque<int>(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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc new file mode 100644 index 000000000..eb1ec6e55 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/2.cc @@ -0,0 +1,114 @@ +// 2005-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.3 deque modifiers + +#include <deque> +#include <testsuite_hooks.h> + +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<int Size> + class My_class + { + double dummy[Size]; + int data; + + public: + My_class(int num) + : data(num) { } + + operator int() const + { return data; } + }; + +template<typename T> + void + test01() + { + bool test __attribute__((unused)) = true; + + typedef std::deque<T> 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<My_class<1> >(); + test01<My_class<8> >(); + test01<My_class<32> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc new file mode 100644 index 000000000..5c8d8b380 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.3 deque modifiers + +#include <deque> +#include <testsuite_hooks.h> + +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<copy_tracker> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc new file mode 100644 index 000000000..d7e8e5d7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-09-26 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_rvalref.h> + +// 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/54577.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/54577.cc new file mode 100644 index 000000000..d1021bbc8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +void test01() +{ + std::deque<int> d1; + d1.push_back(1); + d1.erase(d1.cbegin()); + + std::deque<int> d2; + d2.push_back(2); + d2.push_back(3); + d2.erase(d2.cbegin(), d2.cend()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc new file mode 100644 index 000000000..a6e33a0a2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/moveable.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-28 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::deque<copycounter> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc new file mode 100644 index 000000000..eee60b7c7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +void test01() +{ + std::deque<int> d1, d2{5, 6}; + int n = 0; + std::deque<int>::iterator it = d1.insert(d1.cbegin(), n); + it = d1.insert(d1.cbegin(), 1); + it = d1.insert(d1.cbegin(), {2, 3}); + it = d1.insert(d1.cbegin(), 1, 4); + it = d1.insert(d1.cbegin(), d2.begin(), d2.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc new file mode 100644 index 000000000..be8e2e99a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/moveable.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; + +// Test deque::push_back makes no unneeded copies. +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<copycounter> 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<copycounter> 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<copycounter> 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<copycounter> 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<copycounter> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_back/49836.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_back/49836.cc new file mode 100644 index 000000000..3d1ed5f36 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_back/49836.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// libstdc++/49836 +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::CopyConsOnlyType; + using __gnu_test::MoveConsOnlyType; + + std::deque<CopyConsOnlyType> d1; + CopyConsOnlyType t1(1); + d1.push_back(t1); + d1.push_back(t1); + d1.push_back(t1); + VERIFY( d1.size() == 3 ); + + std::deque<MoveConsOnlyType> d2; + MoveConsOnlyType t2(1); + d2.push_back(std::move(t2)); + d2.push_back(std::move(t2)); + d2.push_back(std::move(t2)); + VERIFY( d2.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_front/49836.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_front/49836.cc new file mode 100644 index 000000000..c4a9d62e2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/push_front/49836.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// libstdc++/49836 +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::CopyConsOnlyType; + using __gnu_test::MoveConsOnlyType; + + std::deque<CopyConsOnlyType> d1; + CopyConsOnlyType t1(1); + d1.push_front(t1); + d1.push_front(t1); + d1.push_front(t1); + VERIFY( d1.size() == 3 ); + + std::deque<MoveConsOnlyType> d2; + MoveConsOnlyType t2(1); + d2.push_front(std::move(t2)); + d2.push_front(std::move(t2)); + d2.push_front(std::move(t2)); + VERIFY( d2.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc new file mode 100644 index 000000000..23aebb94b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_hooks.h> + +struct T { int i; }; + +int swap_calls; + +namespace std +{ + template<> + void + deque<T, allocator<T> >::swap(deque<T, allocator<T> >&) + { ++swap_calls; } +} + +// Should use deque specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::deque<T> A; + std::deque<T> 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<T> A; + deque<T> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc new file mode 100644 index 000000000..e7cd120e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc @@ -0,0 +1,132 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.3 deque::swap + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef deque<char, my_alloc> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc new file mode 100644 index 000000000..8087dca2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/3.cc @@ -0,0 +1,161 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1.3 deque::swap + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef deque<char, my_alloc> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc new file mode 100644 index 000000000..4aafd9f9f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/1.cc @@ -0,0 +1,62 @@ +// 2002-05-18 Paolo Carlini <pcarlini@unitus.it> + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1 deque operators + +#include <deque> +#include <testsuite_hooks.h> + +// libstdc++/6503 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<int> d(2); + typedef std::deque<int>::iterator iter; + typedef std::deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc new file mode 100644 index 000000000..e278f60c1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/operators/2.cc @@ -0,0 +1,50 @@ +// 2002-05-18 Paolo Carlini <pcarlini@unitus.it> + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.1 deque operators + +#include <deque> +#include <testsuite_hooks.h> + +// libstdc++/7186 +void test02() +{ + bool test __attribute__((unused)) = true; + + std::deque<int> d(2); + typedef std::deque<int>::iterator iter; + typedef std::deque<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/range_access.cc new file mode 100644 index 000000000..3058e3155 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <deque> + +void +test01() +{ + std::deque<int> d{1, 2, 3}; + std::begin(d); + std::end(d); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc new file mode 100644 index 000000000..eb1d87f94 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <testsuite_containers.h> + +int main() +{ + typedef std::deque<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/do_the_right_thing.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/do_the_right_thing.cc new file mode 100644 index 000000000..9c77e6fc3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/do_the_right_thing.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +// libstdc++/43813 +void test01() +{ + std::deque<double*> d(7, 0); + d.assign(7, 0); + d.insert(d.begin(), 7, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..4de8f2d0f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -0,0 +1,34 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1764 } + +#include <deque> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::deque<A> d; + d.assign(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc new file mode 100644 index 000000000..28c47d448 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <deque> + +void f() +{ + std::deque<int> v(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..41f290561 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,28 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1697 } + +#include <deque> + +void f() +{ + std::deque<std::deque<int> > d(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..f77b12678 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,29 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1697 } + +#include <deque> +#include <utility> + +void f() +{ + std::deque<std::deque<std::pair<char, char> > > d('a', 'b'); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..e7d5b1ee6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -0,0 +1,34 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1848 } + +#include <deque> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::deque<A> d; + d.insert(d.begin(), 10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/basic.cc new file mode 100644 index 000000000..6893ecde6 --- /dev/null +++ b/gcc-4.9/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 <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::deque<value_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..dcc4db11b --- /dev/null +++ b/gcc-4.9/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 <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::deque<value_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..6b98401f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/exception/propagation_consistent.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::deque<value_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..2ddcb63da --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <deque> + +// { dg-do compile } + +template class std::deque<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..61e4a8bb8 --- /dev/null +++ b/gcc-4.9/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-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <deque> + +template class std::deque<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..3c7bcfef9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <deque> +#include <testsuite_api.h> + +// { dg-do compile } + +// N.B. In C++0x mode we cannot instantiate with T == NonDefaultConstructible +// because of 23.3.2.1.4 +#if __cplusplus < 201103L +template class std::deque<__gnu_test::NonDefaultConstructible>; +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..d0ad21b0e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <deque> + +// { dg-do compile } + +// libstdc++/21770 +template class std::deque<int, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..46125ad22 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/explicit_instantiation/4.cc @@ -0,0 +1,30 @@ +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <deque> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::deque<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..22a8447de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <deque> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Allocator> + class deque<user_type, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc new file mode 100644 index 000000000..aa45e086b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <deque> + +// Check container for required typedefs. +__gnu_test::types<std::deque<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/types/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/types/1.cc new file mode 100644 index 000000000..b4dd26e6c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/deque/types/1.cc @@ -0,0 +1,52 @@ +// 2005-12-18 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <deque> +#include <testsuite_greedy_ops.h> + +int main() +{ + std::deque<greedy_ops::X> d(5); + const std::deque<greedy_ops::X> 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<greedy_ops::X>::iterator it; + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + it + 1; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy.cc new file mode 100644 index 000000000..cd05f6376 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy_assign.cc new file mode 100644 index 000000000..90ea11f7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/copy_assign.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc new file mode 100644 index 000000000..bd5a01811 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <forward_list> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::CustomPointerAlloc; + +template class std::forward_list<T, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v; + v.push_front(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/minimal.cc new file mode 100644 index 000000000..620831cb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/minimal.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <forward_list> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::SimpleAllocator; + +template class std::forward_list<T, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v(alloc_type{}); + v.push_front(T()); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move.cc new file mode 100644 index 000000000..cc0356a23 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { T() }; + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { T() }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc new file mode 100644 index 000000000..cd19ddff9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + v2 = std::move(v1); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc new file mode 100644 index 000000000..2a349ec0d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <forward_list> +#include <testsuite_allocator.h> + +struct T { int i; }; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc new file mode 100644 index 000000000..3d96d3202 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_front(T()); + test_type v2(alloc_type(2)); + v2.push_front(T()); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc new file mode 100644 index 000000000..3ba163916 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list capacity [lib.forward_list.capacity] + +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<double> fld; + VERIFY(fld.empty() == true); + + fld.push_front(1.0); + VERIFY(fld.empty() == false); + + fld.resize(0); + VERIFY(fld.empty() == true); + +#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) + using std::_GLIBCXX_STD_C::_Fwd_list_node; +#else + using std::_Fwd_list_node; +#endif + + VERIFY( (fld.max_size() + == std::allocator<_Fwd_list_node<double> >().max_size()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc new file mode 100644 index 000000000..356122933 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<__gnu_test::NonCopyConstructible> fl; + VERIFY( std::distance(fl.begin(), fl.end()) == 0 ); + + fl.resize(1000); + VERIFY( std::distance(fl.begin(), fl.end()) == 1000 ); + for(auto it = fl.begin(); it != fl.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc new file mode 100644 index 000000000..d270a7e7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + + VERIFY((a == b) == false); + VERIFY((a < b) == true); + VERIFY((a != b) == true); + VERIFY((a > b) == false); + VERIFY((a >= b) == false); + VERIFY((a <= b) == true); + + VERIFY((b == a) == false); + VERIFY((b < a) == false); + VERIFY((b != a) == true); + VERIFY((b > a) == true); + VERIFY((b >= a) == true); + VERIFY((b <= a) == false); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc new file mode 100644 index 000000000..c04c05d46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Default construction +void +test01() +{ + std::forward_list<double> fld; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc new file mode 100644 index 000000000..4d4b002ad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4.2 forward_list construction [forwardlist.cons] + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct Counter +{ + Counter() { ++create; } + Counter(const Counter&) { ++create; } + ~Counter() { ++destroy; } + + static int create; + static int destroy; +}; + +int Counter::create = 0; +int Counter::destroy = 0; + +void test01() +{ + typedef __gnu_test::uneq_allocator<Counter> alloc; + typedef std::forward_list<Counter, alloc> list; + + { + Counter c; + + list l( list(10, c, alloc(1)), alloc(2) ); + + VERIFY( Counter::create == 21 ); + VERIFY( Counter::destroy == 10 ); + } + VERIFY( Counter::destroy == 21 ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc new file mode 100644 index 000000000..d2c4fd850 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4.2 forward_list construction [forwardlist.cons] + +#include <forward_list> + +bool fail = false; + +struct A +{ + A() = default; + A(const A&) { if (fail) throw fail; } +}; + +void test01() +{ + typedef std::forward_list<A> list; + + list l(2); + A from[2]; + fail = true; + // Check existing elements are assigned to, instead of creating new ones. + // This is QoI, not required by the standard. + l.assign(from, from+2); + l.assign(2, from[0]); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/12.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/12.cc new file mode 100644 index 000000000..2cbaec7be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/12.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4.2 forward_list construction [forwardlist.cons] + +#include <forward_list> + +bool fail = false; + +struct NonCopyAssignable +{ + NonCopyAssignable() = default; + NonCopyAssignable(const NonCopyAssignable&) = default; + NonCopyAssignable(int) { } + + NonCopyAssignable& operator=(const NonCopyAssignable&) = delete; + NonCopyAssignable& operator=(int) = delete; +}; + +void test01() +{ + typedef std::forward_list<NonCopyAssignable> list; + + list l(2); + NonCopyAssignable from[2]; + int from2[2]; + + // Assigning non-Assignable elements is QoI, not required by the standard. + + l = l; + + l.assign(from, from+2); + l.assign(2, from[0]); + + l.assign(from2, from2+2); + l.assign(2, from2[0]); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/13.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/13.cc new file mode 100644 index 000000000..de866d517 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/13.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4.2 forward_list construction [forwardlist.cons] + +#include <forward_list> +#include <memory> +#include <scoped_allocator> +#include <testsuite_hooks.h> + +struct A +{ + typedef std::allocator<A> allocator_type; + + A() : ok(false) { } + A(const A&) : ok(false) { } + A(const allocator_type&) : ok(true) { } + A(const A&, const allocator_type&) : ok(true) { } + + bool ok; +}; + +void test01() +{ + typedef std::scoped_allocator_adaptor<A::allocator_type> alloc_type; + typedef std::forward_list<A, alloc_type> list; + + list l1(1); + VERIFY( l1.begin()->ok ); + + A a; + list l2(1, a); + VERIFY( l2.begin()->ok ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/14.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/14.cc new file mode 100644 index 000000000..aae314e6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/14.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4.2 forward_list construction [forwardlist.cons] + +#include <forward_list> +#include <scoped_allocator> + +void test01() +{ + using namespace std; + using list = forward_list<int>; + forward_list<list, scoped_allocator_adaptor<list::allocator_type>> l; + + // Check for forward_list(size_type, const allocator_type&) + l.emplace_front(1u); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc new file mode 100644 index 000000000..f53869d3b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +// Copy construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flccin(i, i+ni); + std::forward_list<int> flcc(flccin, std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc new file mode 100644 index 000000000..4f43f585c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flmc(std::forward_list<int>(i, i+ni), std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc new file mode 100644 index 000000000..dd19f0e93 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of default item +void +test01() +{ + std::forward_list<double> flvd(10); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc new file mode 100644 index 000000000..eefa4a1a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of given item +void +test01() +{ + std::forward_list<float> flv(10, 5.0F); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc new file mode 100644 index 000000000..927ab2249 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc new file mode 100644 index 000000000..343ae3c67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Copy construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flc(fl); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc new file mode 100644 index 000000000..adbdfb4e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flm(std::move(fl)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc new file mode 100644 index 000000000..2fc9d5a4f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following. +// Construction from initializer list +void +test01() +{ + std::forward_list<double> flil({1.0, 2.0, 3.0, 4.0, 5.0}); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc new file mode 100644 index 000000000..ce65589a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<__gnu_test::NonCopyConstructible> fl(1000); + VERIFY( std::distance(fl.begin(), fl.end()) == 1000 ); + for(auto it = fl.begin(); it != fl.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/moveable.cc new file mode 100644 index 000000000..3eddebe01 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/moveable.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <utility> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<int> a, b; + a.push_front(1); + + b = std::move(a); + VERIFY(b.empty() == false); + VERIFY(*b.begin() == 1); + VERIFY(a.empty() == true); + + std::forward_list<int> c(std::move(b)); + VERIFY(c.empty() == false); + (*c.begin() == 1 ); + VERIFY( b.empty() == true ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..d6ba8e85b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +typedef std::forward_list<int> fltype; + +static_assert(std::is_nothrow_move_constructible<fltype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc new file mode 100644 index 000000000..f65ed2b08 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <forward_list> + +std::forward_list<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/clear.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/clear.cc new file mode 100644 index 000000000..92becbed2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/clear.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Check that iterators ownership is correctly manage on swap. +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + std::forward_list<int> fl{1, 2, 3}; + + auto before = fl.before_begin(); + auto end = fl.end(); + fl.clear(); + + VERIFY( end == fl.end() ); + VERIFY( before == fl.before_begin() ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc new file mode 100644 index 000000000..ad9a13514 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<int> fl1{1, 2, 3}; + + auto it = fl1.begin(); + VERIFY( *it == 1 ); + + fl1.erase_after(fl1.before_begin()); + + VERIFY( *it == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc new file mode 100644 index 000000000..ec3cbe75a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + fl1.erase_after(fl1.end()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc new file mode 100644 index 000000000..6ebdb2f67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1}; + fl1.erase_after(fl1.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc new file mode 100644 index 000000000..4a78dc6ba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.erase_after(fl1.before_begin(), fl2.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc new file mode 100644 index 000000000..904da8b6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.erase_after(fl2.before_begin(), fl2.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc new file mode 100644 index 000000000..86dc5e8db --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + + fl1.erase_after(fl1.before_begin(), fl1.before_begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc new file mode 100644 index 000000000..559b18013 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + + fl1.erase_after(fl1.end(), fl1.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc new file mode 100644 index 000000000..eb1fb2922 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + + fl1.erase_after(fl1.begin(), fl1.before_begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc new file mode 100644 index 000000000..335da4c1f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + + auto it = fl1.begin(); + ++it; + fl1.erase_after(it, fl1.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc new file mode 100644 index 000000000..46e1e5b5e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.insert_after(fl1.before_begin(), fl2.before_begin(), fl2.end()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc new file mode 100644 index 000000000..5967c93d1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{0}; + + fl1.insert_after(fl1.before_begin(), fl2.begin(), fl2.before_begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc new file mode 100644 index 000000000..8bc96186f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + + fl1.insert_after(fl1.end(), 4); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc new file mode 100644 index 000000000..b731ec958 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG_PEDANTIC" } +// { dg-do run { xfail *-*-* } } + +#include <forward_list> +#include <iterator> + +void test01() +{ + std::forward_list<int> fl{ 1, 2, 3 }; + fl.insert_after(fl.before_begin(), fl.begin(), std::next(fl.begin(), 2)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..7106dd7b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <forward_list> + +void test01() +{ + std::forward_list<int> fl1; + auto it1 = fl1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/move_constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/move_constructor.cc new file mode 100644 index 000000000..3f7ece838 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/move_constructor.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Check that iterators ownership is correctly manage on swap. +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + std::forward_list<int> fl1{1, 3, 5}; + + auto flit = fl1.before_begin(); + std::forward_list<int> fl2(std::move(fl1)); + +#if !_GLIBCXX_DEBUG + VERIFY( flit == fl1.before_begin() ); +#endif +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..7306b3a8b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <forward_list> + +void test01() +{ + std::forward_list<int> fl1; + fl1 = std::move(fl1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after.cc new file mode 100644 index 000000000..680607295 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Check that iterators ownership is correctly manage on swap. +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{4, 5, 6}; + + auto before = fl1.before_begin(); + auto end = fl1.end(); + fl2.splice_after(fl2.before_begin(), std::move(fl1)); + + VERIFY( before == fl1.before_begin() ); + VERIFY( end == fl1.end() ); + + // no-op just to check that debug mode does not see any problem with it. + fl1.splice_after(fl1.before_begin(), std::move(fl2), + fl2.before_begin(), fl2.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc new file mode 100644 index 000000000..d9f4810c2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + fl1.splice_after(fl1.begin(), std::move(fl1)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc new file mode 100644 index 000000000..ccaadfd54 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.splice_after(fl1.before_begin(), std::move(fl2), fl1.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc new file mode 100644 index 000000000..b1b72ed57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.splice_after(fl1.before_begin(), std::move(fl2), fl2.end()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc new file mode 100644 index 000000000..5bebaecd7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl1{1, 2, 3}; + std::forward_list<int> fl2{1, 2, 3}; + + fl1.splice_after(fl1.before_begin(), + std::move(fl2), ++(++fl2.begin()), ++fl2.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc new file mode 100644 index 000000000..b4b2e32d9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_allocator.h> + +void +test01() +{ + typedef __gnu_test::uneq_allocator<int> alloc_type; + + std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1)); + std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2)); + + fl1.splice_after(fl1.before_begin(), fl2); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc new file mode 100644 index 000000000..7b5c1a442 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_allocator.h> + +void +test01() +{ + typedef __gnu_test::uneq_allocator<int> alloc_type; + + std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1)); + std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2)); + + fl1.splice_after(fl1.before_begin(), fl2, fl2.begin()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc new file mode 100644 index 000000000..309dd01a5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_allocator.h> + +void +test01() +{ + typedef __gnu_test::uneq_allocator<int> alloc_type; + + std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1)); + std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2)); + + fl1.splice_after(fl1.before_begin(), fl2, fl2.begin(), fl2.end()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/swap.cc new file mode 100644 index 000000000..e6ee7b0ea --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/debug/swap.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Check that iterators ownership is correctly manage on swap. +#include <vector> +#include <forward_list> +#include <iostream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + std::forward_list<int> fl1{1, 3, 5}; + std::forward_list<int> fl2{2, 4, 6}; + + std::vector<std::forward_list<int>::iterator> fl1_its; + fl1_its.push_back(fl1.before_begin()); + for (std::forward_list<int>::iterator it = fl1.begin(); + it != fl1.end(); ++it) + { + fl1_its.push_back(it); + } + fl1_its.push_back(fl1.end()); + + std::vector<std::forward_list<int>::iterator> fl2_its; + fl2_its.push_back(fl2.before_begin()); + for (std::forward_list<int>::iterator it = fl2.begin(); + it != fl2.end(); ++it) + { + fl2_its.push_back(it); + } + fl2_its.push_back(fl2.end()); + + fl1.swap(fl2); + + auto fit = fl1.before_begin(); + // before-begin iterator is not transfered: + // TODO: Validate with LWG group how before begin should be + // treated. + VERIFY( fit == fl1_its[0] ); + // All other iterators are, even paste-the-end ones: + for (size_t i = 1; i != fl2_its.size(); ++i) + { + VERIFY( ++fit == fl2_its[i] ); + } + + fit = fl2.before_begin(); + // TODO: Validate with LWG group how before begin should be + // treated. + VERIFY( fit == fl2_its[0] ); + for (size_t i = 1; i != fl1_its.size(); ++i) + { + VERIFY( ++fit == fl1_its[i] ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc new file mode 100644 index 000000000..d7d3dd516 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <array> + +bool test __attribute__((unused)) = true; + +class PathPoint +{ +public: + PathPoint(char t, std::array<double, 3> & c) + : type(t), coord(c) { } + char getType() const { return type; } +private: + char type; + std::array<double, 3> coord; +}; + +// This test verifies the following. +// emplace_front +// pop_front +// emplace_after +void +test01() +{ + std::forward_list<PathPoint> path; + std::array<double, 3> coord1 = { { 0.0, 1.0, 2.0 } }; + path.emplace_front('a', coord1); + + std::forward_list<PathPoint>::const_iterator pos = path.cbegin(); + + std::array<double, 3> coord2 = { { 3.0, 4.0, 5.0 } }; + path.emplace_after(pos, 'b', coord2); + + VERIFY(path.front().getType() == 'a'); + + path.pop_front(); + + VERIFY(path.front().getType() == 'b'); + + path.pop_front(); + + VERIFY(path.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc new file mode 100644 index 000000000..8919d4221 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc @@ -0,0 +1,154 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <string> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// insert_after single item +// before_begin iterator +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::iterator ret = fl.insert_after(fl.before_begin(), + 42); + VERIFY( ret == fl.begin() ); + VERIFY( fl.front() == 42 ); +} + +// This test verifies the following: +void +test02() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == 1 ); + + std::forward_list<int>::iterator ret = fl.insert_after(pos, 0, 42); + VERIFY( ret == pos ); + + ret = fl.insert_after(pos, 5, 42); + VERIFY( *pos == 1 ); + + ++pos; + VERIFY( *pos == 42 ); + ++pos; + ++pos; + ++pos; + ++pos; + VERIFY( *pos == 42 ); + VERIFY( ret == pos ); + ++pos; + VERIFY( *pos == 2 ); +} + +// This test verifies the following: +void +test03() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == 1 ); + + int i[3] = {666, 777, 888}; + std::forward_list<int>::iterator ret = fl.insert_after(pos, i, i); + VERIFY( ret == pos ); + + ret = fl.insert_after(pos, i, i + 3); + VERIFY( *pos == 1 ); + + ++pos; + ++pos; + ++pos; + VERIFY( *pos == 888 ); + VERIFY( ret == pos ); + ++pos; + VERIFY( *pos == 2 ); +} + +// This test verifies the following: +void +test04() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == 1 ); + + std::forward_list<int>::iterator ret = fl.insert_after(pos, { }); + VERIFY( ret == pos); + + ret = fl.insert_after(pos, {-1, -2, -3, -4, -5}); + VERIFY( *pos == 1); + + ++pos; + ++pos; + ++pos; + VERIFY( *pos == -3 ); + ++pos; + ++pos; + VERIFY( ret == pos ); + ++pos; + VERIFY( *pos == 2 ); +} + +// This test verifies the following: +void +test05() +{ + std::forward_list<std::string> fl({"AAA", "BBB", "CCC"}); + + std::forward_list<std::string>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == "BBB" ); + + std::string x( "XXX" ); + std::forward_list<std::string>::iterator ret + = fl.insert_after(pos, std::move(x)); + VERIFY( *pos == "BBB" ); + ++pos; + VERIFY( ret == pos ); + VERIFY( *pos == "XXX" ); + ++pos; + VERIFY( *pos == "CCC" ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc new file mode 100644 index 000000000..5f88f5f8e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc @@ -0,0 +1,97 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +// This test verifies the following: +// cbegin +// erase_after one iterator +// pos is useable and points to current element +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == 1 ); + + std::forward_list<int>::iterator pos2 = fl.erase_after(pos); + + VERIFY( *pos == 1 ); + ++pos; + VERIFY( *pos == 3 ); + VERIFY( pos == pos2 ); +} + +// This test verifies the following: +// cbegin +// erase_after iterator range +// pos is useable and points to current element +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY( *pos == 1 ); + + std::forward_list<int>::iterator stop = fl.begin(); + ++stop; + ++stop; + ++stop; + ++stop; + VERIFY( *stop == 4 ); + + std::forward_list<int>::iterator pos2 = fl.erase_after(pos, stop); + + VERIFY( pos2 == stop ); + VERIFY( *pos == 1 ); + ++pos; + VERIFY( *pos == 4 ); + VERIFY( std::distance(fl.begin(), fl.end()) == 8 ); + + std::forward_list<int>::iterator pos3 + = fl.erase_after(pos, fl.end()); + VERIFY( pos3 == fl.end() ); + VERIFY( ++pos == fl.end() ); + VERIFY( std::distance(fl.begin(), fl.end()) == 3 ); + + std::forward_list<int>::iterator pos4 + = fl.erase_after(fl.before_begin(), pos); + VERIFY( pos4 == pos ); + VERIFY( std::distance(fl.begin(), fl.end()) == 0 ); + VERIFY( fl.empty() ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc new file mode 100644 index 000000000..d21fe4c7f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// swap +void +test01() +{ + std::forward_list<int> fl1({0, 1, 2, 3, 4, 5}); + std::forward_list<int> fl2({666, 777, 888}); + + fl1.swap(fl2); + + VERIFY(fl1.front() == 666); + VERIFY(fl2.front() == 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc new file mode 100644 index 000000000..0d8dad515 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// clear +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + VERIFY(fl.empty() == false); + + fl.clear(); + + VERIFY(fl.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc new file mode 100644 index 000000000..e2e9cfbc2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<int> fl1(1, 5), fl2(1, 4), fl3(1, 3), + fl4(1, 2), fl5(1, 1), fl6(1, 0); + + fl1.splice_after(fl1.before_begin(), fl2); + + auto it = fl1.begin(); + + VERIFY( *it == 4 ); + + ++it; + + VERIFY( *it == 5 ); + + fl3.splice_after(fl3.before_begin(), fl4, fl4.before_begin()); + + it = fl3.begin(); + + VERIFY( *it == 2 ); + + ++it; + + VERIFY( *it == 3 ); + + fl5.splice_after(fl5.before_begin(), fl6, fl6.before_begin(), fl6.end()); + + it = fl5.begin(); + + VERIFY( *it == 0 ); + + ++it; + + VERIFY( *it == 1 ); + + fl1.merge(fl2); + + it = fl1.begin(); + + VERIFY( *it == 4 ); + + ++it; + + VERIFY( *it == 5 ); + + fl1.merge(fl3, std::less<int>()); + + it = fl1.begin(); + + VERIFY( *it == 2 ); + + ++it; + + VERIFY( *it == 3 ); + + ++it; + + VERIFY( *it == 4 ); + + ++it; + + VERIFY( *it == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc new file mode 100644 index 000000000..dca3394da --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + + std::forward_list<double> x = {666.0, 777.0, 888.0}; + + a.splice_after(posa, std::move(x)); + + ++posa; + VERIFY(*posa == 666.0); + + VERIFY(x.empty() == true); +} + +// This test verifies the following: +// +void +test02() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + VERIFY(*posa == 0.0); + + std::forward_list<double> y = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0}; + std::forward_list<double>::const_iterator befy = y.cbefore_begin(); + ++befy; + VERIFY(*befy == 10.0); + std::forward_list<double>::const_iterator endy = befy; + ++endy; + ++endy; + ++endy; + ++endy; + VERIFY(*endy == 14.0); + + a.splice_after(posa, std::move(y), befy, endy); + VERIFY(*posa == 0.0); + + VERIFY(*befy == 10.0); + ++befy; + VERIFY(*befy == 14.0); +} + +// This test verifies the following: +// +void +test03() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + ++posa; + VERIFY(*posa == 1.0); + + std::forward_list<double> z = {42.0, 43.0, 44.0}; + std::forward_list<double>::const_iterator posz = z.begin(); + VERIFY(*posz == 42.0); + + a.splice_after(posa, std::move(z), posz); + VERIFY(*posa == 1.0); + ++posa; + VERIFY(*posa == 43.0); + + VERIFY(*posz == 42.0); + ++posz; + VERIFY(*posz == 44.0); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc new file mode 100644 index 000000000..9f4d33fb5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove(7); + + std::forward_list<int>::const_iterator pos = fl.cbefore_begin(); + for (std::size_t i = 0; i < 7; ++i) + ++pos; + VERIFY(*pos == 6); + + ++pos; + VERIFY(*pos == 8); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc new file mode 100644 index 000000000..b0be679aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove_if +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove_if(std::bind2nd(std::less<int>(),5)); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + VERIFY(*pos == 5); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc new file mode 100644 index 000000000..297ee69fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// unique +void +test01() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, + 42, 42, 42, 42, 42, 7, 0, 0, 0, 9, 9, 9}; + + fl.unique(); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +// Test comparison predicate. +template<typename Num> + class Mod + { + public: + Mod(const Num & mod) + { + m = mod; + } + bool operator()(const Num i, const Num j) + { + return i%m == j%m; + } + private: + Num m; + }; + +// This test verifies the following: +// unique with predicate +void +test02() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + + fl.unique(Mod<int>(111)); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc new file mode 100644 index 000000000..5a0277208 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0}; + + a.merge(std::move(b)); + + std::forward_list<double> r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, + 4.0, 4.0, 4.0, 5.0}; + + VERIFY(a == r); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc new file mode 100644 index 000000000..551d8fe93 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc @@ -0,0 +1,83 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// Comparison functor. +template<typename Num> + class Comp + { + public: + Comp(const Num & num) + { + n = num; + } + bool operator()(const Num i, const Num j) + { + return (n * i) < (n * j); + } + private: + Num n; + }; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[][n] = { + { 0,1,2,3,4,5,6,7,8,9,10,11,12 }, + { 6,2,8,4,11,1,12,7,3,9,5,0,10 }, + { 12,11,10,9,8,7,6,5,4,3,2,1,0 }, + }; + std::forward_list<int> sorted(order[0], order[0] + n); + + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + head.sort(); + + VERIFY(head == sorted); + } + + std::forward_list<int> reversed(order[2], order[2] + n); + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + Comp<int> comp(-1); + head.sort( comp ); + + VERIFY(head == reversed); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc new file mode 100644 index 000000000..07faee159 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[n] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; + + std::forward_list<int> fl(order, order + n); + + std::forward_list<int> fl2; + for (std::size_t i = 0; i < n; ++i) + fl2.push_front(order[i]); + + fl.reverse(); + + VERIFY(std::lexicographical_compare(fl.begin(), fl.end(), + fl2.begin(), fl2.end()) == false); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/remove_freed.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/remove_freed.cc new file mode 100644 index 000000000..528623b0f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/operations/remove_freed.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-08-11 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_hooks.h> + +// 23.3.3.5 forward_list operations [forwardlist.ops] + +// Used to cause many Valgrind errors: LWG 526-type situation. +void test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_list<int> fl1; + + fl1.push_front(1); + fl1.push_front(2); + fl1.push_front(3); + fl1.push_front(4); + fl1.push_front(1); + + fl1.remove(*fl1.begin()); + + VERIFY( std::distance(fl1.begin(), fl1.end()) == 3 ); + + auto it1 = fl1.begin(); + + VERIFY( *it1 == 4 ); + ++it1; + VERIFY( *it1 == 3 ); + ++it1; + VERIFY( *it1 == 2 ); + + std::forward_list<int> fl2; + + fl2.push_front(3); + fl2.push_front(3); + fl2.push_front(3); + fl2.push_front(3); + fl2.push_front(3); + + auto it2 = fl2.begin(); + ++it2; + ++it2; + + fl2.remove(*it2); + + VERIFY( std::distance(fl2.begin(), fl2.end()) == 0 ); + + std::forward_list<int> fl3; + + fl3.push_front(1); + fl3.push_front(2); + fl3.push_front(3); + fl3.push_front(3); + fl3.push_front(3); + + auto it3 = fl3.begin(); + ++it3; + ++it3; + + fl3.remove(*it3); + + VERIFY( std::distance(fl3.begin(), fl3.end()) == 2 ); + + it3 = fl3.begin(); + VERIFY( *it3 == 2 ); + ++it3; + VERIFY( *it3 == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc new file mode 100644 index 000000000..0bd0030a5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <forward_list> + +void +test01() +{ + std::forward_list<int> fl{1, 2, 3}; + std::begin(fl); + std::end(fl); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/citerators.cc new file mode 100644 index 000000000..670c2dd4c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/citerators.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <testsuite_containers.h> + +namespace __gnu_test +{ + template<> + struct populate<std::forward_list<int>, true> + { + populate(std::forward_list<int>& container) + { + container.push_front(1); + container.push_front(2); + } + }; +} + +int main() +{ + typedef std::forward_list<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/do_the_right_thing.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/do_the_right_thing.cc new file mode 100644 index 000000000..04d73bb7e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/do_the_right_thing.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +// libstdc++/43813 +void test01() +{ + std::forward_list<double*> fl(7, 0); + fl.assign(7, 0); + fl.insert_after(fl.before_begin(), 7, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..5b21c1621 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-error "no matching" "" { target *-*-* } 33 } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::forward_list<A> test_type; + test_type l; + l.assign(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor.cc new file mode 100644 index 000000000..5eadac546 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void f() +{ + typedef std::forward_list<int> test_type; + test_type l(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..749a0faad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-error "no matching" "" { target *-*-* } 27 } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +void f() +{ + typedef std::forward_list<std::forward_list<int> > test_type; + test_type l(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..6b3e8be70 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-error "no matching" "" { target *-*-* } 28 } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <utility> + +void f() +{ + typedef std::forward_list<std::forward_list<std::pair<char, char> > > test_type; + test_type l('a', 'b'); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..e085540a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-error "no matching" "" { target *-*-* } 33 } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::forward_list<A> test_type; + test_type l; + l.insert_after(l.begin(), 10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/basic.cc new file mode 100644 index 000000000..83ffa4e1b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/basic.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::forward_list<value_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..0df4502a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/generation_prohibited.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::forward_list<value_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..91129e514 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/exception/propagation_consistent.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::forward_list<value_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..3d0afbc10 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <forward_list> + +// { dg-do compile } + +template class std::forward_list<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..2409b144d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <forward_list> + +// { dg-do compile } + +// libstdc++/21770 +template class std::forward_list<int, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..2a6fbb0e9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/4.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <forward_list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::forward_list<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..3616e3609 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/5.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <forward_list> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::forward_list<int, __gnu_test::ExplicitConsAlloc<int>>; +template class std::forward_list<int, __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/typedefs.cc new file mode 100644 index 000000000..5192d4e25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/forward_list/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <forward_list> + +// Check container for required typedefs. +__gnu_test::types<std::forward_list<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc new file mode 100644 index 000000000..461f9001c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <array> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc new file mode 100644 index 000000000..d5a5dc8dc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <bitset> + +namespace std { + template <size_t N> class bitset; + + // 23.3.5.3 bitset operations: + template <size_t N> + bitset<N> operator&(const bitset<N>&, const bitset<N>&); + + template <size_t N> + bitset<N> operator|(const bitset<N>&, const bitset<N>&); + + template <size_t N> + bitset<N> operator^(const bitset<N>&, const bitset<N>&); + + template <class charT, class traits, size_t N> + basic_istream<charT, traits>& + operator>>(basic_istream<charT, traits>& is, bitset<N>& x); + + template <class charT, class traits, size_t N> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc new file mode 100644 index 000000000..6ca18e761 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <deque> + +namespace std { + template <class T, class Allocator> class deque; + + template <class T, class Allocator> + bool operator== (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + bool operator!= (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + bool operator>= (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + bool operator<= (const deque<T,Allocator>& x, const deque<T,Allocator>& y); + + template <class T, class Allocator> + void swap(deque<T,Allocator>& x, deque<T,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc new file mode 100644 index 000000000..967894f2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <forward_list> + +namespace std { + template <class T, class Allocator> class forward_list; + + template <class T, class Allocator> + bool operator==(const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator< (const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator!=(const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator> (const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator>=(const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator<=(const forward_list<T,Allocator>& x, + const forward_list<T,Allocator>&); + + template <class T, class Allocator> + void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc new file mode 100644 index 000000000..dc9330b9f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +namespace std { + template <class T, class Allocator> class list; + + template <class T, class Allocator> + bool operator==(const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + bool operator< (const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + bool operator!=(const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + bool operator> (const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + bool operator>=(const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>&); + + template <class T, class Allocator> + void swap(list<T,Allocator>& x, list<T,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc new file mode 100644 index 000000000..16cba7733 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc @@ -0,0 +1,71 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> + +namespace std { + template <class Key, class T, class Compare, class Allocator> + class map; + template <class Key, class T, class Compare, class Allocator> + bool operator==(const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator< (const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator!=(const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator> (const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator>=(const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator<=(const map<Key,T,Compare,Allocator>& x, + const map<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + void swap(map<Key,T,Compare,Allocator>& x, + map<Key,T,Compare,Allocator>& y); + + template <class Key, class T, class Compare, class Allocator> + class multimap; + template <class Key, class T, class Compare, class Allocator> + bool operator==(const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator< (const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator!=(const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator> (const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator>=(const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + bool operator<=(const multimap<Key,T,Compare,Allocator>& x, + const multimap<Key,T,Compare,Allocator>& y); + template <class Key, class T, class Compare, class Allocator> + void swap(multimap<Key,T,Compare,Allocator>& x, + multimap<Key,T,Compare,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc new file mode 100644 index 000000000..f53f50ac9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc @@ -0,0 +1,50 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <queue> + +namespace std { + template <class T, class Container> class queue; + template <class T, class Container> + bool operator==(const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container> + bool operator< (const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container> + bool operator!=(const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container> + bool operator> (const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container> + bool operator>=(const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container> + bool operator<=(const queue<T, Container>& x, + const queue<T, Container>& y); + + template <class T, class Container, class Compare> + class priority_queue; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc new file mode 100644 index 000000000..58ae23fee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc @@ -0,0 +1,85 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> + +namespace std { + template <class Key, class Compare, class Allocator> + class set; + + template <class Key, class Compare, class Allocator> + bool operator==(const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator< (const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator!=(const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator> (const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator>=(const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator<=(const set<Key,Compare,Allocator>& x, + const set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + void swap(set<Key,Compare,Allocator>& x, + set<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + class multiset; + + template <class Key, class Compare, class Allocator> + bool operator==(const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator< (const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator!=(const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator> (const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator>=(const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + bool operator<=(const multiset<Key,Compare,Allocator>& x, + const multiset<Key,Compare,Allocator>& y); + + template <class Key, class Compare, class Allocator> + void swap(multiset<Key,Compare,Allocator>& x, + multiset<Key,Compare,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/stack/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/stack/synopsis.cc new file mode 100644 index 000000000..3493efd32 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/stack/synopsis.cc @@ -0,0 +1,48 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <stack> + +namespace std { + template <class T, class Container> class stack; + + template <class T, class Container> + bool operator==(const stack<T, Container>& x, + const stack<T, Container>& y); + + template <class T, class Container> + bool operator< (const stack<T, Container>& x, + const stack<T, Container>& y); + + template <class T, class Container> + bool operator!=(const stack<T, Container>& x, + const stack<T, Container>& y); + + template <class T, class Container> + bool operator> (const stack<T, Container>& x, + const stack<T, Container>& y); + + template <class T, class Container> + bool operator>=(const stack<T, Container>& x, + const stack<T, Container>& y); + + template <class T, class Container> + bool operator<=(const stack<T, Container>& x, + const stack<T, Container>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc new file mode 100644 index 000000000..0bf95bfff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/types_std_c++0x.cc new file mode 100644 index 000000000..a2a8121f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/tuple/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +namespace gnu +{ + using std::ignore; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc new file mode 100644 index 000000000..7b39118fa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc new file mode 100644 index 000000000..773f98a05 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc new file mode 100644 index 000000000..a8ffc4d38 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc @@ -0,0 +1,81 @@ +// { dg-do compile } +// { dg-require-normal-mode "" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +namespace std { + template <class T, class Allocator> class vector; + + template <class T, class Allocator> + bool operator==(const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + bool operator< (const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + bool operator!=(const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + bool operator> (const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + bool operator>=(const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + bool operator<=(const vector<T,Allocator>& x, + const vector<T,Allocator>& y); + + template <class T, class Allocator> + void swap(vector<T,Allocator>& x, vector<T,Allocator>& y); + + template <class Allocator> class vector<bool,Allocator>; + + template <class Allocator> + bool operator==(const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + bool operator< (const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + bool operator!=(const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + bool operator> (const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + bool operator>=(const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + bool operator<=(const vector<bool,Allocator>& x, + const vector<bool,Allocator>& y); + + template <class Allocator> + void swap(vector<bool,Allocator>& x, vector<bool,Allocator>& y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/14340.cc new file mode 100644 index 000000000..ba9bf4161 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <list> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::list<int> list_type; + __gnu_test::conversion<list_type>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/18604.cc new file mode 100644 index 000000000..4eb8b3321 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/18604.cc @@ -0,0 +1,41 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <list> diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc new file mode 100644 index 000000000..b964123b1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc @@ -0,0 +1,29 @@ +// 2005-09-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +// libstdc++/23781 +#include <list> +#include <cstddef> + +typedef std::list<int> list_type; +list_type::iterator it = NULL; // { dg-error "conversion" } +list_type::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/58764.cc new file mode 100644 index 000000000..c523e0276 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <list> + +void test01() +{ + std::list<int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc new file mode 100644 index 000000000..f64a054f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "1.h" +#include <list> + +int +main() +{ + capacity01<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.h new file mode 100644 index 000000000..faa8b4d26 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/1.h @@ -0,0 +1,61 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.2 list capacity [lib.list.capacity] + +#include <testsuite_hooks.h> + +// This test verifies the following. +// +// 23.2.2 bool empty() const +// 23.2.2 size_type size() const +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2.3 void push_back(const T&) +// 23.2.2 size_type max_size() const +// 23.2.2.2 void resize(size_type s, T c = T()) +// +template<typename _Tp> +void +capacity01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator_type; + + list_type list0101; + VERIFY(list0101.empty()); + VERIFY(list0101.size() == 0); + + list0101.push_back(1); + VERIFY(!list0101.empty()); + VERIFY(list0101.size() == 1); + + list0101.resize(3, 2); + VERIFY(!list0101.empty()); + VERIFY(list0101.size() == 3); + + iterator_type i = list0101.begin(); + VERIFY(*i == 1); ++i; + VERIFY(*i == 2); ++i; + VERIFY(*i == 2); ++i; + VERIFY(i == list0101.end()); + + list0101.resize(0); + VERIFY(list0101.empty()); + VERIFY(list0101.size() == 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc new file mode 100644 index 000000000..b2c18d427 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.2 list capacity [lib.list.capacity] + +#include <list> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::list<int> list_type; + list_type l; + +#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE + using std::_List_node; +#else + using std::_GLIBCXX_STD_C::_List_node; +#endif + + VERIFY( l.max_size() == std::allocator<_List_node<int> >().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc new file mode 100644 index 000000000..ecb349425 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<__gnu_test::NonCopyConstructible> l; + VERIFY( std::distance(l.begin(), l.end()) == 0 ); + + l.resize(1000); + VERIFY( std::distance(l.begin(), l.end()) == 1000 ); + for(auto it = l.begin(); it != l.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc new file mode 100644 index 000000000..cb43691ff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc @@ -0,0 +1,29 @@ +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include "check_construct_destroy.h" +#include <list> + +int main() +{ + typedef __gnu_test::tracker_allocator<int> allocator_type; + construct_destroy<std::list<int, allocator_type> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h new file mode 100644 index 000000000..7efb97cc0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h @@ -0,0 +1,79 @@ +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <iterator> +#include <testsuite_allocator.h> + +template<typename _Tp> +bool +construct_destroy() +{ + typedef _Tp list_type; + typedef typename list_type::iterator iterator_type; + + using namespace __gnu_test; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + list_type c; + ok = check_construct_destroy("empty container", 0, 0) && ok; + } + ok = check_construct_destroy("empty container", 0, 0) && ok; + + + tracker_allocator_counter::reset(); + { + list_type c(arr10, arr10 + 10); + ok = check_construct_destroy("Construct from range", 10, 0) && ok; + } + ok = check_construct_destroy("Construct from range", 10, 10) && ok; + + { + list_type 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; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator_type i5 = c.begin(); + std::advance(i5, 5); + c.insert(i5, arr10, arr10+3); + ok = check_construct_destroy("Insert short range", 3, 0) && ok; + } + ok = check_construct_destroy("Insert short range", 3, 13) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator_type i7 = c.begin(); + std::advance(i7, 5); + c.insert(i7, 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.cc new file mode 100644 index 000000000..f82db468c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "1.h" +#include <list> + +int main() +{ + cons01<std::list< A<B> > >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.h new file mode 100644 index 000000000..f936ca43b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/1.h @@ -0,0 +1,63 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// A nontrivial type. +template<typename T> + struct A { }; + +// Another nontrivial type +struct B { }; + +// Default constructor, basic properties +// +// This test verifies the following. +// 23.2.2.1 explicit list(const a& = Allocator()) +// 23.1 (7) iterator behaviour of empty containers +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 existence of required typedefs +// +template<typename _Tp> +void +cons01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type list0101; + VERIFY(list0101.begin() == list0101.end()); + VERIFY(list0101.size() == 0); + + // check type definitions -- will fail compile if missing + typedef typename list_type::reference reference; + typedef typename list_type::const_reference const_reference; + typedef typename list_type::iterator iterator; + typedef typename list_type::const_iterator const_iterator; + typedef typename list_type::size_type size_type; + typedef typename list_type::difference_type difference_type; + typedef typename list_type::value_type value_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::pointer pointer; + typedef typename list_type::const_pointer const_pointer; + typedef typename list_type::reverse_iterator reverse_iterator; + typedef typename list_type::const_reverse_iterator const_reverse_iterator; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.cc new file mode 100644 index 000000000..29304c2ca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "2.h" +#include <list> + +int main() +{ + cons021<std::list<int> >(); + cons022<std::list< A<B> > >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.h new file mode 100644 index 000000000..ff2ace734 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/2.h @@ -0,0 +1,77 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// A nontrivial type. +template<typename T> + struct A { }; + +// Another nontrivial type +struct B { }; + +// Fill constructor +// +// This test verifies the following. +// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template<typename _Tp> +void +cons021() +{ + bool test __attribute__((unused)) = true; + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + // default value + list_type list0202(LIST_SIZE); + for (i = list0202.begin(), count = 0; + i != list0202.end(); + ++i, ++count) + VERIFY(*i == 0); + VERIFY(count == LIST_SIZE); + VERIFY(list0202.size() == LIST_SIZE); + + // explicit value + list_type list0203(LIST_SIZE, INIT_VALUE); + for (i = list0203.begin(), count = 0; + i != list0203.end(); + ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0203.size() == LIST_SIZE); +} + +template<typename _Tp> +void +cons022() +{ + // nontrivial value_type + typedef _Tp list_type; + const std::size_t LIST_SIZE = 5; + list_type list0201(LIST_SIZE); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.cc new file mode 100644 index 000000000..a2435b6ad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "3.h" +#include <list> + +int main() +{ + cons03<std::list<C> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.h new file mode 100644 index 000000000..c4bcda9d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/3.h @@ -0,0 +1,48 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill constructor disguised as a range constructor +template<typename _Tp> +void +cons03() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count = 0; + list_type list0204(LIST_SIZE, INIT_VALUE); + iterator i = list0204.begin(); + for (; i != list0204.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0204.size() == LIST_SIZE); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.cc new file mode 100644 index 000000000..516c4de5a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "4.h" +#include <list> + +int main() +{ + cons04<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.h new file mode 100644 index 000000000..7502f7c9c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/4.h @@ -0,0 +1,61 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// Range constructor +// +// This test verifies the following. +// 23.2.2.1 template list(InputIterator f, InputIterator l, +// const Allocator& a = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template<typename _Tp> +void +cons04() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const std::size_t N = sizeof(A) / sizeof(int); + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + // construct from a dissimilar range + list_type list0301(A, A + N); + for (i = list0301.begin(), count = 0; + i != list0301.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0301.size() == N); + + // construct from a similar range + list_type list0302(list0301.begin(), list0301.end()); + for (i = list0302.begin(), count = 0; + i != list0302.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0302.size() == N); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.cc new file mode 100644 index 000000000..ff1925f92 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "5.h" +#include <list> + +int main() +{ + cons05<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.h new file mode 100644 index 000000000..87c85f349 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/5.h @@ -0,0 +1,51 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// Copy constructor +// +// This test verifies the following. +// 23.2.2.1 list(const list& x) +// 23.2.2 reverse_iterator rbegin() +// 23.2.2 reverse_iterator rend() +// 23.2.2 size_type size() const +// +template<typename _Tp> +void +cons05() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const std::size_t N = sizeof(A) / sizeof(int); + int count; + + typedef _Tp list_type; + typedef typename list_type::reverse_iterator reverse_iterator; + reverse_iterator i; + list_type list0401(A, A + N); + + list_type list0402(list0401); + for (i = list0401.rbegin(), count = N - 1; + i != list0401.rend(); + ++i, --count) + VERIFY(*i == A[count]); + VERIFY(count == -1); + VERIFY(list0401.size() == N); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc new file mode 100644 index 000000000..8a6420b46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +struct A +{ + A(int) { } + A(const A&) = delete; + A& operator=(const A&) = delete; +}; + +void foo() +{ + int i[] = {1, 2}; + std::list<A> li(i, i + 2); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.cc new file mode 100644 index 000000000..0d2b6f98f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "6.h" +#include <list> + +int main() +{ + cons06<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.h new file mode 100644 index 000000000..d523f637d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/6.h @@ -0,0 +1,64 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// Range assign +// +// This test verifies the following. +// 23.2.2.1 void assign(InputIterator f, InputIterator l) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template<typename _Tp> +void +cons06() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {101, 102, 103, 104, 105}; + const std::size_t N = sizeof(A) / sizeof(int); + const std::size_t M = sizeof(B) / sizeof(int); + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + list_type list0501; + + // make it bigger + list0501.assign(A, A + N); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0501.size() == N); + + // make it smaller + list0501.assign(B, B + M); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == B[count]); + VERIFY(count == M); + VERIFY(list0501.size() == M); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.cc new file mode 100644 index 000000000..8b9b84bc3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "7.h" +#include <list> + +int main() +{ + cons07<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.h new file mode 100644 index 000000000..50ceeec61 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/7.h @@ -0,0 +1,65 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// Fill assign +// +// This test verifies the following. +// 23.2.2.1 void assign(size_type n, const T& v) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template<typename _Tp> +void +cons07() +{ + bool test __attribute__((unused)) = true; + const std::size_t BIG_LIST_SIZE = 11; + const int BIG_INIT_VALUE = 7; + const std::size_t SMALL_LIST_SIZE = 5; + const int SMALL_INIT_VALUE = 17; + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + list_type list0601; + VERIFY(list0601.size() == 0); + + // make it bigger + list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == BIG_INIT_VALUE); + VERIFY(count == BIG_LIST_SIZE); + VERIFY(list0601.size() == BIG_LIST_SIZE); + + // make it shrink + list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == SMALL_INIT_VALUE); + VERIFY(count == SMALL_LIST_SIZE); + VERIFY(list0601.size() == SMALL_LIST_SIZE); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.cc new file mode 100644 index 000000000..34c1636a2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "8.h" +#include <list> + +int main() +{ + cons08<std::list<C> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.h new file mode 100644 index 000000000..2df9ddf29 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/8.h @@ -0,0 +1,51 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill Assignment disguised as a Range Assignment +template<typename _Tp> +void +cons08() +{ + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + bool test __attribute__((unused)) = true; + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count = 0; + + list_type list0604; + VERIFY(list0604.size() == 0); + + list0604.assign(LIST_SIZE, INIT_VALUE); + iterator i = list0604.begin(); + for (; i != list0604.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0604.size() == LIST_SIZE); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.cc new file mode 100644 index 000000000..dfc21b3e2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "9.h" +#include <list> + +int main() +{ + cons09<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.h new file mode 100644 index 000000000..7458751bc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/9.h @@ -0,0 +1,59 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.1 list constructors, copy, and assignment + +#include <testsuite_hooks.h> + +// Assignment operator +// +// This test verifies the following. +// 23.2.2 operator=(const list& x) +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 bool operator==(const list& x, const list& y) +// +template<typename _Tp> +void +cons09() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {701, 702, 703, 704, 705}; + const std::size_t N = sizeof(A) / sizeof(int); + std::size_t count; + + iterator i; + + list_type list0701(A, A + N); + VERIFY(list0701.size() == N); + + list_type list0702; + VERIFY(list0702.size() == 0); + + list0702 = list0701; + VERIFY(list0702.size() == N); + for (i = list0702.begin(), count = 0; + i != list0702.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0702 == list0701); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc new file mode 100644 index 000000000..5a901c889 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "clear_allocator.h" +#include <list> + +int main() +{ + typedef std::list<int, clear_alloc<int> > list_type; + Check_Container<list_type>(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h new file mode 100644 index 000000000..0cc73eba4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h @@ -0,0 +1,78 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator<T>() + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + 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; + } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc new file mode 100644 index 000000000..2bd271334 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<__gnu_test::NonCopyConstructible> l(1000); + VERIFY( std::distance(l.begin(), l.end()) == 1000 ); + for(auto it = l.begin(); it != l.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc new file mode 100644 index 000000000..fc2eaa01e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "moveable.h" +#include <list> + +int main() +{ + test_moveable<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h new file mode 100644 index 000000000..9b23850ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h @@ -0,0 +1,41 @@ +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <utility> +#include <testsuite_hooks.h> + +template<typename _Tp> + void + test_moveable() + { + bool test __attribute__((unused)) = true; + + typedef _Tp list_type; + + list_type a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 ); + + list_type c(std::move(b)); + VERIFY( c.size() == 1 && *c.begin() == 1 ); + VERIFY( b.size() == 0 ); + } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..d02ce5a22 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +typedef std::list<int> ltype; + +static_assert(std::is_nothrow_move_constructible<ltype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc new file mode 100644 index 000000000..2212af983 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc new file mode 100644 index 000000000..d64311eb7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign2<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc new file mode 100644 index 000000000..0f976e39b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign3<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc new file mode 100644 index 000000000..0f4c5b7ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc new file mode 100644 index 000000000..ddfc1833c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc new file mode 100644 index 000000000..d76ac8b2e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc new file mode 100644 index 000000000..0de3ff4cd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc new file mode 100644 index 000000000..199b1be08 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc new file mode 100644 index 000000000..79ae79ce7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc new file mode 100644 index 000000000..619f37fae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc new file mode 100644 index 000000000..df09c4083 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc new file mode 100644 index 000000000..076745fa0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc new file mode 100644 index 000000000..41fddb16f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } +// { dg-do run { xfail *-*-* } } + +#include <list> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert4<std::list<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc new file mode 100644 index 000000000..15a89f842 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc @@ -0,0 +1,59 @@ +// List iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/list> +#include <iterator> +#include <testsuite_hooks.h> + +// Assignment +void test01() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list<int> list_type; + list_type v1; + list_type v2; + + v1.push_front(17); + + list_type::iterator start = v1.begin(); + list_type::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + finish = v1.end(); + v1.assign(v2.begin(), v2.end()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + finish = v1.end(); + v1.assign(17, 42); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc new file mode 100644 index 000000000..07ae78734 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc @@ -0,0 +1,55 @@ +// List iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/list> +#include <iterator> +#include <testsuite_hooks.h> + +// Resize +void test02() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list<int> list_type; + + list_type v(10, 17); + + list_type::iterator before = v.begin(); + advance(before, 6); + list_type::iterator at = before; + advance(at, 1); + list_type::iterator after = at; + advance(after, 1); + list_type::iterator finish = v.end(); + + // Shrink + v.resize(7); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc new file mode 100644 index 000000000..67c524cec --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc @@ -0,0 +1,77 @@ +// List iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/list> +#include <iterator> +#include <testsuite_hooks.h> + +// Erase +void test03() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + typedef __gnu_debug::list<int> list_type; + + list_type v(20, 42); + + // Single element erase (middle) + list_type::iterator before = v.begin(); + list_type::iterator at = before; + advance(at, 3); + list_type::iterator after = at; + at = v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Single element erase (end) + before = v.begin(); + at = before; + after = at; + ++after; + at = v.erase(at); + VERIFY(before._M_singular()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 3); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + list_type::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc new file mode 100644 index 000000000..f8e2577bc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc @@ -0,0 +1,55 @@ +// List iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/list> +#include <iterator> +#include <testsuite_hooks.h> + +// Splice +void test04() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list<int> list_type; + + list_type l1(10, 17); + list_type l2(10, 42); + + list_type::iterator start2 = l2.begin(); + list_type::iterator end2 = start2; + advance(end2, 5); + list_type::iterator after2 = end2; + advance(after2, 2); + + l1.splice(l1.begin(), l2, start2, end2); + VERIFY(start2._M_dereferenceable()); + VERIFY(end2._M_dereferenceable()); + VERIFY(after2._M_dereferenceable()); + VERIFY(start2._M_attached_to(&l1)); + VERIFY(end2._M_attached_to(&l2)); + VERIFY(after2._M_attached_to(&l2)); +} + +int main() +{ + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..675f6586f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <list> + +void test01() +{ + std::list<int> l1; + auto it1 = l1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..209990e99 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <list> + +void test01() +{ + std::list<int> l1; + l1 = std::move(l1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.cc new file mode 100644 index 000000000..61b6fd693 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include "init-list.h" +#include <list> + +int main() +{ + typedef int value_type; + typedef __gnu_test::tracker_allocator<int> allocator_type; + typedef std::list<value_type, allocator_type> list_type; + init_list<list_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.h new file mode 100644 index 000000000..954e58047 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/init-list.h @@ -0,0 +1,65 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <testsuite_allocator.h> + +template<typename _Tp> +bool +init_list() +{ + using namespace __gnu_test; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + list_type c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + iterator i = c.begin(); + ok &= (*i++ == 2); + ok &= (*i++ == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator i = c.begin(); + ++i; ++i; ++i; ++i; ++i; ++i; ++i; + c.insert(i, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 3, 0) && ok; + ok &= (*--i == 1); + ok &= (*--i == 42); + } + ok = check_construct_destroy("Insert init-list", 3, 13) && ok; + + { + list_type c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + iterator i = c.begin(); + ok &= (*i++ == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc new file mode 100644 index 000000000..e02e7857f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "1.h" +#include <list> + +int main() +{ + modifiers1<std::list<__gnu_test::copy_tracker> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h new file mode 100644 index 000000000..8e7a61d04 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h @@ -0,0 +1,128 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include <testsuite_hooks.h> + +// range and fill insert/erase + clear +// missing: o fill insert disguised as a range insert in all its variants +// o exception effects +template<typename _Tp> +void +modifiers1() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::value_type value_type; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0301; + value_type::reset(); + + // fill insert at beginning of list / empty list + list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11] + VERIFY(list0301.size() == 3); + VERIFY(copy_constructor::count() == 3); + + // save iterators to verify post-insert validity + iterator b = list0301.begin(); + iterator m = list0301.end(); --m; + iterator e = list0301.end(); + + // fill insert at end of list + value_type::reset(); + list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13] + VERIFY(list0301.size() == 6); + VERIFY(copy_constructor::count() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 11); + + // fill insert in the middle of list + ++m; + value_type::reset(); + list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13] + VERIFY(list0301.size() == 9); + VERIFY(copy_constructor::count() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // single erase + value_type::reset(); + m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13] + VERIFY(list0301.size() == 8); + VERIFY(destructor::count() == 1); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range erase + value_type::reset(); + m = list0301.erase(list0301.begin(), m); // should be [13 13] + VERIFY(list0301.size() == 2); + VERIFY(destructor::count() == 6); + VERIFY(m->id() == 13); + + // range fill at beginning + const int A[] = {321, 322, 333}; + const int N = sizeof(A) / sizeof(int); + value_type::reset(); + b = list0301.begin(); + list0301.insert(b, A, A + N); // should be [321 322 333 13 13] + VERIFY(list0301.size() == 5); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else + VERIFY(copy_constructor::count() == 3); +#endif + VERIFY(m->id() == 13); + + // range fill at end + value_type::reset(); + list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] + VERIFY(list0301.size() == 8); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else + VERIFY(copy_constructor::count() == 3); +#endif + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range fill in middle + value_type::reset(); + list0301.insert(m, A, A + N); + VERIFY(list0301.size() == 11); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else + VERIFY(copy_constructor::count() == 3); +#endif + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + value_type::reset(); + list0301.clear(); + VERIFY(list0301.size() == 0); + VERIFY(destructor::count() == 11); + VERIFY(e == list0301.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc new file mode 100644 index 000000000..41d508eb5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "1.h" +#include <list> + +int main() +{ + modifiers1<std::list<__gnu_test::copy_tracker> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc new file mode 100644 index 000000000..ace9ea834 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "2.h" +#include <list> + +int main() +{ + modifiers2<std::list<__gnu_test::copy_tracker> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h new file mode 100644 index 000000000..0c703415f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h @@ -0,0 +1,89 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include <testsuite_hooks.h> + +// general single insert/erase + swap +template<typename _Tp> +void +modifiers2() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::value_type value_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::const_iterator const_iterator; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0201; + value_type::reset(); + + list0201.insert(list0201.begin(), value_type(1)); // list should be [1] + VERIFY(list0201.size() == 1); + VERIFY(copy_constructor::count() == 1); + + list0201.insert(list0201.end(), value_type(2)); // list should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(copy_constructor::count() == 2); + + iterator i = list0201.begin(); + const_iterator j = i; + VERIFY(i->id() == 1); ++i; + VERIFY(i->id() == 2); + + list0201.insert(i, value_type(3)); // list should be [1 3 2] + VERIFY(list0201.size() == 3); + VERIFY(copy_constructor::count() == 3); + + const_iterator k = i; + VERIFY(i->id() == 2); --i; + VERIFY(i->id() == 3); --i; + VERIFY(i->id() == 1); + VERIFY(j->id() == 1); + + ++i; // will point to '3' + value_type::reset(); + list0201.erase(i); // should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(destructor::count() == 1); + VERIFY(k->id() == 2); + VERIFY(j->id() == 1); + + list_type list0202; + value_type::reset(); + VERIFY(list0202.size() == 0); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); + + // member swap + list0202.swap(list0201); + VERIFY(list0201.size() == 0); + VERIFY(list0202.size() == 2); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); + + // specialized swap + swap(list0201, list0202); + VERIFY(list0201.size() == 2); + VERIFY(list0202.size() == 0); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc new file mode 100644 index 000000000..42d4cf680 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "3.h" +#include <list> + +int main() +{ + modifiers3<std::list<__gnu_test::copy_tracker> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h new file mode 100644 index 000000000..c3ba5484b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h @@ -0,0 +1,121 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include <testsuite_hooks.h> + +// This test verifies the following. +// +// 23.2.2.3 void push_front(const T& x) +// 23.2.2.3 void push_back(const T& x) +// 23.2.2.3 (1) iterator and reference non-invalidation +// 23.2.2.3 (1) exception effects +// 23.2.2.3 (2) complexity requirements +// +// 23.2.2.3 void pop_front() +// 23.2.2.3 void pop_back() +// 23.2.2.3 (3) iterator and reference non-invalidation +// 23.2.2.3 (5) complexity requirements +// +// 23.2.2 const_iterator begin() const +// 23.2.2 iterator end() +// 23.2.2 const_reverse_iterator rbegin() const +// 23.2.2 _reference front() +// 23.2.2 const_reference front() const +// 23.2.2 reference back() +// 23.2.2 const_reference back() const +// +template<typename _Tp> +void +modifiers3() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::value_type value_type; + typedef typename list_type::const_iterator const_iterator; + typedef typename list_type::const_reverse_iterator const_reverse_iterator; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0101; + const_iterator i; + const_reverse_iterator j; + iterator k; + value_type::reset(); + + list0101.push_back(value_type(1)); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(copy_constructor::count() == 1); + + k = list0101.end(); + --k; + VERIFY(k->id() == 1); + VERIFY(k->id() == list0101.front().id()); + VERIFY(k->id() == list0101.back().id()); + + list0101.push_front(value_type(2)); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(copy_constructor::count() == 2); + VERIFY(k->id() == 1); + + list0101.push_back(value_type(3)); // list should be [2 1 3] + VERIFY(list0101.size() == 3); + VERIFY(copy_constructor::count() == 3); + VERIFY(k->id() == 1); + + try + { + list0101.push_back(value_type(4, true)); + VERIFY(false); + } + catch (...) + { + VERIFY(list0101.size() == 3); + VERIFY(copy_constructor::count() == 4); + } + + i = list0101.begin(); + VERIFY(i->id() == 2); + VERIFY(i->id() == list0101.front().id()); + + j = list0101.rbegin(); + VERIFY(j->id() == 3); + VERIFY(j->id() == list0101.back().id()); + + ++i; + VERIFY(i->id() == 1); + + ++j; + VERIFY(j->id() == 1); + + value_type::reset(); + + list0101.pop_back(); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(destructor::count() == 1); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); + + list0101.pop_front(); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(destructor::count() == 2); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/52799.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/52799.cc new file mode 100644 index 000000000..519612a0a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/52799.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +// libstdc++/52799 +int main() +{ + std::list<int> l; + l.emplace(l.begin()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc new file mode 100644 index 000000000..0bc1ee5c1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +void test01() +{ + std::list<int> l1; + l1.emplace(l1.cbegin(), 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/erase/54577.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/erase/54577.cc new file mode 100644 index 000000000..623b5f670 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/erase/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +void test01() +{ + std::list<int> l1; + l1.push_back(1); + l1.erase(l1.cbegin()); + + std::list<int> l2; + l2.push_back(2); + l2.push_back(3); + l2.erase(l2.cbegin(), l2.cend()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc new file mode 100644 index 000000000..4f6ac2db3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc @@ -0,0 +1,31 @@ +// { dg-require-time "" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "25288.h" +#include <list> + +int main() +{ + typedef int value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::list<value_type, allocator_type> list_type; + + insert1<list_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h new file mode 100644 index 000000000..0f849a3d3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h @@ -0,0 +1,90 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include <testsuite_hooks.h> +#include <ext/throw_allocator.h> + +// libstdc++/25288 +template<typename _Tp> +void insert1() +{ + bool test __attribute__((unused)) = true; + + typedef _Tp list_type; + typedef typename _Tp::value_type value_type; + typedef typename _Tp::allocator_type allocator_type; + typedef typename _Tp::size_type size_type; + + for (int j = 0; j < 10; ++j) + for (int i = 0; i < 10; ++i) + { + allocator_type alloc1; + typename allocator_type::never_adjustor adjust1; + list_type list1(alloc1); + + for (int k = 0; k < j; ++k) + list1.push_back(value_type(-(k + 1))); + + try + { + typename allocator_type::always_adjustor adjust2; + list1.insert(list1.begin(), 10, 99); + VERIFY( false ); + } + catch (__gnu_cxx::forced_error&) + { + VERIFY( true ); + } + catch (...) + { + __throw_exception_again; + } + + VERIFY( list1.size() == size_type(j) ); + VERIFY( list1.size() == 0 || list1.back() == -j ); + VERIFY( list1.size() == 0 || list1.front() == -1 ); + + allocator_type alloc2; + list_type list2(alloc2); + + const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + for (int k = 0; k < j; ++k) + list2.push_back(-(k + 1)); + + try + { + typename allocator_type::always_adjustor adjust3; + list2.insert(list2.begin(), data, data + 10); + VERIFY( false ); + } + catch (__gnu_cxx::forced_error&) + { + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( list2.size() == size_type(j) ); + VERIFY( list2.size() == 0 || list2.back() == -j ); + VERIFY( list2.size() == 0 || list2.front() == -1 ); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc new file mode 100644 index 000000000..4f04500a4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +void test01() +{ + std::list<int> l1, l2{5, 6}; + int n = 0; + std::list<int>::iterator it = l1.insert(l1.cbegin(), n); + it = l1.insert(l1.cbegin(), 1); + it = l1.insert(l1.cbegin(), {2, 3}); + it = l1.insert(l1.cbegin(), 1, 4); + it = l1.insert(l1.cbegin(), l2.begin(), l2.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc new file mode 100644 index 000000000..8b151f4be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include "1.h" + +namespace std +{ + template<> + void + list<T, allocator<T> >::swap(list<T, allocator<T> >&) + { ++swap_calls; } +} + +// See c++/13658 for background info. +int main() +{ + swap11<std::list<T> >(); + swap12<std::list<T> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h new file mode 100644 index 000000000..8b2edfdd6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h @@ -0,0 +1,58 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <algorithm> +#include <testsuite_hooks.h> + +struct T { int i; }; + +int swap_calls; + +// Should use list specialization for swap. +template<typename _Tp> +void +swap11() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type A; + list_type B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use list specialization for swap. +template<typename _Tp> +void +swap12() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type A; + list_type B; + swap_calls = 0; + swap(A, B); + VERIFY(1 == swap_calls); +} + +#if !__GXX_WEAK__ && _MT_ALLOCATOR_H +template class __gnu_cxx::__mt_alloc<std::_List_node<T> >; +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc new file mode 100644 index 000000000..89d5d8ddf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc @@ -0,0 +1,31 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include "2.h" + +int main() +{ + typedef char value_type; + typedef __gnu_test::uneq_allocator<value_type> allocator_type; + typedef std::list<value_type, allocator_type> list_type; + + swap2<list_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h new file mode 100644 index 000000000..63f5143e5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h @@ -0,0 +1,127 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list::swap + +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +template<typename _Tp> +void +swap2() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef _Tp list_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::size_type size_type; + + 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); + + size_type size01, size02; + + allocator_type alloc01(1); + + list_type lis01(alloc01); + size01 = lis01.size(); + list_type lis02(alloc01); + size02 = lis02.size(); + + lis01.swap(lis02); + VERIFY( lis01.size() == size02 ); + VERIFY( lis01.empty() ); + VERIFY( lis02.size() == size01 ); + VERIFY( lis02.empty() ); + + list_type lis03(alloc01); + size01 = lis03.size(); + list_type lis04(title02, title02 + N2, alloc01); + size02 = lis04.size(); + + lis03.swap(lis04); + VERIFY( lis03.size() == size02 ); + VERIFY( equal(lis03.begin(), lis03.end(), title02) ); + VERIFY( lis04.size() == size01 ); + VERIFY( lis04.empty() ); + + list_type lis05(title01, title01 + N1, alloc01); + size01 = lis05.size(); + list_type lis06(title02, title02 + N2, alloc01); + size02 = lis06.size(); + + lis05.swap(lis06); + VERIFY( lis05.size() == size02 ); + VERIFY( equal(lis05.begin(), lis05.end(), title02) ); + VERIFY( lis06.size() == size01 ); + VERIFY( equal(lis06.begin(), lis06.end(), title01) ); + + list_type lis07(title01, title01 + N1, alloc01); + size01 = lis07.size(); + list_type lis08(title03, title03 + N3, alloc01); + size02 = lis08.size(); + + lis07.swap(lis08); + VERIFY( lis07.size() == size02 ); + VERIFY( equal(lis07.begin(), lis07.end(), title03) ); + VERIFY( lis08.size() == size01 ); + VERIFY( equal(lis08.begin(), lis08.end(), title01) ); + + list_type lis09(title03, title03 + N3, alloc01); + size01 = lis09.size(); + list_type lis10(title04, title04 + N4, alloc01); + size02 = lis10.size(); + + lis09.swap(lis10); + VERIFY( lis09.size() == size02 ); + VERIFY( equal(lis09.begin(), lis09.end(), title04) ); + VERIFY( lis10.size() == size01 ); + VERIFY( equal(lis10.begin(), lis10.end(), title03) ); + + list_type lis11(title04, title04 + N4, alloc01); + size01 = lis11.size(); + list_type lis12(title01, title01 + N1, alloc01); + size02 = lis12.size(); + + lis11.swap(lis12); + VERIFY( lis11.size() == size02 ); + VERIFY( equal(lis11.begin(), lis11.end(), title01) ); + VERIFY( lis12.size() == size01 ); + VERIFY( equal(lis12.begin(), lis12.end(), title04) ); + + list_type lis13(title03, title03 + N3, alloc01); + size01 = lis13.size(); + list_type lis14(title03, title03 + N3, alloc01); + size02 = lis14.size(); + + lis13.swap(lis14); + VERIFY( lis13.size() == size02 ); + VERIFY( equal(lis13.begin(), lis13.end(), title03) ); + VERIFY( lis14.size() == size01 ); + VERIFY( equal(lis14.begin(), lis14.end(), title03) ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc new file mode 100644 index 000000000..03ad2888a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc @@ -0,0 +1,31 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include "3.h" + +int main() +{ + typedef char value_type; + typedef __gnu_test::uneq_allocator<value_type> allocator_type; + typedef std::list<value_type, allocator_type> list_type; + + swap3<list_type>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h new file mode 100644 index 000000000..0a8a46a44 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h @@ -0,0 +1,156 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.3 list::swap + +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +template<typename _Tp> +void +swap3() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef _Tp list_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::size_type size_type; + + 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); + + size_type size01, size02; + + allocator_type alloc01(1), alloc02(2); + int personality01, personality02; + + list_type lis01(alloc01); + size01 = lis01.size(); + personality01 = lis01.get_allocator().get_personality(); + list_type lis02(alloc02); + size02 = lis02.size(); + personality02 = lis02.get_allocator().get_personality(); + + lis01.swap(lis02); + VERIFY( lis01.size() == size02 ); + VERIFY( lis01.empty() ); + VERIFY( lis02.size() == size01 ); + VERIFY( lis02.empty() ); + VERIFY( lis01.get_allocator().get_personality() == personality02 ); + VERIFY( lis02.get_allocator().get_personality() == personality01 ); + + list_type lis03(alloc02); + size01 = lis03.size(); + personality01 = lis03.get_allocator().get_personality(); + list_type lis04(title02, title02 + N2, alloc01); + size02 = lis04.size(); + personality02 = lis04.get_allocator().get_personality(); + + lis03.swap(lis04); + VERIFY( lis03.size() == size02 ); + VERIFY( equal(lis03.begin(), lis03.end(), title02) ); + VERIFY( lis04.size() == size01 ); + VERIFY( lis04.empty() ); + VERIFY( lis03.get_allocator().get_personality() == personality02 ); + VERIFY( lis04.get_allocator().get_personality() == personality01 ); + + list_type lis05(title01, title01 + N1, alloc01); + size01 = lis05.size(); + personality01 = lis05.get_allocator().get_personality(); + list_type lis06(title02, title02 + N2, alloc02); + size02 = lis06.size(); + personality02 = lis06.get_allocator().get_personality(); + + lis05.swap(lis06); + VERIFY( lis05.size() == size02 ); + VERIFY( equal(lis05.begin(), lis05.end(), title02) ); + VERIFY( lis06.size() == size01 ); + VERIFY( equal(lis06.begin(), lis06.end(), title01) ); + VERIFY( lis05.get_allocator().get_personality() == personality02 ); + VERIFY( lis06.get_allocator().get_personality() == personality01 ); + + list_type lis07(title01, title01 + N1, alloc02); + size01 = lis07.size(); + personality01 = lis07.get_allocator().get_personality(); + list_type lis08(title03, title03 + N3, alloc01); + size02 = lis08.size(); + personality02 = lis08.get_allocator().get_personality(); + + lis07.swap(lis08); + VERIFY( lis07.size() == size02 ); + VERIFY( equal(lis07.begin(), lis07.end(), title03) ); + VERIFY( lis08.size() == size01 ); + VERIFY( equal(lis08.begin(), lis08.end(), title01) ); + VERIFY( lis07.get_allocator().get_personality() == personality02 ); + VERIFY( lis08.get_allocator().get_personality() == personality01 ); + + list_type lis09(title03, title03 + N3, alloc01); + size01 = lis09.size(); + personality01 = lis09.get_allocator().get_personality(); + list_type lis10(title04, title04 + N4, alloc02); + size02 = lis10.size(); + personality02 = lis10.get_allocator().get_personality(); + + lis09.swap(lis10); + VERIFY( lis09.size() == size02 ); + VERIFY( equal(lis09.begin(), lis09.end(), title04) ); + VERIFY( lis10.size() == size01 ); + VERIFY( equal(lis10.begin(), lis10.end(), title03) ); + VERIFY( lis09.get_allocator().get_personality() == personality02 ); + VERIFY( lis10.get_allocator().get_personality() == personality01 ); + + list_type lis11(title04, title04 + N4, alloc02); + size01 = lis11.size(); + personality01 = lis11.get_allocator().get_personality(); + list_type lis12(title01, title01 + N1, alloc01); + size02 = lis12.size(); + personality02 = lis12.get_allocator().get_personality(); + + lis11.swap(lis12); + VERIFY( lis11.size() == size02 ); + VERIFY( equal(lis11.begin(), lis11.end(), title01) ); + VERIFY( lis12.size() == size01 ); + VERIFY( equal(lis12.begin(), lis12.end(), title04) ); + VERIFY( lis11.get_allocator().get_personality() == personality02 ); + VERIFY( lis12.get_allocator().get_personality() == personality01 ); + + list_type lis13(title03, title03 + N3, alloc01); + size01 = lis13.size(); + personality01 = lis13.get_allocator().get_personality(); + list_type lis14(title03, title03 + N3, alloc02); + size02 = lis14.size(); + personality02 = lis14.get_allocator().get_personality(); + + lis13.swap(lis14); + VERIFY( lis13.size() == size02 ); + VERIFY( equal(lis13.begin(), lis13.end(), title03) ); + VERIFY( lis14.size() == size01 ); + VERIFY( equal(lis14.begin(), lis14.end(), title03) ); + VERIFY( lis13.get_allocator().get_personality() == personality02 ); + VERIFY( lis14.get_allocator().get_personality() == personality01 ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.cc new file mode 100644 index 000000000..ca3b305dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "1.h" +#include <list> + +int main() +{ + operations01<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.h new file mode 100644 index 000000000..a681fe0a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/1.h @@ -0,0 +1,68 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.4 list operations [lib.list.ops] + +#include <testsuite_hooks.h> + +// splice(p, x) + remove + reverse +template<typename _Tp> +void +operations01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int K = 417; + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {K, K, K, K, K}; + const std::size_t N = sizeof(A) / sizeof(int); + const std::size_t M = sizeof(B) / sizeof(int); + + list_type list0101(A, A + N); + list_type list0102(B, B + M); + iterator p = list0101.begin(); + + VERIFY(list0101.size() == N); + VERIFY(list0102.size() == M); + + ++p; + list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5] + VERIFY(list0101.size() == N + M); + VERIFY(list0102.size() == 0); + + // remove range from middle + list0101.remove(K); + VERIFY(list0101.size() == N); + + // remove first element + list0101.remove(1); + VERIFY(list0101.size() == N - 1); + + // remove last element + list0101.remove(5); + VERIFY(list0101.size() == N - 2); + + // reverse + list0101.reverse(); + p = list0101.begin(); + VERIFY(*p == 4); ++p; + VERIFY(*p == 3); ++p; + VERIFY(*p == 2); ++p; + VERIFY(p == list0101.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.cc new file mode 100644 index 000000000..275b8b35a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "2.h" +#include <list> + +int main() +{ + operations02<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.h new file mode 100644 index 000000000..c41ba5cfe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2.h @@ -0,0 +1,54 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.4 list operations [lib.list.ops] + +#include <testsuite_hooks.h> + +// splice(p, x, i) + remove_if + operator== +template<typename _Tp> +void +operations02() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {2, 1, 3, 4, 5}; + const int C[] = {1, 3, 4, 5, 2}; + const int N = sizeof(A) / sizeof(int); + list_type list0201(A, A + N); + list_type list0202(A, A + N); + list_type list0203(B, B + N); + list_type list0204(C, C + N); + iterator i = list0201.begin(); + + // result should be unchanged + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 == list0202); + + // result should be [2 1 3 4 5] + ++i; + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 != list0202); + VERIFY(list0201 == list0203); + + // result should be [1 3 4 5 2] + list0201.splice(list0201.end(), list0201, i); + VERIFY(list0201 == list0204); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc new file mode 100644 index 000000000..2829e0974 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "2.h" +#include <list> + +int main() +{ + operations02<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.cc new file mode 100644 index 000000000..1678fea8a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "3.h" +#include <list> + +int main(void) +{ + operations03<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.h new file mode 100644 index 000000000..464618177 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3.h @@ -0,0 +1,68 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.4 list operations [lib.list.ops] + +#include <testsuite_hooks.h> + +// splice(p, x, f, l) + sort + merge + unique +template<typename _Tp> +void +operations03() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {103, 203, 603, 303, 403, 503}; + const int B[] = {417, 417, 417, 417, 417}; + const int E[] = {103, 417, 417, 203, 603, 303, 403, 503}; + const int F[] = {103, 203, 303, 403, 417, 417, 503, 603}; + const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603}; + const int D[] = {103, 203, 303, 403, 417, 503, 603}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int P = sizeof(C) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + const int R = sizeof(E) / sizeof(int); + + list_type list0301(A, A + N); + list_type list0302(B, B + M); + list_type list0303(C, C + P); + list_type list0304(D, D + Q); + list_type list0305(E, E + R); + list_type list0306(F, F + R); + iterator p = list0301.begin(); + iterator q = list0302.begin(); + + ++p; ++q; ++q; + list0301.splice(p, list0302, list0302.begin(), q); + VERIFY(list0301 == list0305); + VERIFY(list0301.size() == N + 2); + VERIFY(list0302.size() == M - 2); + + list0301.sort(); + VERIFY(list0301 == list0306); + + list0301.merge(list0302); + VERIFY(list0301.size() == N + M); + VERIFY(list0302.size() == 0); + VERIFY(list0301 == list0303); + + list0301.unique(); + VERIFY(list0301 == list0304); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc new file mode 100644 index 000000000..3020f49ca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.4 list operations [lib.list.ops] + +// NB: This issue affected only debug-mode. + +#include <list> +#include <functional> + +// libstdc++/35969 +void test01() +{ + { + std::list<int> list1; + std::list<int> list2; + + for(int i = 0; i < 10; ++i) + { + list1.push_back(i); + list2.push_back(10 - i); + } + + list1.sort(); + list2.sort(); + + std::list<int>::iterator node_of_interest = list2.begin(); + + list1.splice(list1.begin(), list2, node_of_interest); + list2.splice(list2.begin(), list1, node_of_interest); + + list1.merge(list2); + + list2.splice(list2.begin(), list1, node_of_interest); + } + + { + std::list<int> list1; + std::list<int> list2; + + for(int i = 0; i < 10; ++i) + { + list1.push_back(i); + list2.push_back(10 - i); + } + + list1.sort(); + list2.sort(); + + std::list<int>::iterator node_of_interest = list2.begin(); + + list1.splice(list1.begin(), list2, node_of_interest); + list2.splice(list2.begin(), list1, node_of_interest); + + list1.merge(list2, std::less<int>()); + + list2.splice(list2.begin(), list1, node_of_interest); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc new file mode 100644 index 000000000..62518067f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "3.h" +#include <list> + +int main() +{ + operations03<std::list<int> >(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.cc new file mode 100644 index 000000000..45a6b8078 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +#include "4.h" +#include <list> + +int main() +{ + operations04<std::list<int> >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.h b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.h new file mode 100644 index 000000000..35e645f58 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/4.h @@ -0,0 +1,92 @@ +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.2.4 list operations [lib.list.ops] + +#include <testsuite_hooks.h> + +// A comparison predicate to order by rightmost digit. Tracks call +// counts for performance checks. +struct CompLastLt +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 < y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastLt::itsCount; + +struct CompLastEq +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 == y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastEq::itsCount; + +// sort(pred) + merge(pred) + unique(pred) +// also checks performance requirements +template<typename _Tp> +void +operations04() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + const int A[] = {1, 2, 3, 4, 5, 6}; + const int B[] = {12, 15, 13, 14, 11}; + const int C[] = {11, 12, 13, 14, 15}; + const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + + list_type list0401(A, A + N); + list_type list0402(B, B + M); + list_type list0403(C, C + M); + list_type list0404(D, D + Q); + list_type list0405(A, A + N); + + // sort B + CompLastLt lt; + + CompLastLt::reset(); + list0402.sort(lt); + VERIFY(list0402 == list0403); + + CompLastLt::reset(); + list0401.merge(list0402, lt); + VERIFY(list0401 == list0404); +#ifndef _GLIBCXX_DEBUG + VERIFY(lt.count() <= (N + M - 1)); +#endif + + CompLastEq eq; + + CompLastEq::reset(); + list0401.unique(eq); + VERIFY(list0401 == list0405); +#ifndef _GLIBCXX_DEBUG + VERIFY(eq.count() == (N + M - 1)); +#endif +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc new file mode 100644 index 000000000..35298076f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <testsuite_hooks.h> + +// PR libstdc++/42352 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<int> l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7}; + + l.sort(); + + for (auto it = l.begin(); it != l.end(); ++it) + { + static int nn = 0; + VERIFY( *it == nn++ ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::list<int> l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7}; + + struct compare + { + bool + operator()(int const& one, int const& two) const + { return one > two; } + }; + + l.sort(compare()); + + for (auto it = l.begin(); it != l.end(); ++it) + { + static int nn = 9; + VERIFY( *it == nn-- ); + } +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/splice/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/splice/const_iterator.cc new file mode 100644 index 000000000..388f1c65e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/operations/splice/const_iterator.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +void test01() +{ + std::list<int> l1{0, 1}, l2{2, 3}; + l1.splice(l1.cbegin(), l2); + l2.splice(l2.cbegin(), std::move(l1)); + l1.splice(l1.cbegin(), l2, l2.cbegin()); + l2.splice(l2.cbegin(), std::move(l1), l1.cbegin()); + l1.splice(l1.cbegin(), l2, l2.cbegin(), l2.cend()); + l2.splice(l2.cbegin(), std::move(l1), l1.cbegin(), l1.cend()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread1.cc new file mode 100644 index 000000000..cdca89ffa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread1.cc @@ -0,0 +1,130 @@ +// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org> +// +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options "-pthreads" { target *-*-solaris* } } + +// This multi-threading C++/STL/POSIX code adheres to rules outlined here: +// http://www.sgi.com/tech/stl/thread_safety.html +// +// It is believed to exercise the allocation code in a manner that +// should reveal memory leaks (and, under rare cases, race conditions, +// if the STL threading support is fubar'd). + +#include <list> +#include <cstdlib> +#include <pthread.h> + +const int thread_cycles = 10; +const int thread_pairs = 10; +const unsigned max_size = 100; +const int iters = 10000; + +class task_queue +{ + typedef std::list<int> list_type; + +public: + task_queue () + { + pthread_mutex_init (&fooLock, 0); + pthread_cond_init (&fooCond1, 0); + pthread_cond_init (&fooCond2, 0); + } + ~task_queue () + { + pthread_mutex_destroy (&fooLock); + pthread_cond_destroy (&fooCond1); + pthread_cond_destroy (&fooCond2); + } + + list_type foo; + pthread_mutex_t fooLock; + pthread_cond_t fooCond1; + pthread_cond_t fooCond2; +}; + +void* +produce(void* t) +{ + task_queue& tq = *(static_cast<task_queue*> (t)); + int num = 0; + while (num < iters) + { + pthread_mutex_lock (&tq.fooLock); + while (tq.foo.size () >= max_size) + pthread_cond_wait (&tq.fooCond1, &tq.fooLock); + tq.foo.push_back (num++); + pthread_cond_signal (&tq.fooCond2); + pthread_mutex_unlock (&tq.fooLock); + } + return 0; +} + +void* +consume(void* t) +{ + task_queue& tq = *(static_cast<task_queue*> (t)); + int num = 0; + while (num < iters) + { + pthread_mutex_lock (&tq.fooLock); + while (tq.foo.size () == 0) + pthread_cond_wait (&tq.fooCond2, &tq.fooLock); + if (tq.foo.front () != num++) + abort (); + tq.foo.pop_front (); + pthread_cond_signal (&tq.fooCond1); + pthread_mutex_unlock (&tq.fooLock); + } + return 0; +} + +int +main() +{ + pthread_t prod[thread_pairs]; + pthread_t cons[thread_pairs]; + + task_queue* tq[thread_pairs]; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (thread_pairs * 2); +#endif + + for (int j = 0; j < thread_cycles; j++) + { + for (int i = 0; i < thread_pairs; i++) + { + tq[i] = new task_queue; + pthread_create (&prod[i], 0, produce, static_cast<void*> (tq[i])); + pthread_create (&cons[i], 0, consume, static_cast<void*> (tq[i])); + } + + for (int i = 0; i < thread_pairs; i++) + { + pthread_join (prod[i], 0); + pthread_join (cons[i], 0); + delete tq[i]; + } + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread5.cc new file mode 100644 index 000000000..ead8d332c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/pthread5.cc @@ -0,0 +1,124 @@ +// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org> +// Adpated from libstdc++/5464 submitted by jjessel@amadeus.net +// Jean-Francois JESSEL (Amadeus SAS Development) +// +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options "-pthreads" { target *-*-solaris* } } + +#include <vector> +#include <list> +#include <string> +#include <cstdlib> +#include <pthread.h> + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +#define NTHREADS 8 +#define LOOPS 20 + +struct tt_t +{ + char buf[100]; + int i; +}; + +void* +thread_function (void* arg) +{ + typedef std::vector<tt_t> vector_type; + typedef std::list<std::string*> list_type; + + int myid __attribute__((unused)) = *(int*) arg; + for (int i = 0; i < LOOPS; i++) + { + vector_type myvect1; + + for (int j = 0; j < 2000; j++) + { + vector_type myvect2; + tt_t v; + v.i = j; + myvect1.push_back (v); + myvect2.push_back (v); + list_type mylist; + std::string string_array[4]; + string_array[0] = "toto"; + string_array[1] = "titi"; + string_array[2] = "tata"; + string_array[3] = "tutu"; + for (int k = 0; k < 4; k++) + { + if (mylist.size ()) + { + list_type::iterator aIt; + for (aIt = mylist.begin (); aIt != mylist.end (); ++aIt) + { + if ((*aIt) == &(string_array[k])) + abort (); + } + } + mylist.push_back (&(string_array[k])); + } + } + } + + return arg; +} + +int +main () +{ + int worker; + pthread_t threads[NTHREADS]; + int ids[NTHREADS]; + void* status; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (NTHREADS); +#endif + + pthread_attr_t tattr; + int ret __attribute__((unused)) = pthread_attr_init (&tattr); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + ret = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM); +#endif + + for (worker = 0; worker < NTHREADS; worker++) + { + ids[worker] = worker; + if (pthread_create(&threads[worker], &tattr, + thread_function, &ids[worker])) + abort (); + } + + for (worker = 0; worker < NTHREADS; worker++) + { + if (pthread_join(threads[worker], static_cast<void **>(&status))) + abort (); + + if (*((int *)status) != worker) + abort (); + } + + return (0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/range_access.cc new file mode 100644 index 000000000..69e21b212 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <list> + +void +test01() +{ + std::list<int> l{1, 2, 3}; + std::begin(l); + std::end(l); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc new file mode 100644 index 000000000..7e8c3895e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <testsuite_containers.h> + +int main() +{ + typedef std::list<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/do_the_right_thing.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/do_the_right_thing.cc new file mode 100644 index 000000000..5430de555 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/do_the_right_thing.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> + +// libstdc++/43813 +void test01() +{ + std::list<double*> l(7, 0); + l.assign(7, 0); + l.insert(l.begin(), 7, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..7c29a2d8c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -0,0 +1,35 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1656 } + +#include <list> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::list<A> list_type; + list_type l; + l.assign(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc new file mode 100644 index 000000000..9d77e6888 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc @@ -0,0 +1,28 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <list> + +void f() +{ + typedef std::list<int> list_type; + list_type l(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..382d985c1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,29 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1608 } + +#include <list> + +void f() +{ + typedef std::list<std::list<int> > list_type; + list_type l(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..14585af98 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,30 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1608 } + +#include <list> +#include <utility> + +void f() +{ + typedef std::list<std::list<std::pair<char, char> > > list_type; + list_type l('a', 'b'); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..a9f9f305f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -0,0 +1,35 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1608 } + +#include <list> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::list<A> list_type; + list_type l; + l.insert(l.begin(), 10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc new file mode 100644 index 000000000..f383a334a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::list<value_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..1ea0f4e3c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::list<value_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..2de89e76d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <list> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::list<value_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..d8b04bb0f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <list> + +// { dg-do compile } + +template class std::list<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..70ff9631b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <list> + +template class std::list<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..6ef850862 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <list> +#include <testsuite_api.h> + +// { dg-do compile } + +// N.B. In C++0x mode we cannot instantiate with T == NonDefaultConstructible +// because of 23.3.4.1.4 +#if __cplusplus < 201103L +template class std::list<__gnu_test::NonDefaultConstructible>; +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..d0581bfbf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <list> + +// { dg-do compile } + +// libstdc++/21770 +template class std::list<int, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..31f74a57c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2010-2014 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <list> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::list<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..73132e580 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <list> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::list<int, __gnu_test::ExplicitConsAlloc<int> >; +template class std::list<int, __gnu_test::ExplicitConsAlloc<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc new file mode 100644 index 000000000..513e15964 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/5_c++0x.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <list> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::list<int, __gnu_test::ExplicitConsAlloc<int>>; +template class std::list<int, __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..6d47db09d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <list> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Allocator> + class list<user_type, Allocator> { }; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc new file mode 100644 index 000000000..d41c21a98 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <list> + +// Check container for required typedefs. +__gnu_test::types<std::list<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/14340.cc new file mode 100644 index 000000000..131dc2a1f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <map> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::map<int, int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/18604.cc new file mode 100644 index 000000000..c377145df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/18604.cc @@ -0,0 +1,41 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <map> diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/23781_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/23781_neg.cc new file mode 100644 index 000000000..76e555620 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/23781_neg.cc @@ -0,0 +1,28 @@ +// 2005-09-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +// libstdc++/23781 +#include <map> +#include <cstddef> + +std::map<int, int>::iterator it = NULL; // { dg-error "conversion" } +std::map<int, int>::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/56613.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/56613.cc new file mode 100644 index 000000000..6ef249082 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/56613.cc @@ -0,0 +1,73 @@ +// -*- C++ -*- + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <map> + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/56613 + +// A conforming C++03 allocator, should still work in C++11 mode. +template<typename T> +struct alloc +{ + typedef T value_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef unsigned size_type; + typedef int difference_type; + + template<typename U> + struct rebind { + typedef alloc<U> other; + }; + + alloc() { } + template<typename U> + alloc(const alloc<U>&) { } + + pointer allocate(size_type n, const void* = 0) { return +std::allocator<T>().allocate(n); } + void deallocate(pointer p, size_type n) { std::allocator<T>().deallocate(p, +n); } + + size_type max_size() const { return -1; } + + void construct(pointer p, const T& t) { new ((void*) p) T(t); } + void destroy(pointer p) { p->~T(); } + + pointer address(reference x) const throw() { return &x; } + const_pointer address(const_reference x) const throw() { return &x; } +}; + +template<typename T, typename U> +bool operator==(alloc<T>, alloc<U>) { return true; } + +template<typename T, typename U> +bool operator!=(alloc<T>, alloc<U>) { return false; } + +int main() +{ + std::map<int, int, std::less<int>, alloc<int> > m; + m[1]; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/58764.cc new file mode 100644 index 000000000..31e09665b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <map> + +void test01() +{ + std::map<int, int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/59872.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/59872.cc new file mode 100644 index 000000000..be8413bfd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/59872.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/59872 + +#include <map> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly(const MoveOnly&) = delete; +}; + +using test_type = std::map<int, MoveOnly>; + +test_type p; +test_type q(std::move(p)); +test_type r(std::move(p), test_type::allocator_type()); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy.cc new file mode 100644 index 000000000..c70806783 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy.cc @@ -0,0 +1,76 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy_assign.cc new file mode 100644 index 000000000..2dc69eaf8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/copy_assign.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/minimal.cc new file mode 100644 index 000000000..2fe3bbd85 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/minimal.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::SimpleAllocator; + +template class std::map<T, U, Cmp, SimpleAllocator<std::pair<const T, U>>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<std::pair<const T, U>> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v(alloc_type{}); + v = { test_type::value_type{} }; + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move.cc new file mode 100644 index 000000000..7247de35e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<std::pair<const T, U>> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<std::pair<const T, U>> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc new file mode 100644 index 000000000..ce29e1d40 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc new file mode 100644 index 000000000..627e8245e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<std::pair<const T, U>> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/swap.cc new file mode 100644 index 000000000..045d45772 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/allocator/swap.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<std::pair<const T, U>, false>&, + const propagating_allocator<std::pair<const T, U>, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<std::pair<const T, U>, false>&, + const propagating_allocator<std::pair<const T, U>, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::map<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc new file mode 100644 index 000000000..3ff273601 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.1 map capacity + +#include <map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::map<int, int> m; + + VERIFY( (m.max_size() == std::allocator<std::_Rb_tree_node< + std::pair<const int, int> > >().max_size()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc new file mode 100644 index 000000000..210526dfd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on map (via swap). If the implementation changed +// this test may begin to fail. + +#include <map> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::map<int, int> a,b; + a[2]=0; + b[1]=0; + b = std::move(a); + VERIFY(b.find(2) != b.end() && a.find(1) == a.end()); + + std::map<int, int> c(std::move(b)); + VERIFY( c.find(2) != c.end()); + VERIFY( b.find(2) == b.end()); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..6b9abd7b5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> + +typedef std::map<int, int> mtype; + +static_assert(std::is_nothrow_move_constructible<mtype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc new file mode 100644 index 000000000..ba868fd25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <map> + +std::map<int, int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc new file mode 100644 index 000000000..8c8200819 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc new file mode 100644 index 000000000..65aaa0bb5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc new file mode 100644 index 000000000..923a444e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct4_neg.cc new file mode 100644 index 000000000..93b098341 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc new file mode 100644 index 000000000..1746ac187 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc new file mode 100644 index 000000000..665d479f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc new file mode 100644 index 000000000..1052ddd4a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert4_neg.cc new file mode 100644 index 000000000..ab65184d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc new file mode 100644 index 000000000..76f51220f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc @@ -0,0 +1,51 @@ +// Map iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/map> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::map; +using std::advance; + +bool test = true; + +// Assignment +void test01() +{ + map<int, int> v1; + map<int, int> v2; + + v1[17] = 42; + + map<int, int>::iterator start = v1.begin(); + map<int, int>::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc new file mode 100644 index 000000000..4891ee28f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc @@ -0,0 +1,70 @@ +// Map iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/map> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::map; +using std::advance; + +bool test = true; + +// Erase +void test02() +{ + map<int, int> v; + for (int i = 0; i < 20; ++i) + v[i] = 20-i; + + // Single element erase (middle) + map<int, int>::iterator before = v.begin(); + map<int, int>::iterator at = before; + advance(at, 3); + map<int, int>::iterator after = at; + ++after; + v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 4); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + map<int, int>::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..f293bdff5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <map> + +void test01() +{ + std::map<int, int> m1; + auto it1 = m1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..c698b7798 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <map> + +void test01() +{ + std::map<int, int> m1; + m1 = std::move(m1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc new file mode 100644 index 000000000..d452d2e3d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc @@ -0,0 +1,78 @@ +// 2005-08-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <stdexcept> +#include <testsuite_hooks.h> + +// libstdc++/23578 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::map<int, double> map_type; + + { + map_type m; + m[0] = 1.5; + + double& rd = m.at(0); + VERIFY( rd == 1.5 ); + try + { + m.at(1); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } + + { + map_type m; + m[1] = 2.5; + const map_type cm(m); + + const double& crd = cm.at(1); + VERIFY( crd == 2.5 ); + try + { + cm.at(0); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc new file mode 100644 index 000000000..74493de2b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<rvalstruct, rvalstruct> Map; + + Map m; + VERIFY( m.empty() ); + + m[rvalstruct(1)] = rvalstruct(17); + VERIFY( m.size() == 1 ); + VERIFY( (m.begin()->first).val == 1 ); + VERIFY( (m.begin()->second).val == 17 ); + VERIFY( m[rvalstruct(1)].val == 17 ); + + m[rvalstruct(2)] = rvalstruct(9); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(2)].val == 9 ); + + m[rvalstruct(1)] = rvalstruct(5); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(1)].val == 5 ); + VERIFY( m[rvalstruct(2)].val == 9 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/39901.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/39901.cc new file mode 100644 index 000000000..d40bdc600 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/39901.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_hooks.h> + +// c++/39901 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::map<std::pair<int, int>, int> the_map; + + the_map[{0, 1}] = 5; + VERIFY( (the_map.size() == 1) ); + VERIFY( (the_map[{0, 1}] == 5) ); + + VERIFY( (the_map[{0, 0}] == 0) ); + VERIFY( (the_map.size() == 2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc new file mode 100644 index 000000000..0f0b6da38 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> + +class moveable +{ +public: + moveable(moveable&&) { } + moveable() { } + + operator int() + { return 0; } +}; + +// libstdc++/46148 +int main() +{ + std::map<bool,moveable> the_map; + return the_map[true]; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/init-list.cc new file mode 100644 index 000000000..c2493372c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/init-list.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + map<int,double> m({ { 1, 1.0 }, { 2, 2.0 }, { 42, 237.0 } }); + VERIFY(m.size() == 3); + VERIFY(m[1] == 1.0); + VERIFY(m[2] == 2.0); + VERIFY(m[42] == 237.0); + + m = { {5, 55.0}, { 6, 66.0 } }; + VERIFY(m.size() == 2); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + + m.insert({ { 7, 77.0 }, { 8, 88.0 } }); + VERIFY(m.size() == 4); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + VERIFY(m[7] == 77.0); + VERIFY(m[8] == 88.0); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/dr130.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/dr130.cc new file mode 100644 index 000000000..25d1f4815 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/dr130.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } +// 2008-07-22 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_hooks.h> + +// DR 130. Associative erase should return an iterator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map<int, int> m0; + typedef map<int, int>::iterator iterator; + typedef map<int, int>::const_iterator const_iterator; + typedef map<int, int>::value_type value_type; + typedef pair<iterator, bool> insert_return_type; + + m0.insert(value_type(1, 1)); + insert_return_type irt1 = m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + + iterator pos1 = m0.erase(irt1.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = m0.erase(irt2.first); + VERIFY( pos2 == m0.end() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map<int, int> m0; + typedef map<int, int>::iterator iterator; + typedef map<int, int>::const_iterator const_iterator; + typedef map<int, int>::value_type value_type; + typedef pair<iterator, bool> insert_return_type; + + insert_return_type irt0 = m0.insert(value_type(1, 1)); + m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + insert_return_type irt3 = m0.insert(value_type(4, 4)); + + iterator pos1 = m0.erase(irt0.first, irt2.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = m0.erase(irt2.first, ++irt3.first); + VERIFY( pos2 == m0.end() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc new file mode 100644 index 000000000..44543f546 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc @@ -0,0 +1,114 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <utility> +#include <tuple> +#include <vector> +#include <map> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::map<char, std::vector<double>> Map; + Map m; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = m.emplace('a', coord1); + VERIFY( ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + + coord1[0] = 3.0; + ret = m.emplace('a', coord1); + VERIFY( !ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + VERIFY( ret.first->second[0] == 0.0 ); + + auto it = m.emplace_hint(m.begin(), 'b', coord1); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second[0] == 3.0 ); + + double *px = &coord1[0]; + ret = m.emplace('c', std::move(coord1)); + VERIFY( ret.second ); + VERIFY( ret.first->first == 'c' ); + VERIFY( &(ret.first->second[0]) == px ); +} + +void test02() +{ + using namespace std; + typedef map<char, PathPoint> Map; + Map m; + + vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple('a', coord1)); + VERIFY( ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + + coord1[0] = 3.0; + ret = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple( 'b', coord1)); + VERIFY( !ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + VERIFY( ret.first->second.getCoords()[0] == 0.0 ); + + auto it = m.emplace_hint(m.begin(), piecewise_construct, + make_tuple('b'), make_tuple('c', coord1)); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + ret = m.emplace(piecewise_construct, + make_tuple('c'), make_tuple('d', move(coord1))); + VERIFY( ret.second ); + VERIFY( ret.first->first == 'c' ); + VERIFY( &(ret.first->second.getCoords()[0]) == px ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc new file mode 100644 index 000000000..bc14c8645 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +#include <map> + +struct Key +{ + Key() { } + + Key(const Key&) { } + + template<typename T> + Key(const T&) + { } + + bool operator<(const Key&) const; +}; + +#if __cplusplus < 201103L +// libstdc++/47628 +void f() +{ + typedef std::map<Key, int> Map; + Map m; + m.insert(Map::value_type()); + Map::iterator i = m.begin(); + m.erase(i); +} +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc new file mode 100644 index 000000000..f968d28de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::map<X, int>& s, X x) +{ + std::map<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/abi_tag.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/abi_tag.cc new file mode 100644 index 000000000..56b8addc1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/abi_tag.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options -std=c++11 } +// { dg-require-normal-mode "" } + +// Copyright (C) 2013-2014 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// Test that the C++11 variants have an ABI tag + +#include <map> + +using container = std::map<int, int>; +using iterator = typename container::iterator; +using const_iterator = typename container::const_iterator; + +// { dg-final { scan-assembler "_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5eraseB5cxx11ESt17_Rb_tree_iteratorIS4_E" } } +iterator (container::*p1)(iterator) = &container::erase; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/dr130-linkage-check.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/dr130-linkage-check.cc new file mode 100644 index 000000000..00a44efca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/dr130-linkage-check.cc @@ -0,0 +1,40 @@ +// { dg-require-effective-target ia32 } +// { dg-require-sharedlib "" } +// { dg-options "-fno-inline -std=gnu++11 ./testsuite_shared.so" } +// 2013-06-03 Benjamin Kosnik <bkoz@redhat..com> +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> + +int main() +{ + typedef std::map<int, int> container_type; + + { + container_type s { {0,0} , {1,1} , {2,2} }; + __gnu_test::linkage_check_cxx98_cxx11_erase(s); + } + + { + container_type s { {0,0} , {1,1} , {2,2} }; + __gnu_test::linkage_check_cxx98_cxx11_erase_iterators(s); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc new file mode 100644 index 000000000..e32c4efa3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc @@ -0,0 +1,67 @@ +// 2001-08-23 pme & Sylvain.Pion@sophia.inria.fr + +// Copyright (C) 2001-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.1.2, table 69 -- map::insert(p,t) + +#include <map> +#include <testsuite_hooks.h> + +// { dg-do run } + +// libstdc++/3349 and +// http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01375.html +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::map<int, int> Map; + Map M; + Map::iterator hint; + + hint = M.insert(Map::value_type(7, 0)).first; + + M.insert(hint, Map::value_type(8, 1)); + M.insert(M.begin(), Map::value_type(9, 2)); + +#if 0 + // The tree's __rb_verify() member must be exposed in map<> before this + // will even compile. It's good test to see that "missing" entries are + // in fact present in the {map,tree}, but in the wrong place. + if (0) + { + Map::iterator i = M.begin(); + while (i != M.end()) { + std::cerr << '(' << i->first << ',' << i->second << ")\n"; + ++i; + } + std::cerr << "tree internal verify: " + << std::boolalpha << M.__rb_verify() << "\n"; + } +#endif + + VERIFY ( M.find(7) != M.end() ); + VERIFY ( M.find(8) != M.end() ); + VERIFY ( M.find(9) != M.end() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc new file mode 100644 index 000000000..e97435f95 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/map> +#include <testsuite_hooks.h> + +// libstdc++/16813 +void test01() +{ + using __gnu_debug::map; + bool test __attribute__((unused)) = true; + + map<int, float> m1, m2; + + m1[3] = 3.0f; + m1[11] = -67.0f; + + m2.insert(m1.begin(), m1.end()); + + VERIFY( m1 == m2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc new file mode 100644 index 000000000..79f7a9179 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + std::pair<Map::iterator, bool> p = m.insert(Pair(1, rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( p.first->first == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair<Map::iterator, bool> p1 = m.insert(Pair(2, rvalstruct(3))); + std::pair<Map::iterator, bool> p2 = m.insert(Pair(2, rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( p1.first->first == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc new file mode 100644 index 000000000..e84551ac7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + std::pair<Map::iterator, bool> p = m.insert(Pair(rvalstruct(1), + rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( (p.first->first).val == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair<Map::iterator, bool> p1 = m.insert(Pair(rvalstruct(2), + rvalstruct(3))); + std::pair<Map::iterator, bool> p2 = m.insert(Pair(rvalstruct(2), + rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (p1.first->first).val == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc new file mode 100644 index 000000000..c9ec8d4de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + Map::iterator p = m.insert(m.begin(), Pair(1, rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p == m.begin() ); + VERIFY( p->first == 1 ); + VERIFY( (p->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator p1 = m.insert(m.begin(), Pair(2, rvalstruct(3))); + Map::iterator p2 = m.insert(p1, Pair(2, rvalstruct(7))); + VERIFY( m.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( p1->first == 2 ); + VERIFY( (p2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc new file mode 100644 index 000000000..f28cf30f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + Map::iterator p = m.insert(m.begin(), Pair(rvalstruct(1), + rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p == m.begin() ); + VERIFY( (p->first).val == 1 ); + VERIFY( (p->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator p1 = m.insert(m.begin(), Pair(rvalstruct(2), + rvalstruct(3))); + Map::iterator p2 = m.insert(p1, Pair(rvalstruct(2), + rvalstruct(7))); + VERIFY( m.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( (p1->first).val == 2 ); + VERIFY( (p2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc new file mode 100644 index 000000000..42c10cf7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_hooks.h> + +struct T { int i; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + map<T, int>::swap(map<T, int>&) + { ++swap_calls; } +} + +// Should use map specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::map<T, int> A; + std::map<T, int> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use map specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + map<T, int> A; + map<T, int> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc new file mode 100644 index 000000000..036c11499 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc @@ -0,0 +1,146 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.1 map::swap + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair<const char, int> my_pair; + typedef __gnu_test::uneq_allocator<my_pair> my_alloc; + typedef map<char, int, less<char>, my_alloc> my_map; + + 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); + + map<char, int> map01_ref; + for (size_t i = 0; i < N1; ++i) + map01_ref.insert(my_pair(title01[i], i)); + map<char, int> map02_ref; + for (size_t i = 0; i < N2; ++i) + map02_ref.insert(my_pair(title02[i], i)); + map<char, int> map03_ref; + for (size_t i = 0; i < N3; ++i) + map03_ref.insert(my_pair(title03[i], i)); + map<char, int> map04_ref; + for (size_t i = 0; i < N4; ++i) + map04_ref.insert(my_pair(title04[i], i)); + + my_map::size_type size01, size02; + + my_alloc alloc01(1); + + my_map map01(less<char>(), alloc01); + size01 = map01.size(); + my_map map02(less<char>(), alloc01); + size02 = map02.size(); + + map01.swap(map02); + VERIFY( map01.size() == size02 ); + VERIFY( map01.empty() ); + VERIFY( map02.size() == size01 ); + VERIFY( map02.empty() ); + + my_map map03(less<char>(), alloc01); + size01 = map03.size(); + my_map map04(map02_ref.begin(), map02_ref.end(), less<char>(), alloc01); + size02 = map04.size(); + + map03.swap(map04); + VERIFY( map03.size() == size02 ); + VERIFY( equal(map03.begin(), map03.end(), map02_ref.begin()) ); + VERIFY( map04.size() == size01 ); + VERIFY( map04.empty() ); + + my_map map05(map01_ref.begin(), map01_ref.end(), less<char>(), alloc01); + size01 = map05.size(); + my_map map06(map02_ref.begin(), map02_ref.end(), less<char>(), alloc01); + size02 = map06.size(); + + map05.swap(map06); + VERIFY( map05.size() == size02 ); + VERIFY( equal(map05.begin(), map05.end(), map02_ref.begin()) ); + VERIFY( map06.size() == size01 ); + VERIFY( equal(map06.begin(), map06.end(), map01_ref.begin()) ); + + my_map map07(map01_ref.begin(), map01_ref.end(), less<char>(), alloc01); + size01 = map07.size(); + my_map map08(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size02 = map08.size(); + + map07.swap(map08); + VERIFY( map07.size() == size02 ); + VERIFY( equal(map07.begin(), map07.end(), map03_ref.begin()) ); + VERIFY( map08.size() == size01 ); + VERIFY( equal(map08.begin(), map08.end(), map01_ref.begin()) ); + + my_map map09(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size01 = map09.size(); + my_map map10(map04_ref.begin(), map04_ref.end(), less<char>(), alloc01); + size02 = map10.size(); + + map09.swap(map10); + VERIFY( map09.size() == size02 ); + VERIFY( equal(map09.begin(), map09.end(), map04_ref.begin()) ); + VERIFY( map10.size() == size01 ); + VERIFY( equal(map10.begin(), map10.end(), map03_ref.begin()) ); + + my_map map11(map04_ref.begin(), map04_ref.end(), less<char>(), alloc01); + size01 = map11.size(); + my_map map12(map01_ref.begin(), map01_ref.end(), less<char>(), alloc01); + size02 = map12.size(); + + map11.swap(map12); + VERIFY( map11.size() == size02 ); + VERIFY( equal(map11.begin(), map11.end(), map01_ref.begin()) ); + VERIFY( map12.size() == size01 ); + VERIFY( equal(map12.begin(), map12.end(), map04_ref.begin()) ); + + my_map map13(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size01 = map13.size(); + my_map map14(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size02 = map14.size(); + + map13.swap(map14); + VERIFY( map13.size() == size02 ); + VERIFY( equal(map13.begin(), map13.end(), map03_ref.begin()) ); + VERIFY( map14.size() == size01 ); + VERIFY( equal(map14.begin(), map14.end(), map03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc new file mode 100644 index 000000000..a94b2127b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc @@ -0,0 +1,175 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.1 map::swap + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair<const char, int> my_pair; + typedef __gnu_test::uneq_allocator<my_pair> my_alloc; + typedef map<char, int, less<char>, my_alloc> my_map; + + 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); + + map<char, int> map01_ref; + for (size_t i = 0; i < N1; ++i) + map01_ref.insert(my_pair(title01[i], i)); + map<char, int> map02_ref; + for (size_t i = 0; i < N2; ++i) + map02_ref.insert(my_pair(title02[i], i)); + map<char, int> map03_ref; + for (size_t i = 0; i < N3; ++i) + map03_ref.insert(my_pair(title03[i], i)); + map<char, int> map04_ref; + for (size_t i = 0; i < N4; ++i) + map04_ref.insert(my_pair(title04[i], i)); + + my_map::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_map map01(less<char>(), alloc01); + size01 = map01.size(); + personality01 = map01.get_allocator().get_personality(); + my_map map02(less<char>(), alloc02); + size02 = map02.size(); + personality02 = map02.get_allocator().get_personality(); + + map01.swap(map02); + VERIFY( map01.size() == size02 ); + VERIFY( map01.empty() ); + VERIFY( map02.size() == size01 ); + VERIFY( map02.empty() ); + VERIFY( map01.get_allocator().get_personality() == personality02 ); + VERIFY( map02.get_allocator().get_personality() == personality01 ); + + my_map map03(less<char>(), alloc02); + size01 = map03.size(); + personality01 = map03.get_allocator().get_personality(); + my_map map04(map02_ref.begin(), map02_ref.end(), less<char>(), alloc01); + size02 = map04.size(); + personality02 = map04.get_allocator().get_personality(); + + map03.swap(map04); + VERIFY( map03.size() == size02 ); + VERIFY( equal(map03.begin(), map03.end(), map02_ref.begin()) ); + VERIFY( map04.size() == size01 ); + VERIFY( map04.empty() ); + VERIFY( map03.get_allocator().get_personality() == personality02 ); + VERIFY( map04.get_allocator().get_personality() == personality01 ); + + my_map map05(map01_ref.begin(), map01_ref.end(), less<char>(), alloc01); + size01 = map05.size(); + personality01 = map05.get_allocator().get_personality(); + my_map map06(map02_ref.begin(), map02_ref.end(), less<char>(), alloc02); + size02 = map06.size(); + personality02 = map06.get_allocator().get_personality(); + + map05.swap(map06); + VERIFY( map05.size() == size02 ); + VERIFY( equal(map05.begin(), map05.end(), map02_ref.begin()) ); + VERIFY( map06.size() == size01 ); + VERIFY( equal(map06.begin(), map06.end(), map01_ref.begin()) ); + VERIFY( map05.get_allocator().get_personality() == personality02 ); + VERIFY( map06.get_allocator().get_personality() == personality01 ); + + my_map map07(map01_ref.begin(), map01_ref.end(), less<char>(), alloc02); + size01 = map07.size(); + personality01 = map07.get_allocator().get_personality(); + my_map map08(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size02 = map08.size(); + personality02 = map08.get_allocator().get_personality(); + + map07.swap(map08); + VERIFY( map07.size() == size02 ); + VERIFY( equal(map07.begin(), map07.end(), map03_ref.begin()) ); + VERIFY( map08.size() == size01 ); + VERIFY( equal(map08.begin(), map08.end(), map01_ref.begin()) ); + VERIFY( map07.get_allocator().get_personality() == personality02 ); + VERIFY( map08.get_allocator().get_personality() == personality01 ); + + my_map map09(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size01 = map09.size(); + personality01 = map09.get_allocator().get_personality(); + my_map map10(map04_ref.begin(), map04_ref.end(), less<char>(), alloc02); + size02 = map10.size(); + personality02 = map10.get_allocator().get_personality(); + + map09.swap(map10); + VERIFY( map09.size() == size02 ); + VERIFY( equal(map09.begin(), map09.end(), map04_ref.begin()) ); + VERIFY( map10.size() == size01 ); + VERIFY( equal(map10.begin(), map10.end(), map03_ref.begin()) ); + VERIFY( map09.get_allocator().get_personality() == personality02 ); + VERIFY( map10.get_allocator().get_personality() == personality01 ); + + my_map map11(map04_ref.begin(), map04_ref.end(), less<char>(), alloc02); + size01 = map11.size(); + personality01 = map11.get_allocator().get_personality(); + my_map map12(map01_ref.begin(), map01_ref.end(), less<char>(), alloc01); + size02 = map12.size(); + personality02 = map12.get_allocator().get_personality(); + + map11.swap(map12); + VERIFY( map11.size() == size02 ); + VERIFY( equal(map11.begin(), map11.end(), map01_ref.begin()) ); + VERIFY( map12.size() == size01 ); + VERIFY( equal(map12.begin(), map12.end(), map04_ref.begin()) ); + VERIFY( map11.get_allocator().get_personality() == personality02 ); + VERIFY( map12.get_allocator().get_personality() == personality01 ); + + my_map map13(map03_ref.begin(), map03_ref.end(), less<char>(), alloc01); + size01 = map13.size(); + personality01 = map13.get_allocator().get_personality(); + my_map map14(map03_ref.begin(), map03_ref.end(), less<char>(), alloc02); + size02 = map14.size(); + personality02 = map14.get_allocator().get_personality(); + + map13.swap(map14); + VERIFY( map13.size() == size02 ); + VERIFY( equal(map13.begin(), map13.end(), map03_ref.begin()) ); + VERIFY( map14.size() == size01 ); + VERIFY( equal(map14.begin(), map14.end(), map03_ref.begin()) ); + VERIFY( map13.get_allocator().get_personality() == personality02 ); + VERIFY( map14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/1.cc new file mode 100644 index 000000000..24638765b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/1.cc @@ -0,0 +1,127 @@ +// 2006-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <map> +#include <testsuite_hooks.h> + +// A few tests for equal_range, in the occasion of libstdc++/29385. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map<int, int> m0; + typedef map<int, int>::iterator iterator; + typedef pair<iterator, bool> insert_return_type; + pair<iterator, iterator> pp0; + typedef map<int, int>::value_type value_type; + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 0 ); + VERIFY( pp0.first == m0.end() ); + VERIFY( pp0.second == m0.end() ); + + insert_return_type irt0 = m0.insert(value_type(1, 1)); + insert_return_type irt1 = m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + + pp0 = m0.equal_range(2); + VERIFY( m0.count(2) == 1 ); + VERIFY( *pp0.first == value_type(2, 2) ); + VERIFY( *pp0.second == value_type(3, 3) ); + VERIFY( pp0.first == irt1.first ); + VERIFY( --pp0.first == irt0.first ); + VERIFY( pp0.second == irt2.first ); + + m0.insert(value_type(3, 4)); + insert_return_type irt3 = m0.insert(value_type(3, 5)); + insert_return_type irt4 = m0.insert(value_type(4, 6)); + + pp0 = m0.equal_range(3); + VERIFY( m0.count(3) == 1 ); + VERIFY( *pp0.first == value_type(3, 3) ); + VERIFY( *pp0.second == value_type(4, 6) ); + VERIFY( pp0.first == irt2.first ); + VERIFY( --pp0.first == irt1.first ); + VERIFY( pp0.second == irt4.first ); + + insert_return_type irt5 = m0.insert(value_type(0, 7)); + m0.insert(value_type(1, 8)); + m0.insert(value_type(1, 9)); + m0.insert(value_type(1, 10)); + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 1 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt5.first ); + VERIFY( pp0.second == irt1.first ); + + insert_return_type irt6 = m0.insert(value_type(5, 11)); + m0.insert(value_type(5, 12)); + m0.insert(value_type(5, 13)); + + pp0 = m0.equal_range(5); + VERIFY( m0.count(5) == 1 ); + VERIFY( *pp0.first == value_type(5, 11) ); + VERIFY( pp0.first == irt6.first ); + VERIFY( --pp0.first == irt4.first ); + VERIFY( pp0.second == m0.end() ); + + m0.insert(value_type(4, 14)); + m0.insert(value_type(4, 15)); + m0.insert(value_type(4, 16)); + + pp0 = m0.equal_range(4); + VERIFY( m0.count(4) == 1 ); + VERIFY( *pp0.first == value_type(4, 6) ); + VERIFY( *pp0.second == value_type(5, 11) ); + VERIFY( pp0.first == irt4.first ); + VERIFY( --pp0.first == irt3.first ); + VERIFY( pp0.second == irt6.first ); + + m0.insert(value_type(0, 17)); + insert_return_type irt7 = m0.insert(value_type(0, 18)); + m0.insert(value_type(1, 19)); + + pp0 = m0.equal_range(0); + VERIFY( m0.count(0) == 1 ); + VERIFY( *pp0.first == value_type(0, 7) ); + VERIFY( *pp0.second == value_type(1, 1) ); + VERIFY( pp0.first == irt5.first ); + VERIFY( pp0.first == m0.begin() ); + VERIFY( pp0.second == irt0.first ); + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 1 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt7.first); + VERIFY( pp0.second == irt1.first ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc new file mode 100644 index 000000000..8df23234b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc @@ -0,0 +1,52 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <map> + +// libstdc++/31440 +struct DagNode +{ }; + +class MemoTable +{ +public: + void memoRewrite(); + +private: + struct dagNodeLt; + class MemoMap; + + MemoMap* memoMap; +}; + +struct MemoTable::dagNodeLt +{ + bool operator()(const DagNode*, const DagNode*); +}; + +class MemoTable::MemoMap +: public std::map<DagNode*, DagNode*, MemoTable::dagNodeLt> +{ }; + +void +MemoTable::memoRewrite() +{ + memoMap->find(0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/count.cc new file mode 100644 index 000000000..7e974c68f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operations/count.cc @@ -0,0 +1,106 @@ +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef map<int, int>::value_type value_type; + + map<int, int> m0; + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 0 ); + + m0.insert(value_type(1, 1)); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 1 ); + + m0.insert(value_type(1, 2)); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 1 ); + + m0.insert(value_type(2, 1)); + VERIFY( m0.count(2) == 1 ); + + m0.insert(value_type(3, 1)); + m0.insert(value_type(3, 2)); + m0.insert(value_type(3, 3)); + VERIFY( m0.count(3) == 1 ); + + m0.erase(2); + VERIFY( m0.count(2) == 0 ); + + m0.erase(0); + VERIFY( m0.count(0) == 0 ); + + map<int, int> m1(m0); + VERIFY( m1.count(0) == 0 ); + VERIFY( m1.count(1) == 1 ); + VERIFY( m1.count(2) == 0 ); + VERIFY( m1.count(3) == 1 ); + + m0.clear(); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 0 ); + VERIFY( m0.count(2) == 0 ); + VERIFY( m0.count(3) == 0 ); + + m1.insert(value_type(4, 1)); + m1.insert(value_type(5, 1)); + m1.insert(value_type(5, 2)); + m1.insert(value_type(5, 3)); + m1.insert(value_type(5, 4)); + VERIFY( m1.count(4) == 1 ); + VERIFY( m1.count(5) == 1 ); + + m1.erase(1); + VERIFY( m1.count(1) == 0 ); + + m1.erase(m1.find(5)); + VERIFY( m1.count(5) == 0 ); + + m1.insert(value_type(1, 1)); + m1.insert(value_type(1, 2)); + VERIFY( m1.count(1) == 1 ); + + m1.erase(5); + VERIFY( m1.count(5) == 0 ); + + m1.erase(m1.find(4)); + VERIFY( m1.count(4) == 0 ); + + m1.clear(); + VERIFY( m1.count(0) == 0 ); + VERIFY( m1.count(1) == 0 ); + VERIFY( m1.count(2) == 0 ); + VERIFY( m1.count(3) == 0 ); + VERIFY( m1.count(4) == 0 ); + VERIFY( m1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1.cc new file mode 100644 index 000000000..bbb4576d1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1.cc @@ -0,0 +1,48 @@ +// 2000-09-07 bgarcia@laurelnetworks.com + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 template class multiset + +#include <map> +#include <string> +#include <iostream> + +// libstdc++/737 +// http://gcc.gnu.org/ml/libstdc++/2000-11/msg00093.html +void test02() +{ + typedef std::map<int, int> MapInt; + + MapInt m; + + for (unsigned i = 0; i < 10; ++i) + m.insert(MapInt::value_type(i,i)); + + for (MapInt::const_iterator i = m.begin(); i != m.end(); ++i) + std::cerr << i->second << ' '; + + for (MapInt::const_iterator i = m.begin(); m.end() != i; ++i) + std::cerr << i->second << ' '; +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc new file mode 100644 index 000000000..9ab86de1c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc @@ -0,0 +1,42 @@ +// { dg-do compile } + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 template class multiset negative tests +// 2000-09-07 bgarcia@laurelnetworks.com + +#include <map> +#include <string> + +// libstdc++/86: map & set iterator comparisons are not type-safe +void test01() +{ + bool test __attribute__((unused)) = true; + std::map<unsigned int, int> mapByIndex; + std::map<std::string, unsigned> mapByName; + + mapByIndex.insert(std::pair<unsigned, int>(0, 1)); + mapByIndex.insert(std::pair<unsigned, int>(6, 5)); + + std::map<unsigned, int>::iterator itr(mapByIndex.begin()); + + // NB: notice, it's not mapByIndex!! + test &= itr != mapByName.end(); // { dg-error "no" } + test &= itr == mapByName.end(); // { dg-error "no" } +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/2.cc new file mode 100644 index 000000000..53c1adbf3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/operators/2.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// This test verifies that the value type of a map need not be default copyable. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> +#include <testsuite_counter_type.h> + +struct Mapped +{ + Mapped() = default; + explicit Mapped(const Mapped&) = default; +}; + +struct DefaultConstructibleType +{ + int val; + + DefaultConstructibleType() : val(123) + {} + + DefaultConstructibleType(const DefaultConstructibleType&) = delete; + DefaultConstructibleType(DefaultConstructibleType&&) = delete; + + DefaultConstructibleType& operator=(int x) + { + val = x; + return *this; + } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using __gnu_test::rvalstruct; + using __gnu_test::counter_type; + + std::map<int, Mapped> m1; + m1[0] = Mapped(); + + std::map<int, rvalstruct> m2; + m2[0] = rvalstruct(13); + + std::map<int, DefaultConstructibleType> m3; + VERIFY( m3[0].val == 123 ); + VERIFY( m3.size() == 1 ); + m3[0] = 2; + VERIFY( m3[0].val == 2 ); + + std::map<counter_type, int> m4; + VERIFY( m4[counter_type(1)] == 0 ); + VERIFY( counter_type::specialize_count == 1 ); + VERIFY( counter_type::copy_count == 0 ); + VERIFY( counter_type::move_count == 1 ); + + counter_type k(2); + counter_type::reset(); + + VERIFY( m4[k] == 0 ); + VERIFY( counter_type::copy_count == 1 ); + VERIFY( counter_type::move_count == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/pthread6.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/pthread6.cc new file mode 100644 index 000000000..74027bb97 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/pthread6.cc @@ -0,0 +1,86 @@ +// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org> +// Adpated from libstdc++/5444 submitted by markus.breuer@materna.de +// +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options "-pthreads" { target *-*-solaris* } } + +#include <string> +#include <map> +#include <vector> +#include <pthread.h> + +const int max_thread_count = 8; +const int loops = 100000; + +const char* my_default = "Hallo Welt!"; + +const std::size_t upper_limit = 2500; +const std::size_t lower_limit = 1000; + +typedef char charT; + +typedef std::string String; + +typedef String MyType; + +void* +thread_main (void*) +{ + typedef std::map<unsigned int,MyType> Map; + typedef Map::value_type Value_Pair; + Map myMap; + + for (int loop = 0; loop < loops; loop++) + { + String& str = myMap[loop]; + str.append (my_default); + myMap.insert (Value_Pair (loop, str)); + + if (myMap.size () > upper_limit) + { + while (myMap.size () > lower_limit) + { + Map::iterator it = myMap.begin (); + myMap.erase (it); + } + } + } + + return 0; +} + +int +main (void) +{ + pthread_t tid[max_thread_count]; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (max_thread_count); +#endif + + for (int i = 0; i < max_thread_count; i++) + pthread_create (&tid[i], 0, thread_main, 0); + + for (int i = 0; i < max_thread_count; i++) + pthread_join (tid[i], 0); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/range_access.cc new file mode 100644 index 000000000..442b82e1a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <map> + +void +test01() +{ + std::map<int, double> m{{1, 1.0}, {2, 2.0}, {3, 3.0}}; + std::begin(m); + std::end(m); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc new file mode 100644 index 000000000..3cc7a3ef5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::map<int, int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc new file mode 100644 index 000000000..67dc49b30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::map<key_type, key_type, compare_type, allocator_type> test_type; + + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..d890a28a9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::map<key_type, key_type, compare_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..9fd5e1fe8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::map<key_type, key_type, compare_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..8b342b1ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +template class std::map<int, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..b27c166e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> + +template class std::map<int, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..6b71a64d3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// N.B. We cannot instantiate with T == NonDefaultConstructible +// because of 23.3.1.2. +template class std::map<__gnu_test::NonDefaultConstructible, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..3d71502b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +// libstdc++/21770 +template class std::map<int, double, std::less<int>, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..244854be4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2010-2014 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::map<__gnu_test::OverloadedAddress, + __gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..dfc0317ea --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::map<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int> >; +template class std::map<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc new file mode 100644 index 000000000..b790eba30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/5_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::map<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::map<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..9d3cbae4d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <map> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Data, typename Allocator> + class map<user_type, Data, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc new file mode 100644 index 000000000..4eeac3e53 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <map> + +// Check container for required typedefs. +__gnu_test::types<std::map<int, long> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/14340.cc new file mode 100644 index 000000000..7f0ad3c53 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <map> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::multimap<int, int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/23781_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/23781_neg.cc new file mode 100644 index 000000000..56963fc95 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/23781_neg.cc @@ -0,0 +1,28 @@ +// 2005-09-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +// libstdc++/23781 +#include <map> +#include <cstddef> + +std::multimap<int, int>::iterator it = NULL; // { dg-error "conversion" } +std::multimap<int, int>::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/58764.cc new file mode 100644 index 000000000..4e8511672 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <map> + +void test01() +{ + std::multimap<int, int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy.cc new file mode 100644 index 000000000..ed3fe6738 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy.cc @@ -0,0 +1,76 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy_assign.cc new file mode 100644 index 000000000..4c9c37104 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/copy_assign.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/minimal.cc new file mode 100644 index 000000000..8257c6e97 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/minimal.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::SimpleAllocator; + +template class std::multimap<T, U, Cmp, SimpleAllocator<std::pair<const T, U>>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<std::pair<const T, U>> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v(alloc_type{}); + v = { test_type::value_type{} }; + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move.cc new file mode 100644 index 000000000..5e24475e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<std::pair<const T, U>> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<std::pair<const T, U>> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc new file mode 100644 index 000000000..119b13058 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc new file mode 100644 index 000000000..62fd603f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<std::pair<const T, U>> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/swap.cc new file mode 100644 index 000000000..daea78e81 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/allocator/swap.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<std::pair<const T, U>, false>&, + const propagating_allocator<std::pair<const T, U>, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<std::pair<const T, U>, false>&, + const propagating_allocator<std::pair<const T, U>, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, false> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, U>, true> alloc_type; + typedef std::multimap<T, U, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc new file mode 100644 index 000000000..43bf5ce8b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.2 multimap capacity + +#include <map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::multimap<int, int> mm; + + VERIFY( (mm.max_size() == std::allocator<std::_Rb_tree_node< + std::pair<const int, int> > >().max_size()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/moveable.cc new file mode 100644 index 000000000..a89009f27 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on multimap (via swap). If the implementation changed +// this test may begin to fail. + +#include <map> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::multimap<int, int> a,b; + a.insert(std::make_pair(2,0)); + b.insert(std::make_pair(1,0)); + b = std::move(a); + VERIFY(b.find(2) != b.end() && a.find(1) == a.end()); + + std::multimap<int, int> c(std::move(b)); + VERIFY( c.find(2) != c.end()); + VERIFY( b.find(2) == b.end()); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..e1efb7a33 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> + +typedef std::multimap<int, int> mmtype; + +static_assert(std::is_nothrow_move_constructible<mmtype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc new file mode 100644 index 000000000..38b8bcd73 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <map> + +std::multimap<int, int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc new file mode 100644 index 000000000..437b7d6b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc new file mode 100644 index 000000000..77e341a16 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc new file mode 100644 index 000000000..d590b6a04 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct4_neg.cc new file mode 100644 index 000000000..32cf05d38 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc new file mode 100644 index 000000000..c8dad663d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc new file mode 100644 index 000000000..4ec9dd24e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc new file mode 100644 index 000000000..9c1841ef0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert4_neg.cc new file mode 100644 index 000000000..bed6191f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/1.cc new file mode 100644 index 000000000..9e9d92742 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/1.cc @@ -0,0 +1,52 @@ +// Multimap iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/map> +#include <iterator> +#include <testsuite_hooks.h> +#include <utility> + +using __gnu_debug::multimap; +using std::advance; + +bool test = true; + +// Assignment +void test01() +{ + multimap<int, int> v1; + multimap<int, int> v2; + + v1.insert(std::make_pair(17, 42)); + + multimap<int, int>::iterator start = v1.begin(); + multimap<int, int>::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/2.cc new file mode 100644 index 000000000..e0abc9de2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/invalidation/2.cc @@ -0,0 +1,71 @@ +// Multimap iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/map> +#include <iterator> +#include <testsuite_hooks.h> +#include <utility> + +using __gnu_debug::multimap; +using std::advance; + +bool test = true; + +// Erase +void test02() +{ + multimap<int, int> v; + for (int i = 0; i < 20; ++i) + v.insert(std::make_pair(i, 20-i)); + + // Single element erase (middle) + multimap<int, int>::iterator before = v.begin(); + multimap<int, int>::iterator at = before; + advance(at, 3); + multimap<int, int>::iterator after = at; + ++after; + v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 4); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + multimap<int, int>::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..deda713c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <map> + +void test01() +{ + std::multimap<int, int> mm1; + auto it1 = mm1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..2bba545bc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <map> + +void test01() +{ + std::multimap<int, int> mm1; + mm1 = std::move(mm1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc new file mode 100644 index 000000000..88e49fc02 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + typedef multimap<int,double> Container; + typedef Container::iterator iterator; + typedef pair<iterator,iterator> itpair; + Container m({ { 1, 1.0 }, { 1, 2.0 }, { 1, 237.0 } }); + VERIFY(m.size() == 3); + itpair ip = m.equal_range(1); + VERIFY(distance(ip.first, ip.second) == 3); + iterator i = ip.first; + VERIFY((*i++).second == 1.0); + VERIFY((*i++).second == 2.0); + VERIFY((*i++).second == 237.0); + + m = { {5, 55.0}, { 5, 66.0 }, { 42, 4242.0 } }; + VERIFY(m.size() == 3); + ip = m.equal_range(5); + VERIFY(distance(ip.first, ip.second) == 2); + i = ip.first; + VERIFY((*i++).second == 55.0); + VERIFY((*i++).second == 66.0); + + m.insert({ { 7, 77.0 }, { 7, 88.0 } }); + VERIFY(m.size() == 5); + VERIFY(m.count(5) == 2); + VERIFY(m.count(42) == 1); + VERIFY(m.count(7) == 2); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/dr130.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/dr130.cc new file mode 100644 index 000000000..c62fefdca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/dr130.cc @@ -0,0 +1,87 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on multiset (via swap). If the implementation changed +// this test may begin to fail. + +#include <map> +#include <vector> +#include <testsuite_hooks.h> + +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multimap<int, int> mm0; + typedef multimap<int, int>::iterator iterator; + typedef multimap<int, int>::const_iterator const_iterator; + typedef multimap<int, int>::value_type value_type; + typedef iterator insert_return_type; + + vector<insert_return_type> irt; + for (int i = 1; i <= 4; ++i) + for (int j = 1; j <= i; ++j) + irt.push_back( mm0.insert( value_type( i, i ) ) ); + + iterator pos1 = mm0.erase(irt[1]); + VERIFY( pos1 == irt[2] ); + + iterator pos2 = mm0.erase(irt[2]); + VERIFY( pos2 == irt[3] ); + + iterator pos3 = mm0.erase(irt[9]); + VERIFY( pos3 == mm0.end() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multimap<int, int> mm0; + typedef multimap<int, int>::iterator iterator; + typedef multimap<int, int>::const_iterator const_iterator; + typedef multimap<int, int>::value_type value_type; + typedef iterator insert_return_type; + + vector<insert_return_type> irt; + for (int i = 1; i <= 4; ++i) + for (int j = 1; j <= i; ++j) + irt.push_back( mm0.insert( value_type( i, i ) ) ); + + iterator pos1 = mm0.erase(irt[3], irt[6]); + VERIFY( pos1 == irt[6] ); + + iterator pos2 = mm0.erase(irt[6], ++irt[9]); + VERIFY( pos2 == mm0.end() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc new file mode 100644 index 000000000..fa98f4329 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> +#include <vector> +#include <map> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::multimap<char, std::vector<double>> MMap; + MMap mm; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = mm.emplace('a', coord1); + VERIFY( mm.size() == 1 ); + VERIFY( it->first == 'a' ); + + coord1[0] = 3.0; + it = mm.emplace('a', coord1); + VERIFY( mm.size() == 2 ); + VERIFY( it->first == 'a' ); + VERIFY( it->second[0] == 3.0 ); + + it = mm.emplace_hint(mm.begin(), 'b', coord1); + VERIFY( it != mm.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second[0] == 3.0 ); + + double *px = &coord1[0]; + it = mm.emplace('c', std::move(coord1)); + VERIFY( it->first == 'c' ); + VERIFY( &(it->second[0]) == px ); +} + +void test02() +{ + using namespace std; + typedef multimap<char, PathPoint> Map; + Map m; + + vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple('a', coord1)); + VERIFY( m.size() == 1 ); + VERIFY( it->first == 'a' ); + + coord1[0] = 3.0; + it = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple( 'b', coord1)); + VERIFY( m.size() == 2 ); + VERIFY( it->first == 'a' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + it = m.emplace_hint(m.begin(), piecewise_construct, + make_tuple('b'), make_tuple('c', coord1)); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + it = m.emplace(piecewise_construct, + make_tuple('c'), make_tuple('d', move(coord1))); + VERIFY( it->first == 'c' ); + VERIFY( &(it->second.getCoords()[0]) == px ); +} + + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/47628.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/47628.cc new file mode 100644 index 000000000..22ee17f65 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/47628.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +#include <map> + +struct Key +{ + Key() { } + + Key(const Key&) { } + + template<typename T> + Key(const T&) + { } + + bool operator<(const Key&) const; +}; + +#if __cplusplus < 201103L +// libstdc++/47628 +void f() +{ + typedef std::multimap<Key, int> MMap; + MMap mm; + mm.insert(MMap::value_type()); + MMap::iterator i = mm.begin(); + mm.erase(i); +} +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc new file mode 100644 index 000000000..a0d00d179 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::multimap<X, int>& s, X x) +{ + std::multimap<X, int>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/abi_tag.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/abi_tag.cc new file mode 100644 index 000000000..fe2f5808b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/abi_tag.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options -std=c++11 } +// { dg-require-normal-mode "" } + +// Copyright (C) 2013-2014 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// Test that the C++11 variants have an ABI tag + +#include <map> + +using container = std::multimap<int, int>; +using iterator = typename container::iterator; +using const_iterator = typename container::const_iterator; + +// { dg-final { scan-assembler "_ZNSt8multimapIiiSt4lessIiESaISt4pairIKiiEEE5eraseB5cxx11ESt17_Rb_tree_iteratorIS4_E" } } +iterator (container::*p1)(iterator) = &container::erase; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/dr130-linkage-check.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/dr130-linkage-check.cc new file mode 100644 index 000000000..4a614fd25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/dr130-linkage-check.cc @@ -0,0 +1,40 @@ +// { dg-require-effective-target ia32 } +// { dg-require-sharedlib "" } +// { dg-options "-fno-inline -std=gnu++11 ./testsuite_shared.so" } +// 2013-06-03 Benjamin Kosnik <bkoz@redhat..com> +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> + +int main() +{ + typedef std::multimap<int, int> container_type; + + { + container_type s { {0,0} , {1,1} , {2,2} }; + __gnu_test::linkage_check_cxx98_cxx11_erase(s); + } + + { + container_type s { {0,0} , {1,1} , {2,2} }; + __gnu_test::linkage_check_cxx98_cxx11_erase_iterators(s); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc new file mode 100644 index 000000000..69905dce4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(Pair(1, rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( i->first == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + m.insert(Pair(2, rvalstruct(3))); + m.insert(Pair(2, rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( i1->first == 2 ); + VERIFY( i2->first == 2 ); + VERIFY( (i1->second).val == 3 && (i2->second).val == 7 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc new file mode 100644 index 000000000..25e964a4e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(Pair(rvalstruct(1), rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( (i->first).val == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + m.insert(Pair(rvalstruct(2), rvalstruct(3))); + m.insert(Pair(rvalstruct(2), rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( (i1->first).val == 2 ); + VERIFY( (i2->first).val == 2 ); + VERIFY( (i1->second).val == 3 && (i2->second).val == 7 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc new file mode 100644 index 000000000..4708b0b22 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc @@ -0,0 +1,140 @@ +// 2006-01-07 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.2 Class template multimap + +#include <map> +#include <testsuite_hooks.h> + +// libstdc++/22102 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::multimap<int, int> Mmap; + typedef Mmap::value_type value_type; + typedef Mmap::iterator iterator; + + Mmap mm1; + + const iterator it1 = mm1.insert(value_type(0, 0)); + const iterator it2 = mm1.insert(value_type(1, 1)); + const iterator it3 = mm1.insert(value_type(2, 2)); + + const value_type vt1(2, 1); + const iterator it4 = mm1.insert(it1, vt1); + iterator it5 = it4; + iterator it6 = it4; + VERIFY( mm1.size() == 4 ); + VERIFY( *it4 == vt1 ); + VERIFY( ++it5 == it3 ); + VERIFY( --it6 == it2 ); + VERIFY( *it5 == *it3 ); + VERIFY( *it6 == *it2 ); + + const value_type vt2(2, 0); + const iterator it7 = mm1.insert(mm1.begin(), vt2); + iterator it8 = it7; + iterator it9 = it7; + VERIFY( mm1.size() == 5 ); + VERIFY( *it7 == vt2 ); + VERIFY( ++it8 == it4 ); + VERIFY( --it9 == it2 ); + VERIFY( *it8 == *it4 ); + VERIFY( *it9 == *it2 ); + + const value_type vt3(2, -1); + const iterator it10 = mm1.insert(it1, vt3); + iterator it11 = it10; + iterator it12 = it10; + VERIFY( mm1.size() == 6 ); + VERIFY( *it10 == vt3 ); + VERIFY( ++it11 == it7 ); + VERIFY( --it12 == it2 ); + VERIFY( *it11 == *it7 ); + VERIFY( *it12 == *it2 ); + + const value_type vt4(0, 1); + const iterator it13 = mm1.insert(it10, vt4); + iterator it14 = it13; + iterator it15 = it13; + VERIFY( mm1.size() == 7 ); + VERIFY( *it13 == vt4 ); + VERIFY( ++it14 == it2 ); + VERIFY( --it15 == it1 ); + VERIFY( *it14 == *it2 ); + VERIFY( *it15 == *it1 ); + + const value_type vt5(1, 0); + const iterator it16 = mm1.insert(it13, vt5); + iterator it17 = it16; + iterator it18 = it16; + VERIFY( mm1.size() == 8 ); + VERIFY( *it16 == vt5 ); + VERIFY( ++it17 == it2 ); + VERIFY( --it18 == it13 ); + VERIFY( *it17 == *it2 ); + VERIFY( *it18 == *it13 ); + + const value_type vt6(0, -1); + const iterator it19 = mm1.insert(it1, vt6); + iterator it20 = it19; + VERIFY( mm1.size() == 9 ); + VERIFY( *it19 == vt6 ); + VERIFY( it19 == mm1.begin() ); + VERIFY( ++it20 == it1 ); + VERIFY( *it20 == *it1 ); + + const value_type vt7(3, 3); + const iterator it21 = mm1.insert(it19, vt7); + iterator it22 = it21; + iterator it23 = it21; + VERIFY( mm1.size() == 10 ); + VERIFY( *it21 == vt7 ); + VERIFY( ++it22 == mm1.end() ); + VERIFY( --it23 == it3 ); + VERIFY( *it23 == *it3 ); + + const value_type vt8(2, 3); + const iterator it24 = mm1.insert(mm1.end(), vt8); + iterator it25 = it24; + iterator it26 = it24; + VERIFY( mm1.size() == 11 ); + VERIFY( *it24 == vt8 ); + VERIFY( ++it25 == it21 ); + VERIFY( --it26 == it3 ); + VERIFY( *it25 == *it21 ); + VERIFY( *it26 == *it3 ); + + const value_type vt9(3, 2); + const iterator it27 = mm1.insert(it3, vt9); + iterator it28 = it27; + iterator it29 = it27; + VERIFY( mm1.size() == 12 ); + VERIFY( *it27 == vt9 ); + VERIFY( ++it28 == it21 ); + VERIFY( --it29 == it24 ); + VERIFY( *it28 == *it21 ); + VERIFY( *it29 == *it24 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc new file mode 100644 index 000000000..a7425512b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(m.begin(), Pair(1, rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( i->first == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i0 = m.insert(m.begin(), Pair(2, rvalstruct(3))); + m.insert(i0, Pair(2, rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( i1->first == 2 ); + VERIFY( i2->first == 2 ); + VERIFY( (i1->second).val == 7 && (i2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc new file mode 100644 index 000000000..94eca44e4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(m.begin(), + Pair(rvalstruct(1), rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( (i->first).val == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i0 = m.insert(Pair(rvalstruct(2), rvalstruct(3))); + m.insert(i0, Pair(rvalstruct(2), rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( (i1->first).val == 2 ); + VERIFY( (i2->first).val == 2 ); + VERIFY( (i1->second).val == 7 && (i2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc new file mode 100644 index 000000000..51586d1cd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_hooks.h> + +struct T { int i; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + multimap<T, int>::swap(multimap<T, int>&) + { ++swap_calls; } +} + +// Should use multimap specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::multimap<T, int> A; + std::multimap<T, int> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use multimap specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + multimap<T, int> A; + multimap<T, int> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/2.cc new file mode 100644 index 000000000..6a1e0d75b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/2.cc @@ -0,0 +1,146 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.2 multimap::swap + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair<const char, int> my_pair; + typedef __gnu_test::uneq_allocator<my_pair> my_alloc; + typedef multimap<char, int, less<char>, my_alloc> my_mmap; + + 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); + + multimap<char, int> mmap01_ref; + for (size_t i = 0; i < N1; ++i) + mmap01_ref.insert(my_pair(title01[i], i)); + multimap<char, int> mmap02_ref; + for (size_t i = 0; i < N2; ++i) + mmap02_ref.insert(my_pair(title02[i], i)); + multimap<char, int> mmap03_ref; + for (size_t i = 0; i < N3; ++i) + mmap03_ref.insert(my_pair(title03[i], i)); + multimap<char, int> mmap04_ref; + for (size_t i = 0; i < N4; ++i) + mmap04_ref.insert(my_pair(title04[i], i)); + + my_mmap::size_type size01, size02; + + my_alloc alloc01(1); + + my_mmap mmap01(less<char>(), alloc01); + size01 = mmap01.size(); + my_mmap mmap02(less<char>(), alloc01); + size02 = mmap02.size(); + + mmap01.swap(mmap02); + VERIFY( mmap01.size() == size02 ); + VERIFY( mmap01.empty() ); + VERIFY( mmap02.size() == size01 ); + VERIFY( mmap02.empty() ); + + my_mmap mmap03(less<char>(), alloc01); + size01 = mmap03.size(); + my_mmap mmap04(mmap02_ref.begin(), mmap02_ref.end(), less<char>(), alloc01); + size02 = mmap04.size(); + + mmap03.swap(mmap04); + VERIFY( mmap03.size() == size02 ); + VERIFY( equal(mmap03.begin(), mmap03.end(), mmap02_ref.begin()) ); + VERIFY( mmap04.size() == size01 ); + VERIFY( mmap04.empty() ); + + my_mmap mmap05(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc01); + size01 = mmap05.size(); + my_mmap mmap06(mmap02_ref.begin(), mmap02_ref.end(), less<char>(), alloc01); + size02 = mmap06.size(); + + mmap05.swap(mmap06); + VERIFY( mmap05.size() == size02 ); + VERIFY( equal(mmap05.begin(), mmap05.end(), mmap02_ref.begin()) ); + VERIFY( mmap06.size() == size01 ); + VERIFY( equal(mmap06.begin(), mmap06.end(), mmap01_ref.begin()) ); + + my_mmap mmap07(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc01); + size01 = mmap07.size(); + my_mmap mmap08(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size02 = mmap08.size(); + + mmap07.swap(mmap08); + VERIFY( mmap07.size() == size02 ); + VERIFY( equal(mmap07.begin(), mmap07.end(), mmap03_ref.begin()) ); + VERIFY( mmap08.size() == size01 ); + VERIFY( equal(mmap08.begin(), mmap08.end(), mmap01_ref.begin()) ); + + my_mmap mmap09(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size01 = mmap09.size(); + my_mmap mmap10(mmap04_ref.begin(), mmap04_ref.end(), less<char>(), alloc01); + size02 = mmap10.size(); + + mmap09.swap(mmap10); + VERIFY( mmap09.size() == size02 ); + VERIFY( equal(mmap09.begin(), mmap09.end(), mmap04_ref.begin()) ); + VERIFY( mmap10.size() == size01 ); + VERIFY( equal(mmap10.begin(), mmap10.end(), mmap03_ref.begin()) ); + + my_mmap mmap11(mmap04_ref.begin(), mmap04_ref.end(), less<char>(), alloc01); + size01 = mmap11.size(); + my_mmap mmap12(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc01); + size02 = mmap12.size(); + + mmap11.swap(mmap12); + VERIFY( mmap11.size() == size02 ); + VERIFY( equal(mmap11.begin(), mmap11.end(), mmap01_ref.begin()) ); + VERIFY( mmap12.size() == size01 ); + VERIFY( equal(mmap12.begin(), mmap12.end(), mmap04_ref.begin()) ); + + my_mmap mmap13(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size01 = mmap13.size(); + my_mmap mmap14(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size02 = mmap14.size(); + + mmap13.swap(mmap14); + VERIFY( mmap13.size() == size02 ); + VERIFY( equal(mmap13.begin(), mmap13.end(), mmap03_ref.begin()) ); + VERIFY( mmap14.size() == size01 ); + VERIFY( equal(mmap14.begin(), mmap14.end(), mmap03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/3.cc new file mode 100644 index 000000000..cf57f30bf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/3.cc @@ -0,0 +1,175 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.2 multimap::swap + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair<const char, int> my_pair; + typedef __gnu_test::uneq_allocator<my_pair> my_alloc; + typedef multimap<char, int, less<char>, my_alloc> my_mmap; + + 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); + + multimap<char, int> mmap01_ref; + for (size_t i = 0; i < N1; ++i) + mmap01_ref.insert(my_pair(title01[i], i)); + multimap<char, int> mmap02_ref; + for (size_t i = 0; i < N2; ++i) + mmap02_ref.insert(my_pair(title02[i], i)); + multimap<char, int> mmap03_ref; + for (size_t i = 0; i < N3; ++i) + mmap03_ref.insert(my_pair(title03[i], i)); + multimap<char, int> mmap04_ref; + for (size_t i = 0; i < N4; ++i) + mmap04_ref.insert(my_pair(title04[i], i)); + + my_mmap::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_mmap mmap01(less<char>(), alloc01); + size01 = mmap01.size(); + personality01 = mmap01.get_allocator().get_personality(); + my_mmap mmap02(less<char>(), alloc02); + size02 = mmap02.size(); + personality02 = mmap02.get_allocator().get_personality(); + + mmap01.swap(mmap02); + VERIFY( mmap01.size() == size02 ); + VERIFY( mmap01.empty() ); + VERIFY( mmap02.size() == size01 ); + VERIFY( mmap02.empty() ); + VERIFY( mmap01.get_allocator().get_personality() == personality02 ); + VERIFY( mmap02.get_allocator().get_personality() == personality01 ); + + my_mmap mmap03(less<char>(), alloc02); + size01 = mmap03.size(); + personality01 = mmap03.get_allocator().get_personality(); + my_mmap mmap04(mmap02_ref.begin(), mmap02_ref.end(), less<char>(), alloc01); + size02 = mmap04.size(); + personality02 = mmap04.get_allocator().get_personality(); + + mmap03.swap(mmap04); + VERIFY( mmap03.size() == size02 ); + VERIFY( equal(mmap03.begin(), mmap03.end(), mmap02_ref.begin()) ); + VERIFY( mmap04.size() == size01 ); + VERIFY( mmap04.empty() ); + VERIFY( mmap03.get_allocator().get_personality() == personality02 ); + VERIFY( mmap04.get_allocator().get_personality() == personality01 ); + + my_mmap mmap05(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc01); + size01 = mmap05.size(); + personality01 = mmap05.get_allocator().get_personality(); + my_mmap mmap06(mmap02_ref.begin(), mmap02_ref.end(), less<char>(), alloc02); + size02 = mmap06.size(); + personality02 = mmap06.get_allocator().get_personality(); + + mmap05.swap(mmap06); + VERIFY( mmap05.size() == size02 ); + VERIFY( equal(mmap05.begin(), mmap05.end(), mmap02_ref.begin()) ); + VERIFY( mmap06.size() == size01 ); + VERIFY( equal(mmap06.begin(), mmap06.end(), mmap01_ref.begin()) ); + VERIFY( mmap05.get_allocator().get_personality() == personality02 ); + VERIFY( mmap06.get_allocator().get_personality() == personality01 ); + + my_mmap mmap07(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc02); + size01 = mmap07.size(); + personality01 = mmap07.get_allocator().get_personality(); + my_mmap mmap08(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size02 = mmap08.size(); + personality02 = mmap08.get_allocator().get_personality(); + + mmap07.swap(mmap08); + VERIFY( mmap07.size() == size02 ); + VERIFY( equal(mmap07.begin(), mmap07.end(), mmap03_ref.begin()) ); + VERIFY( mmap08.size() == size01 ); + VERIFY( equal(mmap08.begin(), mmap08.end(), mmap01_ref.begin()) ); + VERIFY( mmap07.get_allocator().get_personality() == personality02 ); + VERIFY( mmap08.get_allocator().get_personality() == personality01 ); + + my_mmap mmap09(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size01 = mmap09.size(); + personality01 = mmap09.get_allocator().get_personality(); + my_mmap mmap10(mmap04_ref.begin(), mmap04_ref.end(), less<char>(), alloc02); + size02 = mmap10.size(); + personality02 = mmap10.get_allocator().get_personality(); + + mmap09.swap(mmap10); + VERIFY( mmap09.size() == size02 ); + VERIFY( equal(mmap09.begin(), mmap09.end(), mmap04_ref.begin()) ); + VERIFY( mmap10.size() == size01 ); + VERIFY( equal(mmap10.begin(), mmap10.end(), mmap03_ref.begin()) ); + VERIFY( mmap09.get_allocator().get_personality() == personality02 ); + VERIFY( mmap10.get_allocator().get_personality() == personality01 ); + + my_mmap mmap11(mmap04_ref.begin(), mmap04_ref.end(), less<char>(), alloc02); + size01 = mmap11.size(); + personality01 = mmap11.get_allocator().get_personality(); + my_mmap mmap12(mmap01_ref.begin(), mmap01_ref.end(), less<char>(), alloc01); + size02 = mmap12.size(); + personality02 = mmap12.get_allocator().get_personality(); + + mmap11.swap(mmap12); + VERIFY( mmap11.size() == size02 ); + VERIFY( equal(mmap11.begin(), mmap11.end(), mmap01_ref.begin()) ); + VERIFY( mmap12.size() == size01 ); + VERIFY( equal(mmap12.begin(), mmap12.end(), mmap04_ref.begin()) ); + VERIFY( mmap11.get_allocator().get_personality() == personality02 ); + VERIFY( mmap12.get_allocator().get_personality() == personality01 ); + + my_mmap mmap13(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc01); + size01 = mmap13.size(); + personality01 = mmap13.get_allocator().get_personality(); + my_mmap mmap14(mmap03_ref.begin(), mmap03_ref.end(), less<char>(), alloc02); + size02 = mmap14.size(); + personality02 = mmap14.get_allocator().get_personality(); + + mmap13.swap(mmap14); + VERIFY( mmap13.size() == size02 ); + VERIFY( equal(mmap13.begin(), mmap13.end(), mmap03_ref.begin()) ); + VERIFY( mmap14.size() == size01 ); + VERIFY( equal(mmap14.begin(), mmap14.end(), mmap03_ref.begin()) ); + VERIFY( mmap13.get_allocator().get_personality() == personality02 ); + VERIFY( mmap14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc new file mode 100644 index 000000000..8e414c7fe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/1.cc @@ -0,0 +1,126 @@ +// 2006-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <map> +#include <testsuite_hooks.h> + +// A few tests for equal_range, in the occasion of libstdc++/29385. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multimap<int, int> mm0; + typedef multimap<int, int>::iterator iterator; + pair<iterator, iterator> pp0; + typedef multimap<int, int>::value_type value_type; + + pp0 = mm0.equal_range(1); + VERIFY( mm0.count(1) == 0 ); + VERIFY( pp0.first == mm0.end() ); + VERIFY( pp0.second == mm0.end() ); + + iterator iter0 = mm0.insert(value_type(1, 1)); + iterator iter1 = mm0.insert(value_type(2, 2)); + iterator iter2 = mm0.insert(value_type(3, 3)); + + pp0 = mm0.equal_range(2); + VERIFY( mm0.count(2) == 1 ); + VERIFY( *pp0.first == value_type(2, 2) ); + VERIFY( *pp0.second == value_type(3, 3) ); + VERIFY( pp0.first == iter1 ); + VERIFY( --pp0.first == iter0 ); + VERIFY( pp0.second == iter2 ); + + mm0.insert(value_type(3, 4)); + iterator iter3 = mm0.insert(value_type(3, 5)); + iterator iter4 = mm0.insert(value_type(4, 6)); + + pp0 = mm0.equal_range(3); + VERIFY( mm0.count(3) == 3 ); + VERIFY( *pp0.first == value_type(3, 3) ); + VERIFY( *pp0.second == value_type(4, 6) ); + VERIFY( pp0.first == iter2 ); + VERIFY( --pp0.first == iter1 ); + VERIFY( pp0.second == iter4 ); + + iterator iter5 = mm0.insert(value_type(0, 7)); + mm0.insert(value_type(1, 8)); + mm0.insert(value_type(1, 9)); + mm0.insert(value_type(1, 10)); + + pp0 = mm0.equal_range(1); + VERIFY( mm0.count(1) == 4 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == iter0 ); + VERIFY( --pp0.first == iter5 ); + VERIFY( pp0.second == iter1 ); + + iterator iter6 = mm0.insert(value_type(5, 11)); + mm0.insert(value_type(5, 12)); + mm0.insert(value_type(5, 13)); + + pp0 = mm0.equal_range(5); + VERIFY( mm0.count(5) == 3 ); + VERIFY( *pp0.first == value_type(5, 11) ); + VERIFY( pp0.first == iter6 ); + VERIFY( --pp0.first == iter4 ); + VERIFY( pp0.second == mm0.end() ); + + mm0.insert(value_type(4, 14)); + mm0.insert(value_type(4, 15)); + mm0.insert(value_type(4, 16)); + + pp0 = mm0.equal_range(4); + VERIFY( mm0.count(4) == 4 ); + VERIFY( *pp0.first == value_type(4, 6) ); + VERIFY( *pp0.second == value_type(5, 11) ); + VERIFY( pp0.first == iter4 ); + VERIFY( --pp0.first == iter3 ); + VERIFY( pp0.second == iter6 ); + + mm0.insert(value_type(0, 17)); + iterator iter7 = mm0.insert(value_type(0, 18)); + mm0.insert(value_type(1, 19)); + + pp0 = mm0.equal_range(0); + VERIFY( mm0.count(0) == 3 ); + VERIFY( *pp0.first == value_type(0, 7) ); + VERIFY( *pp0.second == value_type(1, 1) ); + VERIFY( pp0.first == iter5 ); + VERIFY( pp0.first == mm0.begin() ); + VERIFY( pp0.second == iter0 ); + + pp0 = mm0.equal_range(1); + VERIFY( mm0.count(1) == 5 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == iter0 ); + VERIFY( --pp0.first == iter7 ); + VERIFY( pp0.second == iter1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc new file mode 100644 index 000000000..b44f8309d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc @@ -0,0 +1,106 @@ +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef multimap<int, int>::value_type value_type; + + multimap<int, int> mm0; + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 0 ); + + mm0.insert(value_type(1, 1)); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 1 ); + + mm0.insert(value_type(1, 2)); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 2 ); + + mm0.insert(value_type(2, 1)); + VERIFY( mm0.count(2) == 1 ); + + mm0.insert(value_type(3, 1)); + mm0.insert(value_type(3, 2)); + mm0.insert(value_type(3, 3)); + VERIFY( mm0.count(3) == 3 ); + + mm0.erase(2); + VERIFY( mm0.count(2) == 0 ); + + mm0.erase(0); + VERIFY( mm0.count(0) == 0 ); + + multimap<int, int> mm1(mm0); + VERIFY( mm1.count(0) == 0 ); + VERIFY( mm1.count(1) == 2 ); + VERIFY( mm1.count(2) == 0 ); + VERIFY( mm1.count(3) == 3 ); + + mm0.clear(); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 0 ); + VERIFY( mm0.count(2) == 0 ); + VERIFY( mm0.count(3) == 0 ); + + mm1.insert(value_type(4, 1)); + mm1.insert(value_type(5, 1)); + mm1.insert(value_type(5, 2)); + mm1.insert(value_type(5, 3)); + mm1.insert(value_type(5, 4)); + VERIFY( mm1.count(4) == 1 ); + VERIFY( mm1.count(5) == 4 ); + + mm1.erase(1); + VERIFY( mm1.count(1) == 0 ); + + mm1.erase(mm1.find(5)); + VERIFY( mm1.count(5) == 3 ); + + mm1.insert(value_type(1, 1)); + mm1.insert(value_type(1, 2)); + VERIFY( mm1.count(1) == 2 ); + + mm1.erase(5); + VERIFY( mm1.count(5) == 0 ); + + mm1.erase(mm1.find(4)); + VERIFY( mm1.count(4) == 0 ); + + mm1.clear(); + VERIFY( mm1.count(0) == 0 ); + VERIFY( mm1.count(1) == 0 ); + VERIFY( mm1.count(2) == 0 ); + VERIFY( mm1.count(3) == 0 ); + VERIFY( mm1.count(4) == 0 ); + VERIFY( mm1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc new file mode 100644 index 000000000..45a8246af --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <map> + +void +test01() +{ + std::multimap<int, double> mm{{1, 1.0}, {2, 2.0}, {3, 3.0}}; + std::begin(mm); + std::end(mm); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/citerators.cc new file mode 100644 index 000000000..85fe06650 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::multimap<int, int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/basic.cc new file mode 100644 index 000000000..f46a2f135 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/basic.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::multimap<key_type, key_type, compare_type, allocator_type> test_type; + + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..8e1eace42 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::multimap<key_type, key_type, compare_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..8c3187f07 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit key_type; + typedef std::pair<const key_type, key_type> value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<key_type> compare_type; + typedef std::multimap<key_type, key_type, compare_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..d4137d70a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +template class std::multimap<int, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..0978e3d39 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> + +template class std::multimap<int, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..45cb3243d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +template class std::multimap<__gnu_test::NonDefaultConstructible, + __gnu_test::NonDefaultConstructible>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..be3743671 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +// libstdc++/21770 +template class std::multimap<int, double, std::less<int>, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..896a501b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/4.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2010-2014 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::multimap<__gnu_test::OverloadedAddress, + __gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..ebce1f26b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::multimap<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int> >; +template class std::multimap<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc new file mode 100644 index 000000000..24c715d57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/explicit_instantiation/5_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::multimap<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::multimap<int, int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..73ee546a0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <map> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Data, typename Allocator> + class multimap<user_type, Data, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/typedefs.cc new file mode 100644 index 000000000..c2c879a11 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multimap/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <map> + +// Check container for required typedefs. +__gnu_test::types<std::multimap<int, long> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/14340.cc new file mode 100644 index 000000000..79dd3d708 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <set> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::multiset<int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/23781_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/23781_neg.cc new file mode 100644 index 000000000..1cd3ec547 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/23781_neg.cc @@ -0,0 +1,28 @@ +// 2005-09-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +// libstdc++/23781 +#include <set> +#include <cstddef> + +std::multiset<int>::iterator it = NULL; // { dg-error "conversion" } +std::multiset<int>::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/58764.cc new file mode 100644 index 000000000..f82792301 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <set> + +void test01() +{ + std::multiset<int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy.cc new file mode 100644 index 000000000..1faf32b8c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy_assign.cc new file mode 100644 index 000000000..140af8c4f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/copy_assign.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/minimal.cc new file mode 100644 index 000000000..7e3afda5c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/minimal.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::SimpleAllocator; + +template class std::multiset<T, Cmp, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v(alloc_type{}); + v = { test_type::value_type{} }; + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move.cc new file mode 100644 index 000000000..8ed3b7d60 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc new file mode 100644 index 000000000..3436f4b46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc new file mode 100644 index 000000000..be4936608 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/swap.cc new file mode 100644 index 000000000..52500c5e7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/allocator/swap.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::multiset<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc new file mode 100644 index 000000000..185d4f0d1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 multiset capacity + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::multiset<int> ms; + + VERIFY( ms.max_size() + == std::allocator<std::_Rb_tree_node<int> >().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/moveable.cc new file mode 100644 index 000000000..5cc846279 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on multiset (via swap). If the implementation changed +// this test may begin to fail. + +#include <set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::multiset<int> a,b; + a.insert(2); + b.insert(1); + b = std::move(a); + VERIFY(b.find(2) != b.end() && a.find(1) == a.end()); + + std::multiset<int> c(std::move(b)); + VERIFY( c.find(2) != c.end()); + VERIFY( b.find(2) == b.end()); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..2d75c7fb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> + +typedef std::multiset<int> mstype; + +static_assert(std::is_nothrow_move_constructible<mstype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc new file mode 100644 index 000000000..b0a5cdef5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <set> + +std::multiset<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc new file mode 100644 index 000000000..769e8a0d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc new file mode 100644 index 000000000..9dcc327d1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc new file mode 100644 index 000000000..fbdf5ded3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct4_neg.cc new file mode 100644 index 000000000..4fcbae04b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc new file mode 100644 index 000000000..44fc97bd0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc new file mode 100644 index 000000000..fbb59a89f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc new file mode 100644 index 000000000..1c8f9635c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert4_neg.cc new file mode 100644 index 000000000..8e8995403 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/1.cc new file mode 100644 index 000000000..7629bf1d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/1.cc @@ -0,0 +1,51 @@ +// Multiset iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/set> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::multiset; +using std::advance; + +bool test = true; + +// Assignment +void test01() +{ + multiset<int> v1; + multiset<int> v2; + + v1.insert(17); + + multiset<int>::iterator start = v1.begin(); + multiset<int>::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/2.cc new file mode 100644 index 000000000..1ab8cd184 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/invalidation/2.cc @@ -0,0 +1,69 @@ +// Multiset iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/set> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::multiset; +using std::advance; + +// Erase +void test02() +{ + bool test __attribute__((unused)) = true; + multiset<int> v; + for (int i = 0; i < 20; ++i) + v.insert(i); + + // Single element erase (middle) + multiset<int>::iterator before = v.begin(); + multiset<int>::iterator at = before; + advance(at, 3); + multiset<int>::iterator after = at; + ++after; + v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 4); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + multiset<int>::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..fa420c7d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <set> + +void test01() +{ + std::multiset<int> ms1; + auto it1 = ms1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..d99e6666b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <set> + +void test01() +{ + std::multiset<int> ms1; + ms1 = std::move(ms1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc new file mode 100644 index 000000000..3cda1fb41 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + multiset<int> m({ 1, 5, 5, 37 }); + VERIFY(m.size() == 4); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 2); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 37, 37, 102 }; + VERIFY(m.size() == 5); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42, 42 }); + VERIFY(m.size() == 7); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 2); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/dr130.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/dr130.cc new file mode 100644 index 000000000..1e798c3fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/dr130.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on multiset (via swap). If the implementation changed +// this test may begin to fail. + +#include <set> +#include <vector> +#include <testsuite_hooks.h> + +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset<int> ms0; + typedef multiset<int>::iterator iterator; + typedef multiset<int>::const_iterator const_iterator; + typedef iterator insert_return_type; + + vector<insert_return_type> irt; + for ( int i = 1; i <= 4; ++i ) + for (int j = 1; j <= i; ++j) + irt.push_back( ms0.insert( i ) ); + + iterator pos1 = ms0.erase(irt[1]); + VERIFY( pos1 == irt[2] ); + + iterator pos2 = ms0.erase(irt[2]); + VERIFY( pos2 == irt[3] ); + + iterator pos3 = ms0.erase(irt[9]); + VERIFY( pos3 == ms0.end() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset<int> ms0; + typedef multiset<int>::iterator iterator; + typedef multiset<int>::const_iterator const_iterator; + typedef iterator insert_return_type; + + vector<insert_return_type> irt; + for ( int i = 1; i <= 4; ++i ) + for (int j = 1; j <= i; ++j) + irt.push_back( ms0.insert( i ) ); + + iterator pos1 = ms0.erase(irt[3], irt[6]); + VERIFY( pos1 == irt[6] ); + + iterator pos2 = ms0.erase(irt[6], ++irt[9]); + VERIFY( pos2 == ms0.end() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc new file mode 100644 index 000000000..a013ef700 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <set> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +struct PathPointLess +{ + bool operator() (const PathPoint& __lhs, const PathPoint& __rhs) const + { return __lhs.getType() < __rhs.getType(); } +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::multiset<PathPoint, PathPointLess> Mset; + Mset ms; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = ms.emplace('a', coord1); + VERIFY( ms.size() == 1 ); + VERIFY( it->getType() == 'a' ); + + coord1[0] = 3.0; + it = ms.emplace('a', coord1); + VERIFY( ms.size() == 2 ); + VERIFY( it->getType() == 'a' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + it = ms.emplace_hint(ms.begin(), 'b', coord1); + VERIFY( it != ms.end() ); + VERIFY( it->getType() == 'b' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + it = ms.emplace('c', std::move(coord1)); + VERIFY( ms.size() == 4 ); + VERIFY( it->getType() == 'c' ); + VERIFY( &(it->getCoords()[0]) == px ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc new file mode 100644 index 000000000..3aaa15c6c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::multiset<X>& s, X x) +{ + std::multiset<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/abi_tag.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/abi_tag.cc new file mode 100644 index 000000000..652fb30ec --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/abi_tag.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options -std=c++11 } +// { dg-require-normal-mode "" } + +// Copyright (C) 2013-2014 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// Test that the C++11 variants have an ABI tag + +#include <set> + +using container = std::multiset<int>; +using iterator = typename container::iterator; +using const_iterator = typename container::const_iterator; + +// { dg-final { scan-assembler "_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE" } } +iterator (container::*p1)(const_iterator) = &container::erase; + +// { dg-final { scan-assembler "_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiES5_" } } +iterator (container::*p2)(const_iterator, const_iterator) = &container::erase; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/dr130-linkage-check.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/dr130-linkage-check.cc new file mode 100644 index 000000000..c8e98f8c7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/dr130-linkage-check.cc @@ -0,0 +1,40 @@ +// { dg-require-effective-target ia32 } +// { dg-require-sharedlib "" } +// { dg-options "-fno-inline -std=gnu++11 ./testsuite_shared.so" } +// 2013-06-03 Benjamin Kosnik <bkoz@redhat..com> +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> + +int main() +{ + typedef std::multiset<int> container_type; + + { + container_type s { 0, 1, 2 }; + __gnu_test::linkage_check_cxx98_cxx11_erase(s); + } + + { + container_type s { 0, 1, 2 }; + __gnu_test::linkage_check_cxx98_cxx11_erase_iterators(s); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/1.cc new file mode 100644 index 000000000..e1aa88d0b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/1.cc @@ -0,0 +1,64 @@ +// 1999-06-24 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 template class multiset + +#include <sstream> +#include <iterator> +#include <set> +#include <algorithm> +#include <testsuite_hooks.h> + +namespace std +{ + std::ostream& + operator<<(std::ostream& os, std::pair<int, int> const& p) + { return os << p.first << ' ' << p.second; } +} + +bool +operator<(std::pair<int, int> const& lhs, std::pair<int, int> const& rhs) +{ return lhs.first < rhs.first; } + +int main () +{ + bool test __attribute__((unused)) = true; + typedef std::multiset<std::pair<int, int> >::iterator iterator; + std::pair<int, int> p(69, 0); + std::multiset<std::pair<int, int> > s; + + for (p.second = 0; p.second < 5; ++p.second) + s.insert(p); + for (iterator it = s.begin(); it != s.end(); ++it) + if (it->second < 5) + { + s.insert(it, p); + ++p.second; + } + + std::ostringstream stream; + std::copy(s.begin(), s.end(), + std::ostream_iterator<std::pair<int, int> >(stream, "\n")); + const std::string expected("69 0\n69 1\n69 2\n69 3\n69 4\n" + "69 5\n69 6\n69 7\n69 8\n69 9\n"); + std::string tested(stream.str()); + VERIFY( tested == expected ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/2.cc new file mode 100644 index 000000000..34d3a8ad5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/2.cc @@ -0,0 +1,83 @@ +// 2005-01-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +// A few tests for insert with hint, in the occasion of libstdc++/19422 +// and libstdc++/19433. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset<int> ms0, ms1; + multiset<int>::iterator iter1; + + ms0.insert(1); + ms1.insert(ms1.end(), 1); + VERIFY( ms0 == ms1 ); + + ms0.insert(3); + ms1.insert(ms1.begin(), 3); + VERIFY( ms0 == ms1 ); + + ms0.insert(4); + iter1 = ms1.insert(ms1.end(), 4); + VERIFY( ms0 == ms1 ); + + ms0.insert(6); + ms1.insert(iter1, 6); + VERIFY( ms0 == ms1 ); + + ms0.insert(2); + ms1.insert(ms1.begin(), 2); + VERIFY( ms0 == ms1 ); + + ms0.insert(7); + ms1.insert(ms1.end(), 7); + VERIFY( ms0 == ms1 ); + + ms0.insert(5); + ms1.insert(ms1.find(4), 5); + VERIFY( ms0 == ms1 ); + + ms0.insert(0); + ms1.insert(ms1.end(), 0); + VERIFY( ms0 == ms1 ); + + ms0.insert(8); + ms1.insert(ms1.find(3), 8); + VERIFY( ms0 == ms1 ); + + ms0.insert(9); + ms1.insert(ms1.end(), 9); + VERIFY( ms0 == ms1 ); + + ms0.insert(10); + ms1.insert(ms1.begin(), 10); + VERIFY( ms0 == ms1 ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/22102.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/22102.cc new file mode 100644 index 000000000..a84a598b9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/22102.cc @@ -0,0 +1,140 @@ +// 2006-01-07 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 Class template multiset + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/22102 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::multiset<int> Mset; + typedef Mset::value_type value_type; + typedef Mset::iterator iterator; + + Mset ms1; + + const iterator it1 = ms1.insert(value_type(0)); + const iterator it2 = ms1.insert(value_type(1)); + const iterator it3 = ms1.insert(value_type(2)); + + const value_type vt1(2); + const iterator it4 = ms1.insert(it1, vt1); + iterator it5 = it4; + iterator it6 = it4; + VERIFY( ms1.size() == 4 ); + VERIFY( *it4 == vt1 ); + VERIFY( ++it5 == it3 ); + VERIFY( --it6 == it2 ); + VERIFY( *it5 == *it3 ); + VERIFY( *it6 == *it2 ); + + const value_type vt2(2); + const iterator it7 = ms1.insert(ms1.begin(), vt2); + iterator it8 = it7; + iterator it9 = it7; + VERIFY( ms1.size() == 5 ); + VERIFY( *it7 == vt2 ); + VERIFY( ++it8 == it4 ); + VERIFY( --it9 == it2 ); + VERIFY( *it8 == *it4 ); + VERIFY( *it9 == *it2 ); + + const value_type vt3(2); + const iterator it10 = ms1.insert(it1, vt3); + iterator it11 = it10; + iterator it12 = it10; + VERIFY( ms1.size() == 6 ); + VERIFY( *it10 == vt3 ); + VERIFY( ++it11 == it7 ); + VERIFY( --it12 == it2 ); + VERIFY( *it11 == *it7 ); + VERIFY( *it12 == *it2 ); + + const value_type vt4(0); + const iterator it13 = ms1.insert(it10, vt4); + iterator it14 = it13; + iterator it15 = it13; + VERIFY( ms1.size() == 7 ); + VERIFY( *it13 == vt4 ); + VERIFY( ++it14 == it2 ); + VERIFY( --it15 == it1 ); + VERIFY( *it14 == *it2 ); + VERIFY( *it15 == *it1 ); + + const value_type vt5(1); + const iterator it16 = ms1.insert(it13, vt5); + iterator it17 = it16; + iterator it18 = it16; + VERIFY( ms1.size() == 8 ); + VERIFY( *it16 == vt5 ); + VERIFY( ++it17 == it2 ); + VERIFY( --it18 == it13 ); + VERIFY( *it17 == *it2 ); + VERIFY( *it18 == *it13 ); + + const value_type vt6(0); + const iterator it19 = ms1.insert(it1, vt6); + iterator it20 = it19; + VERIFY( ms1.size() == 9 ); + VERIFY( *it19 == vt6 ); + VERIFY( it19 == ms1.begin() ); + VERIFY( ++it20 == it1 ); + VERIFY( *it20 == *it1 ); + + const value_type vt7(3); + const iterator it21 = ms1.insert(it19, vt7); + iterator it22 = it21; + iterator it23 = it21; + VERIFY( ms1.size() == 10 ); + VERIFY( *it21 == vt7 ); + VERIFY( ++it22 == ms1.end() ); + VERIFY( --it23 == it3 ); + VERIFY( *it23 == *it3 ); + + const value_type vt8(2); + const iterator it24 = ms1.insert(ms1.end(), vt8); + iterator it25 = it24; + iterator it26 = it24; + VERIFY( ms1.size() == 11 ); + VERIFY( *it24 == vt8 ); + VERIFY( ++it25 == it21 ); + VERIFY( --it26 == it3 ); + VERIFY( *it25 == *it21 ); + VERIFY( *it26 == *it3 ); + + const value_type vt9(3); + const iterator it27 = ms1.insert(it3, vt9); + iterator it28 = it27; + iterator it29 = it27; + VERIFY( ms1.size() == 12 ); + VERIFY( *it27 == vt9 ); + VERIFY( ++it28 == it21 ); + VERIFY( --it29 == it24 ); + VERIFY( *it28 == *it21 ); + VERIFY( *it29 == *it24 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/3.cc new file mode 100644 index 000000000..6249bd7cb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/3.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator i = s.insert(rvalstruct(1)); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( i == s.begin() ); + VERIFY( (*i).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + s.insert(rvalstruct(2)); + Set::iterator i = s.insert(rvalstruct(2)); + VERIFY( s.size() == 2 ); + VERIFY( std::distance(s.begin(), s.end()) == 2 ); + VERIFY( (*i).val == 2 ); + + Set::iterator i2 = s.begin(); + ++i2; + VERIFY( i == s.begin() || i == i2 ); + VERIFY( (*(s.begin())).val == 2 && (*i2).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/4.cc new file mode 100644 index 000000000..a84393cf5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/4.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator i = s.insert(s.begin(), rvalstruct(1)); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( i == s.begin() ); + VERIFY( (*i).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator i0 = s.insert(s.begin(), rvalstruct(2)); + Set::iterator i1 = s.insert(i0, rvalstruct(2)); + VERIFY( s.size() == 2 ); + VERIFY( std::distance(s.begin(), s.end()) == 2 ); + VERIFY( (*i1).val == 2 ); + + Set::iterator i2 = s.begin(); + ++i2; + VERIFY( i1 == s.begin() ); + VERIFY( (*(s.begin())).val == 2 && (*i2).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc new file mode 100644 index 000000000..d6af38777 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_hooks.h> + +struct T { int i; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + multiset<T>::swap(multiset<T>&) + { ++swap_calls; } +} + +// Should use multiset specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::multiset<T> A; + std::multiset<T> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use multiset specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + multiset<T> A; + multiset<T> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/2.cc new file mode 100644 index 000000000..eb6c2432b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/2.cc @@ -0,0 +1,137 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 multiset::swap + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef multiset<char, less<char>, my_alloc> my_multiset; + + 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); + + const multiset<char> mset01_ref(title01, title01 + N1); + const multiset<char> mset02_ref(title02, title02 + N2); + const multiset<char> mset03_ref(title03, title03 + N3); + const multiset<char> mset04_ref(title04, title04 + N4); + + my_multiset::size_type size01, size02; + + my_alloc alloc01(1); + + my_multiset mset01(less<char>(), alloc01); + size01 = mset01.size(); + my_multiset mset02(less<char>(), alloc01); + size02 = mset02.size(); + + mset01.swap(mset02); + VERIFY( mset01.size() == size02 ); + VERIFY( mset01.empty() ); + VERIFY( mset02.size() == size01 ); + VERIFY( mset02.empty() ); + + my_multiset mset03(less<char>(), alloc01); + size01 = mset03.size(); + my_multiset mset04(title02, title02 + N2, less<char>(), alloc01); + size02 = mset04.size(); + + mset03.swap(mset04); + VERIFY( mset03.size() == size02 ); + VERIFY( equal(mset03.begin(), mset03.end(), mset02_ref.begin()) ); + VERIFY( mset04.size() == size01 ); + VERIFY( mset04.empty() ); + + my_multiset mset05(title01, title01 + N1, less<char>(), alloc01); + size01 = mset05.size(); + my_multiset mset06(title02, title02 + N2, less<char>(), alloc01); + size02 = mset06.size(); + + mset05.swap(mset06); + VERIFY( mset05.size() == size02 ); + VERIFY( equal(mset05.begin(), mset05.end(), mset02_ref.begin()) ); + VERIFY( mset06.size() == size01 ); + VERIFY( equal(mset06.begin(), mset06.end(), mset01_ref.begin()) ); + + my_multiset mset07(title01, title01 + N1, less<char>(), alloc01); + size01 = mset07.size(); + my_multiset mset08(title03, title03 + N3, less<char>(), alloc01); + size02 = mset08.size(); + + mset07.swap(mset08); + VERIFY( mset07.size() == size02 ); + VERIFY( equal(mset07.begin(), mset07.end(), mset03_ref.begin()) ); + VERIFY( mset08.size() == size01 ); + VERIFY( equal(mset08.begin(), mset08.end(), mset01_ref.begin()) ); + + my_multiset mset09(title03, title03 + N3, less<char>(), alloc01); + size01 = mset09.size(); + my_multiset mset10(title04, title04 + N4, less<char>(), alloc01); + size02 = mset10.size(); + + mset09.swap(mset10); + VERIFY( mset09.size() == size02 ); + VERIFY( equal(mset09.begin(), mset09.end(), mset04_ref.begin()) ); + VERIFY( mset10.size() == size01 ); + VERIFY( equal(mset10.begin(), mset10.end(), mset03_ref.begin()) ); + + my_multiset mset11(title04, title04 + N4, less<char>(), alloc01); + size01 = mset11.size(); + my_multiset mset12(title01, title01 + N1, less<char>(), alloc01); + size02 = mset12.size(); + + mset11.swap(mset12); + VERIFY( mset11.size() == size02 ); + VERIFY( equal(mset11.begin(), mset11.end(), mset01_ref.begin()) ); + VERIFY( mset12.size() == size01 ); + VERIFY( equal(mset12.begin(), mset12.end(), mset04_ref.begin()) ); + + my_multiset mset13(title03, title03 + N3, less<char>(), alloc01); + size01 = mset13.size(); + my_multiset mset14(title03, title03 + N3, less<char>(), alloc01); + size02 = mset14.size(); + + mset13.swap(mset14); + VERIFY( mset13.size() == size02 ); + VERIFY( equal(mset13.begin(), mset13.end(), mset03_ref.begin()) ); + VERIFY( mset14.size() == size01 ); + VERIFY( equal(mset14.begin(), mset14.end(), mset03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/3.cc new file mode 100644 index 000000000..230b4bc46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/3.cc @@ -0,0 +1,166 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 multiset::swap + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef multiset<char, less<char>, my_alloc> my_multiset; + + 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); + + const multiset<char> mset01_ref(title01, title01 + N1); + const multiset<char> mset02_ref(title02, title02 + N2); + const multiset<char> mset03_ref(title03, title03 + N3); + const multiset<char> mset04_ref(title04, title04 + N4); + + my_multiset::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_multiset mset01(less<char>(), alloc01); + size01 = mset01.size(); + personality01 = mset01.get_allocator().get_personality(); + my_multiset mset02(less<char>(), alloc02); + size02 = mset02.size(); + personality02 = mset02.get_allocator().get_personality(); + + mset01.swap(mset02); + VERIFY( mset01.size() == size02 ); + VERIFY( mset01.empty() ); + VERIFY( mset02.size() == size01 ); + VERIFY( mset02.empty() ); + VERIFY( mset01.get_allocator().get_personality() == personality02 ); + VERIFY( mset02.get_allocator().get_personality() == personality01 ); + + my_multiset mset03(less<char>(), alloc02); + size01 = mset03.size(); + personality01 = mset03.get_allocator().get_personality(); + my_multiset mset04(title02, title02 + N2, less<char>(), alloc01); + size02 = mset04.size(); + personality02 = mset04.get_allocator().get_personality(); + + mset03.swap(mset04); + VERIFY( mset03.size() == size02 ); + VERIFY( equal(mset03.begin(), mset03.end(), mset02_ref.begin()) ); + VERIFY( mset04.size() == size01 ); + VERIFY( mset04.empty() ); + VERIFY( mset03.get_allocator().get_personality() == personality02 ); + VERIFY( mset04.get_allocator().get_personality() == personality01 ); + + my_multiset mset05(title01, title01 + N1, less<char>(), alloc01); + size01 = mset05.size(); + personality01 = mset05.get_allocator().get_personality(); + my_multiset mset06(title02, title02 + N2, less<char>(), alloc02); + size02 = mset06.size(); + personality02 = mset06.get_allocator().get_personality(); + + mset05.swap(mset06); + VERIFY( mset05.size() == size02 ); + VERIFY( equal(mset05.begin(), mset05.end(), mset02_ref.begin()) ); + VERIFY( mset06.size() == size01 ); + VERIFY( equal(mset06.begin(), mset06.end(), mset01_ref.begin()) ); + VERIFY( mset05.get_allocator().get_personality() == personality02 ); + VERIFY( mset06.get_allocator().get_personality() == personality01 ); + + my_multiset mset07(title01, title01 + N1, less<char>(), alloc02); + size01 = mset07.size(); + personality01 = mset07.get_allocator().get_personality(); + my_multiset mset08(title03, title03 + N3, less<char>(), alloc01); + size02 = mset08.size(); + personality02 = mset08.get_allocator().get_personality(); + + mset07.swap(mset08); + VERIFY( mset07.size() == size02 ); + VERIFY( equal(mset07.begin(), mset07.end(), mset03_ref.begin()) ); + VERIFY( mset08.size() == size01 ); + VERIFY( equal(mset08.begin(), mset08.end(), mset01_ref.begin()) ); + VERIFY( mset07.get_allocator().get_personality() == personality02 ); + VERIFY( mset08.get_allocator().get_personality() == personality01 ); + + my_multiset mset09(title03, title03 + N3, less<char>(), alloc01); + size01 = mset09.size(); + personality01 = mset09.get_allocator().get_personality(); + my_multiset mset10(title04, title04 + N4, less<char>(), alloc02); + size02 = mset10.size(); + personality02 = mset10.get_allocator().get_personality(); + + mset09.swap(mset10); + VERIFY( mset09.size() == size02 ); + VERIFY( equal(mset09.begin(), mset09.end(), mset04_ref.begin()) ); + VERIFY( mset10.size() == size01 ); + VERIFY( equal(mset10.begin(), mset10.end(), mset03_ref.begin()) ); + VERIFY( mset09.get_allocator().get_personality() == personality02 ); + VERIFY( mset10.get_allocator().get_personality() == personality01 ); + + my_multiset mset11(title04, title04 + N4, less<char>(), alloc02); + size01 = mset11.size(); + personality01 = mset11.get_allocator().get_personality(); + my_multiset mset12(title01, title01 + N1, less<char>(), alloc01); + size02 = mset12.size(); + personality02 = mset12.get_allocator().get_personality(); + + mset11.swap(mset12); + VERIFY( mset11.size() == size02 ); + VERIFY( equal(mset11.begin(), mset11.end(), mset01_ref.begin()) ); + VERIFY( mset12.size() == size01 ); + VERIFY( equal(mset12.begin(), mset12.end(), mset04_ref.begin()) ); + VERIFY( mset11.get_allocator().get_personality() == personality02 ); + VERIFY( mset12.get_allocator().get_personality() == personality01 ); + + my_multiset mset13(title03, title03 + N3, less<char>(), alloc01); + size01 = mset13.size(); + personality01 = mset13.get_allocator().get_personality(); + my_multiset mset14(title03, title03 + N3, less<char>(), alloc02); + size02 = mset14.size(); + personality02 = mset14.get_allocator().get_personality(); + + mset13.swap(mset14); + VERIFY( mset13.size() == size02 ); + VERIFY( equal(mset13.begin(), mset13.end(), mset03_ref.begin()) ); + VERIFY( mset14.size() == size01 ); + VERIFY( equal(mset14.begin(), mset14.end(), mset03_ref.begin()) ); + VERIFY( mset13.get_allocator().get_personality() == personality02 ); + VERIFY( mset14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc new file mode 100644 index 000000000..0bfa6f9c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/1.cc @@ -0,0 +1,125 @@ +// 2006-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +// A few tests for equal_range, in the occasion of libstdc++/29385. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset<int> ms0; + typedef multiset<int>::iterator iterator; + pair<iterator, iterator> pp0; + + pp0 = ms0.equal_range(1); + VERIFY( ms0.count(1) == 0 ); + VERIFY( pp0.first == ms0.end() ); + VERIFY( pp0.second == ms0.end() ); + + iterator iter0 = ms0.insert(1); + iterator iter1 = ms0.insert(2); + iterator iter2 = ms0.insert(3); + + pp0 = ms0.equal_range(2); + VERIFY( ms0.count(2) == 1 ); + VERIFY( *pp0.first == 2 ); + VERIFY( *pp0.second == 3 ); + VERIFY( pp0.first == iter1 ); + VERIFY( --pp0.first == iter0 ); + VERIFY( pp0.second == iter2 ); + + ms0.insert(3); + iterator iter3 = ms0.insert(3); + iterator iter4 = ms0.insert(4); + + pp0 = ms0.equal_range(3); + VERIFY( ms0.count(3) == 3 ); + VERIFY( *pp0.first == 3 ); + VERIFY( *pp0.second == 4 ); + VERIFY( pp0.first == iter2 ); + VERIFY( --pp0.first == iter1 ); + VERIFY( pp0.second == iter4 ); + + iterator iter5 = ms0.insert(0); + ms0.insert(1); + ms0.insert(1); + ms0.insert(1); + + pp0 = ms0.equal_range(1); + VERIFY( ms0.count(1) == 4 ); + VERIFY( *pp0.first == 1 ); + VERIFY( *pp0.second == 2 ); + VERIFY( pp0.first == iter0 ); + VERIFY( --pp0.first == iter5 ); + VERIFY( pp0.second == iter1 ); + + iterator iter6 = ms0.insert(5); + ms0.insert(5); + ms0.insert(5); + + pp0 = ms0.equal_range(5); + VERIFY( ms0.count(5) == 3 ); + VERIFY( *pp0.first == 5 ); + VERIFY( pp0.first == iter6 ); + VERIFY( --pp0.first == iter4 ); + VERIFY( pp0.second == ms0.end() ); + + ms0.insert(4); + ms0.insert(4); + ms0.insert(4); + + pp0 = ms0.equal_range(4); + VERIFY( ms0.count(4) == 4 ); + VERIFY( *pp0.first == 4 ); + VERIFY( *pp0.second == 5 ); + VERIFY( pp0.first == iter4 ); + VERIFY( --pp0.first == iter3 ); + VERIFY( pp0.second == iter6 ); + + ms0.insert(0); + iterator iter7 = ms0.insert(0); + ms0.insert(1); + + pp0 = ms0.equal_range(0); + VERIFY( ms0.count(0) == 3 ); + VERIFY( *pp0.first == 0 ); + VERIFY( *pp0.second == 1 ); + VERIFY( pp0.first == iter5 ); + VERIFY( pp0.first == ms0.begin() ); + VERIFY( pp0.second == iter0 ); + + pp0 = ms0.equal_range(1); + VERIFY( ms0.count(1) == 5 ); + VERIFY( *pp0.first == 1 ); + VERIFY( *pp0.second == 2 ); + VERIFY( pp0.first == iter0 ); + VERIFY( --pp0.first == iter7 ); + VERIFY( pp0.second == iter1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc new file mode 100644 index 000000000..1eeeffaae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc @@ -0,0 +1,104 @@ +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset<int> ms0; + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 0 ); + + ms0.insert(1); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 1 ); + + ms0.insert(1); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 2 ); + + ms0.insert(2); + VERIFY( ms0.count(2) == 1 ); + + ms0.insert(3); + ms0.insert(3); + ms0.insert(3); + VERIFY( ms0.count(3) == 3 ); + + ms0.erase(2); + VERIFY( ms0.count(2) == 0 ); + + ms0.erase(0); + VERIFY( ms0.count(0) == 0 ); + + multiset<int> ms1(ms0); + VERIFY( ms1.count(0) == 0 ); + VERIFY( ms1.count(1) == 2 ); + VERIFY( ms1.count(2) == 0 ); + VERIFY( ms1.count(3) == 3 ); + + ms0.clear(); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 0 ); + VERIFY( ms0.count(2) == 0 ); + VERIFY( ms0.count(3) == 0 ); + + ms1.insert(4); + ms1.insert(5); + ms1.insert(5); + ms1.insert(5); + ms1.insert(5); + VERIFY( ms1.count(4) == 1 ); + VERIFY( ms1.count(5) == 4 ); + + ms1.erase(1); + VERIFY( ms1.count(1) == 0 ); + + ms1.erase(ms1.find(5)); + VERIFY( ms1.count(5) == 3 ); + + ms1.insert(1); + ms1.insert(1); + VERIFY( ms1.count(1) == 2 ); + + ms1.erase(5); + VERIFY( ms1.count(5) == 0 ); + + ms1.erase(ms1.find(4)); + VERIFY( ms1.count(4) == 0 ); + + ms1.clear(); + VERIFY( ms1.count(0) == 0 ); + VERIFY( ms1.count(1) == 0 ); + VERIFY( ms1.count(2) == 0 ); + VERIFY( ms1.count(3) == 0 ); + VERIFY( ms1.count(4) == 0 ); + VERIFY( ms1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc new file mode 100644 index 000000000..6a9680591 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <set> + +void +test01() +{ + std::multiset<int> ms{1, 2, 3}; + std::begin(ms); + std::end(ms); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/citerators.cc new file mode 100644 index 000000000..1e3f7a48e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::multiset<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/basic.cc new file mode 100644 index 000000000..56379256b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/basic.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::multiset<value_type, compare_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..ecaef0335 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/generation_prohibited.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::multiset<value_type, compare_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..ee89b271d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/exception/propagation_consistent.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::multiset<value_type, compare_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..06b3d3125 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +template class std::multiset<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..68d233e25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> + +template class std::multiset<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..a5b1bfa75 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/2.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +template class std::multiset<__gnu_test::NonDefaultConstructible>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..2986141dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +// libstdc++/21770 +template class std::multiset<int, std::less<int>, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..099488f9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/4.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2010-2014 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::multiset<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..0e39c3f1b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::multiset<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int> >; +template class std::multiset<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc new file mode 100644 index 000000000..04ed47e06 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/explicit_instantiation/5_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::multiset<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::multiset<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..042ee4ee7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <set> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Allocator> + class multiset<user_type, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/typedefs.cc new file mode 100644 index 000000000..d7dfe6da0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/multiset/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <set> + +// Check container for required typedefs. +__gnu_test::types<std::multiset<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc new file mode 100644 index 000000000..3c7fda825 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/members/7161.cc @@ -0,0 +1,47 @@ +// 2002-06-28 pme + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3 container adaptros + +#include <queue> +#include <testsuite_hooks.h> + +// libstdc++/7161 +void +test03() +{ + int data[] = {1, 2, 3}; + std::priority_queue<int> pq; + + for (int i = 0; i < 3; ++i) + pq.push(data[i]); + + pq.top(); + for (int i = 0; i < 2; ++i) + pq.pop(); + + while (!pq.empty()) + pq.pop(); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/moveable.cc new file mode 100644 index 000000000..a892ddeb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/moveable.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on vector (via swap). If the implementation changed +// this test may begin to fail. + +#include <queue> +#include <utility> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::priority_queue<int> a,b; + a.push(1); + b = std::move(a); + VERIFY( b.size() == 1 && b.top() == 1 && a.size() == 0 ); + + std::priority_queue<int> c(std::move(b)); + VERIFY( c.size() == 1 && c.top() == 1 ); + VERIFY( b.size() == 0 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..b43ebf505 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers. + +#include <queue> + +template class std::priority_queue<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..692b0540d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers. + +#include <queue> + +template class std::priority_queue<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/typedefs.cc new file mode 100644 index 000000000..5b7275fc3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/priority_queue/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <queue> + +// Check container for required typedefs. +__gnu_test::types<std::priority_queue<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc new file mode 100644 index 000000000..186385ec1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/members/7157.cc @@ -0,0 +1,40 @@ +// 2002-06-28 pme + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3 container adaptros + +#include <queue> +#include <testsuite_hooks.h> + +// libstdc++/7157 +void +test01() +{ + std::queue<int> q; + + q.push(1); + q.front(); + q.pop(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/moveable.cc new file mode 100644 index 000000000..b01f3fd8d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/moveable.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on vector (via swap). If the implementation changed +// this test may begin to fail. + +#include <queue> +#include <utility> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::queue<int> a,b; + a.push(1); + b = std::move(a); + VERIFY( b.size() == 1 && b.front() == 1 && a.size() == 0 ); + + std::queue<int> c(std::move(b)); + VERIFY( c.size() == 1 && c.front() == 1 ); + VERIFY( b.size() == 0 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..f14f2400b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers. + +#include <queue> + +template class std::queue<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..b743acc1a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers. + +#include <queue> + +template class std::queue<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/typedefs.cc new file mode 100644 index 000000000..c0a5401cd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/queue/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <queue> + +// Check container for required typedefs. +__gnu_test::types<std::queue<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/14340.cc new file mode 100644 index 000000000..f46dcd2e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <set> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::set<int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/18604.cc new file mode 100644 index 000000000..39edc46b4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/18604.cc @@ -0,0 +1,42 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <set> + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/23781_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/23781_neg.cc new file mode 100644 index 000000000..6b9a269ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/23781_neg.cc @@ -0,0 +1,28 @@ +// 2005-09-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +// libstdc++/23781 +#include <set> +#include <cstddef> + +std::set<int>::iterator it = NULL; // { dg-error "conversion" } +std::set<int>::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/58764.cc new file mode 100644 index 000000000..9a2ae3ac7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/58764.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <set> + +void test01() +{ + std::set<int> a = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy.cc new file mode 100644 index 000000000..b67621ca9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy_assign.cc new file mode 100644 index 000000000..0e13d15ed --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/copy_assign.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/minimal.cc new file mode 100644 index 000000000..92044b2e7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/minimal.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::SimpleAllocator; + +template class std::set<T, Cmp, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v(alloc_type{}); + v = { test_type::value_type{} }; + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move.cc new file mode 100644 index 000000000..2427b4baf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +struct U { }; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc new file mode 100644 index 000000000..1100aac3d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + v2 = std::move(v1); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc new file mode 100644 index 000000000..bc1ecfecb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/swap.cc new file mode 100644 index 000000000..8ac224962 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/allocator/swap.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +bool operator<(T l, T r) { return l.i < r.i; } + +using Cmp = std::less<T>; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::set<T, Cmp, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { test_type::value_type{} }; + test_type v2(alloc_type(2)); + v2 = { test_type::value_type{} }; + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc new file mode 100644 index 000000000..4e6d2bbfa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.3 set capacity + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::set<int> s; + + VERIFY( s.max_size() == + std::allocator<std::_Rb_tree_node<int> >().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc new file mode 100644 index 000000000..2af16585f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc @@ -0,0 +1,76 @@ +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <functional> +#include <iterator> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::set<int, std::less<int>, tracker_allocator<int> > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + const int arr10a[10] = { 31, 23, 82, 46, 13, 17, 30, 71, 22, 51 }; + bool ok = true; + + 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(arr10a[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(arr10a, arr10a+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(arr10a, arr10a+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/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/moveable.cc new file mode 100644 index 000000000..6dd64fad9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on set (via swap). If the implementation changed +// this test may begin to fail. + +#include <set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::set<int> a,b; + a.insert(2); + b.insert(1); + b = std::move(a); + VERIFY(b.find(2) != b.end() && a.find(1) == a.end()); + + std::set<int> c(std::move(b)); + VERIFY( c.find(2) != c.end()); + VERIFY( b.find(2) == b.end()); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..c5ade6c4d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> + +typedef std::set<int> stype; + +static_assert(std::is_nothrow_move_constructible<stype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc new file mode 100644 index 000000000..80f322305 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <set> + +std::set<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc new file mode 100644 index 000000000..acaca73d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc new file mode 100644 index 000000000..98c58a2d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc new file mode 100644 index 000000000..6521f549a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct4_neg.cc new file mode 100644 index 000000000..787a39577 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc new file mode 100644 index 000000000..f9bc9486d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc new file mode 100644 index 000000000..d92101f5a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc new file mode 100644 index 000000000..a570a65f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert4_neg.cc new file mode 100644 index 000000000..35c87c63a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/1.cc new file mode 100644 index 000000000..b40c84508 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/1.cc @@ -0,0 +1,51 @@ +// Set iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/set> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::set; +using std::advance; + +bool test = true; + +// Assignment +void test01() +{ + set<int> v1; + set<int> v2; + + v1.insert(17); + + set<int>::iterator start = v1.begin(); + set<int>::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/2.cc new file mode 100644 index 000000000..6745ff201 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/invalidation/2.cc @@ -0,0 +1,70 @@ +// Set iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/set> +#include <iterator> +#include <testsuite_hooks.h> + +using __gnu_debug::set; +using std::advance; + +// Erase +void test02() +{ + bool test __attribute__((unused)) = true; + + set<int> v; + for (int i = 0; i < 20; ++i) + v.insert(i); + + // Single element erase (middle) + set<int>::iterator before = v.begin(); + set<int>::iterator at = before; + advance(at, 3); + set<int>::iterator after = at; + ++after; + v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 4); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + set<int>::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..7067c663c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <set> + +void test01() +{ + std::set<int> s1; + auto it1 = s1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..69c7d184b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <set> + +void test01() +{ + std::set<int> s1; + s1 = std::move(s1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/init-list.cc new file mode 100644 index 000000000..bc109bc8f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/init-list.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + set<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42 }); + VERIFY(m.size() == 4); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 1); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc new file mode 100644 index 000000000..f98e53603 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +/* + * The goal with this application is to compare the performance + * between different std::allocator implementations. The results are + * influenced by the underlying allocator in the "C" library, malloc. + */ + +#include <set> +#include <sstream> + +using namespace std; + +typedef int test_type; + +// This can take extremely long on simulators, timing out the test. +// { dg-options "-DITERATIONS=10" { target simulator } } +#ifndef ITERATIONS +#define ITERATIONS 10000 +#endif + +// The number of iterations to be performed. +int iterations = ITERATIONS; + +// The number of values to insert in the container, 32 will cause 5 +// (re)allocations to be performed (sizes 4, 8, 16, 32 and 64) +// This means that all allocations are within _MAX_BYTES = 128 as +// defined in stl_alloc.h for __pool_alloc. Whether or not this +// value is relevant in "the real world" or not I don't know and +// should probably be investigated in more detail. +int insert_values = 128; + +template<typename TestType> + struct value_type : public pair<TestType, TestType> + { + value_type() : pair<TestType, TestType>(0, 0) { } + + inline value_type operator++() { return ++this->first, *this; } + inline operator TestType() const { return this->first; } + }; + +template<typename Container> + void + do_loop() + { + Container obj; + int test_iterations = 0; + value_type<test_type> test_value; + while (test_iterations < iterations) + { + for (int j = 0; j < insert_values; ++j) + obj.insert(obj.end(), ++test_value); + ++test_iterations; + } + } + +template<typename Container> + void + test_container(Container, bool run_threaded = false) + { + do_loop<Container>(); + std::ostringstream comment; + if (run_threaded) + comment << "4-way threaded iterations: " << iterations*4 << '\t'; + else + comment << "iterations: " << iterations << '\t'; + } + +// http://gcc.gnu.org/ml/libstdc++/2001-05/msg00105.html +// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html +int main(void) +{ + typedef less<test_type> compare_type; + test_container(set<test_type, compare_type>()); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc new file mode 100644 index 000000000..e685ff86e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/17948 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef set<int>::size_type size_type; + + set<int> s; + + s.insert(2); + s.insert(3); + + size_type x = s.erase(3); + + VERIFY( s.size() == 1 ); + VERIFY( x == 1 ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/dr130.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/dr130.cc new file mode 100644 index 000000000..6b0897357 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/dr130.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } +// 2008-07-22 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_hooks.h> + +// DR 130. Associative erase should return an iterator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0; + typedef set<int>::iterator iterator; + typedef set<int>::const_iterator const_iterator; + typedef pair<iterator, bool> insert_return_type; + + s0.insert(1); + insert_return_type irt1 = s0.insert(2); + insert_return_type irt2 = s0.insert(3); + + iterator pos1 = s0.erase(irt1.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = s0.erase(irt2.first); + VERIFY( pos2 == s0.end() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0; + typedef set<int>::iterator iterator; + typedef set<int>::const_iterator const_iterator; + typedef pair<iterator, bool> insert_return_type; + + insert_return_type irt0 = s0.insert(1); + s0.insert(2); + insert_return_type irt2 = s0.insert(3); + insert_return_type irt3 = s0.insert(4); + + iterator pos1 = s0.erase(irt0.first, irt2.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = s0.erase(irt2.first, ++irt3.first); + VERIFY( pos2 == s0.end() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc new file mode 100644 index 000000000..12ea12eb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc @@ -0,0 +1,81 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <set> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +struct PathPointLess +{ + bool operator() (const PathPoint& __lhs, const PathPoint& __rhs) const + { return __lhs.getType() < __rhs.getType(); } +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::set<PathPoint, PathPointLess> Set; + Set s; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = s.emplace('a', coord1); + VERIFY( ret.second ); + VERIFY( s.size() == 1 ); + VERIFY( ret.first->getType() == 'a' ); + + coord1[0] = 3.0; + ret = s.emplace('a', coord1); + VERIFY( !ret.second ); + VERIFY( s.size() == 1 ); + VERIFY( ret.first->getType() == 'a' ); + VERIFY( ret.first->getCoords()[0] == 0.0 ); + + auto it = s.emplace_hint(s.begin(), 'b', coord1); + VERIFY( it != s.end() ); + VERIFY( it->getType() == 'b' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + ret = s.emplace('c', std::move(coord1)); + VERIFY( ret.second ); + VERIFY( ret.first->getType() == 'c' ); + VERIFY( &(ret.first->getCoords()[0]) == px ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc new file mode 100644 index 000000000..b5331b669 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::set<X>& s, X x) +{ + std::set<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/abi_tag.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/abi_tag.cc new file mode 100644 index 000000000..effa6ac21 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/abi_tag.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options -std=c++11 } +// { dg-require-normal-mode "" } + +// Copyright (C) 2013-2014 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// Test that the C++11 variants have an ABI tag + +#include <set> + +using container = std::set<int>; +using iterator = typename container::iterator; +using const_iterator = typename container::const_iterator; + +// { dg-final { scan-assembler "_ZNSt3setIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE" } } +iterator (container::*p1)(const_iterator) = &container::erase; + +// { dg-final { scan-assembler "_ZNSt3setIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiES5_" } } +iterator (container::*p2)(const_iterator, const_iterator) = &container::erase; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/dr130-linkage-check.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/dr130-linkage-check.cc new file mode 100644 index 000000000..2f91401aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/dr130-linkage-check.cc @@ -0,0 +1,40 @@ +// { dg-require-effective-target ia32 } +// { dg-require-sharedlib "" } +// { dg-options "-fno-inline -std=gnu++11 ./testsuite_shared.so" } +// 2013-06-03 Benjamin Kosnik <bkoz@redhat..com> +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> + +int main() +{ + typedef std::set<int> container_type; + + { + container_type s { 0, 1, 2 }; + __gnu_test::linkage_check_cxx98_cxx11_erase(s); + } + + { + container_type s { 0, 1, 2 }; + __gnu_test::linkage_check_cxx98_cxx11_erase_iterators(s); + } + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc new file mode 100644 index 000000000..faae843a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc @@ -0,0 +1,83 @@ +// 2005-01-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +// A few tests for insert with hint, in the occasion of libstdc++/19422 +// and libstdc++/19433. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0, s1; + set<int>::iterator iter1; + + s0.insert(1); + s1.insert(s1.end(), 1); + VERIFY( s0 == s1 ); + + s0.insert(3); + s1.insert(s1.begin(), 3); + VERIFY( s0 == s1 ); + + s0.insert(4); + iter1 = s1.insert(s1.end(), 4); + VERIFY( s0 == s1 ); + + s0.insert(6); + s1.insert(iter1, 6); + VERIFY( s0 == s1 ); + + s0.insert(2); + s1.insert(s1.begin(), 2); + VERIFY( s0 == s1 ); + + s0.insert(7); + s1.insert(s1.end(), 7); + VERIFY( s0 == s1 ); + + s0.insert(5); + s1.insert(s1.find(4), 5); + VERIFY( s0 == s1 ); + + s0.insert(0); + s1.insert(s1.end(), 0); + VERIFY( s0 == s1 ); + + s0.insert(8); + s1.insert(s1.find(3), 8); + VERIFY( s0 == s1 ); + + s0.insert(9); + s1.insert(s1.end(), 9); + VERIFY( s0 == s1 ); + + s0.insert(10); + s1.insert(s1.begin(), 10); + VERIFY( s0 == s1 ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc new file mode 100644 index 000000000..dcd8c334b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p = s.insert(rvalstruct(1)); + VERIFY( p.second ); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( p.first == s.begin() ); + VERIFY( (*p.first).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p1 = s.insert(rvalstruct(2)); + std::pair<Set::iterator, bool> p2 = s.insert(rvalstruct(2)); + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( s.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (*p1.first).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/3.cc new file mode 100644 index 000000000..b2dc57dc9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/3.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator p = s.insert(s.begin(), rvalstruct(1)); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( p == s.begin() ); + VERIFY( (*p).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator p1 = s.insert(s.begin(), rvalstruct(2)); + Set::iterator p2 = s.insert(p1, rvalstruct(2)); + VERIFY( s.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( (*p1).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc new file mode 100644 index 000000000..59f9e61d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_hooks.h> + +struct T { int i; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + set<T>::swap(set<T>&) + { ++swap_calls; } +} + +// Should use set specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::set<T> A; + std::set<T> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use set specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + set<T> A; + set<T> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc new file mode 100644 index 000000000..b17a08096 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc @@ -0,0 +1,137 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.3 set::swap + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef set<char, less<char>, my_alloc> my_set; + + 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); + + const set<char> set01_ref(title01, title01 + N1); + const set<char> set02_ref(title02, title02 + N2); + const set<char> set03_ref(title03, title03 + N3); + const set<char> set04_ref(title04, title04 + N4); + + my_set::size_type size01, size02; + + my_alloc alloc01(1); + + my_set set01(less<char>(), alloc01); + size01 = set01.size(); + my_set set02(less<char>(), alloc01); + size02 = set02.size(); + + set01.swap(set02); + VERIFY( set01.size() == size02 ); + VERIFY( set01.empty() ); + VERIFY( set02.size() == size01 ); + VERIFY( set02.empty() ); + + my_set set03(less<char>(), alloc01); + size01 = set03.size(); + my_set set04(title02, title02 + N2, less<char>(), alloc01); + size02 = set04.size(); + + set03.swap(set04); + VERIFY( set03.size() == size02 ); + VERIFY( equal(set03.begin(), set03.end(), set02_ref.begin()) ); + VERIFY( set04.size() == size01 ); + VERIFY( set04.empty() ); + + my_set set05(title01, title01 + N1, less<char>(), alloc01); + size01 = set05.size(); + my_set set06(title02, title02 + N2, less<char>(), alloc01); + size02 = set06.size(); + + set05.swap(set06); + VERIFY( set05.size() == size02 ); + VERIFY( equal(set05.begin(), set05.end(), set02_ref.begin()) ); + VERIFY( set06.size() == size01 ); + VERIFY( equal(set06.begin(), set06.end(), set01_ref.begin()) ); + + my_set set07(title01, title01 + N1, less<char>(), alloc01); + size01 = set07.size(); + my_set set08(title03, title03 + N3, less<char>(), alloc01); + size02 = set08.size(); + + set07.swap(set08); + VERIFY( set07.size() == size02 ); + VERIFY( equal(set07.begin(), set07.end(), set03_ref.begin()) ); + VERIFY( set08.size() == size01 ); + VERIFY( equal(set08.begin(), set08.end(), set01_ref.begin()) ); + + my_set set09(title03, title03 + N3, less<char>(), alloc01); + size01 = set09.size(); + my_set set10(title04, title04 + N4, less<char>(), alloc01); + size02 = set10.size(); + + set09.swap(set10); + VERIFY( set09.size() == size02 ); + VERIFY( equal(set09.begin(), set09.end(), set04_ref.begin()) ); + VERIFY( set10.size() == size01 ); + VERIFY( equal(set10.begin(), set10.end(), set03_ref.begin()) ); + + my_set set11(title04, title04 + N4, less<char>(), alloc01); + size01 = set11.size(); + my_set set12(title01, title01 + N1, less<char>(), alloc01); + size02 = set12.size(); + + set11.swap(set12); + VERIFY( set11.size() == size02 ); + VERIFY( equal(set11.begin(), set11.end(), set01_ref.begin()) ); + VERIFY( set12.size() == size01 ); + VERIFY( equal(set12.begin(), set12.end(), set04_ref.begin()) ); + + my_set set13(title03, title03 + N3, less<char>(), alloc01); + size01 = set13.size(); + my_set set14(title03, title03 + N3, less<char>(), alloc01); + size02 = set14.size(); + + set13.swap(set14); + VERIFY( set13.size() == size02 ); + VERIFY( equal(set13.begin(), set13.end(), set03_ref.begin()) ); + VERIFY( set14.size() == size01 ); + VERIFY( equal(set14.begin(), set14.end(), set03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc new file mode 100644 index 000000000..943f0a904 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc @@ -0,0 +1,166 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.3 set::swap + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef set<char, less<char>, my_alloc> my_set; + + 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); + + const set<char> set01_ref(title01, title01 + N1); + const set<char> set02_ref(title02, title02 + N2); + const set<char> set03_ref(title03, title03 + N3); + const set<char> set04_ref(title04, title04 + N4); + + my_set::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_set set01(less<char>(), alloc01); + size01 = set01.size(); + personality01 = set01.get_allocator().get_personality(); + my_set set02(less<char>(), alloc02); + size02 = set02.size(); + personality02 = set02.get_allocator().get_personality(); + + set01.swap(set02); + VERIFY( set01.size() == size02 ); + VERIFY( set01.empty() ); + VERIFY( set02.size() == size01 ); + VERIFY( set02.empty() ); + VERIFY( set01.get_allocator().get_personality() == personality02 ); + VERIFY( set02.get_allocator().get_personality() == personality01 ); + + my_set set03(less<char>(), alloc02); + size01 = set03.size(); + personality01 = set03.get_allocator().get_personality(); + my_set set04(title02, title02 + N2, less<char>(), alloc01); + size02 = set04.size(); + personality02 = set04.get_allocator().get_personality(); + + set03.swap(set04); + VERIFY( set03.size() == size02 ); + VERIFY( equal(set03.begin(), set03.end(), set02_ref.begin()) ); + VERIFY( set04.size() == size01 ); + VERIFY( set04.empty() ); + VERIFY( set03.get_allocator().get_personality() == personality02 ); + VERIFY( set04.get_allocator().get_personality() == personality01 ); + + my_set set05(title01, title01 + N1, less<char>(), alloc01); + size01 = set05.size(); + personality01 = set05.get_allocator().get_personality(); + my_set set06(title02, title02 + N2, less<char>(), alloc02); + size02 = set06.size(); + personality02 = set06.get_allocator().get_personality(); + + set05.swap(set06); + VERIFY( set05.size() == size02 ); + VERIFY( equal(set05.begin(), set05.end(), set02_ref.begin()) ); + VERIFY( set06.size() == size01 ); + VERIFY( equal(set06.begin(), set06.end(), set01_ref.begin()) ); + VERIFY( set05.get_allocator().get_personality() == personality02 ); + VERIFY( set06.get_allocator().get_personality() == personality01 ); + + my_set set07(title01, title01 + N1, less<char>(), alloc02); + size01 = set07.size(); + personality01 = set07.get_allocator().get_personality(); + my_set set08(title03, title03 + N3, less<char>(), alloc01); + size02 = set08.size(); + personality02 = set08.get_allocator().get_personality(); + + set07.swap(set08); + VERIFY( set07.size() == size02 ); + VERIFY( equal(set07.begin(), set07.end(), set03_ref.begin()) ); + VERIFY( set08.size() == size01 ); + VERIFY( equal(set08.begin(), set08.end(), set01_ref.begin()) ); + VERIFY( set07.get_allocator().get_personality() == personality02 ); + VERIFY( set08.get_allocator().get_personality() == personality01 ); + + my_set set09(title03, title03 + N3, less<char>(), alloc01); + size01 = set09.size(); + personality01 = set09.get_allocator().get_personality(); + my_set set10(title04, title04 + N4, less<char>(), alloc02); + size02 = set10.size(); + personality02 = set10.get_allocator().get_personality(); + + set09.swap(set10); + VERIFY( set09.size() == size02 ); + VERIFY( equal(set09.begin(), set09.end(), set04_ref.begin()) ); + VERIFY( set10.size() == size01 ); + VERIFY( equal(set10.begin(), set10.end(), set03_ref.begin()) ); + VERIFY( set09.get_allocator().get_personality() == personality02 ); + VERIFY( set10.get_allocator().get_personality() == personality01 ); + + my_set set11(title04, title04 + N4, less<char>(), alloc02); + size01 = set11.size(); + personality01 = set11.get_allocator().get_personality(); + my_set set12(title01, title01 + N1, less<char>(), alloc01); + size02 = set12.size(); + personality02 = set12.get_allocator().get_personality(); + + set11.swap(set12); + VERIFY( set11.size() == size02 ); + VERIFY( equal(set11.begin(), set11.end(), set01_ref.begin()) ); + VERIFY( set12.size() == size01 ); + VERIFY( equal(set12.begin(), set12.end(), set04_ref.begin()) ); + VERIFY( set11.get_allocator().get_personality() == personality02 ); + VERIFY( set12.get_allocator().get_personality() == personality01 ); + + my_set set13(title03, title03 + N3, less<char>(), alloc01); + size01 = set13.size(); + personality01 = set13.get_allocator().get_personality(); + my_set set14(title03, title03 + N3, less<char>(), alloc02); + size02 = set14.size(); + personality02 = set14.get_allocator().get_personality(); + + set13.swap(set14); + VERIFY( set13.size() == size02 ); + VERIFY( equal(set13.begin(), set13.end(), set03_ref.begin()) ); + VERIFY( set14.size() == size01 ); + VERIFY( equal(set14.begin(), set14.end(), set03_ref.begin()) ); + VERIFY( set13.get_allocator().get_personality() == personality02 ); + VERIFY( set14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/1.cc new file mode 100644 index 000000000..81616e8b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/1.cc @@ -0,0 +1,126 @@ +// 2006-11-25 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +// A few tests for equal_range, in the occasion of libstdc++/29385. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0; + typedef set<int>::iterator iterator; + typedef pair<iterator, bool> insert_return_type; + pair<iterator, iterator> pp0; + + pp0 = s0.equal_range(1); + VERIFY( s0.count(1) == 0 ); + VERIFY( pp0.first == s0.end() ); + VERIFY( pp0.second == s0.end() ); + + insert_return_type irt0 = s0.insert(1); + insert_return_type irt1 = s0.insert(2); + insert_return_type irt2 = s0.insert(3); + + pp0 = s0.equal_range(2); + VERIFY( s0.count(2) == 1 ); + VERIFY( *pp0.first == 2 ); + VERIFY( *pp0.second == 3 ); + VERIFY( pp0.first == irt1.first ); + VERIFY( --pp0.first == irt0.first ); + VERIFY( pp0.second == irt2.first ); + + s0.insert(3); + insert_return_type irt3 = s0.insert(3); + insert_return_type irt4 = s0.insert(4); + + pp0 = s0.equal_range(3); + VERIFY( s0.count(3) == 1 ); + VERIFY( *pp0.first == 3 ); + VERIFY( *pp0.second == 4 ); + VERIFY( pp0.first == irt2.first ); + VERIFY( --pp0.first == irt1.first ); + VERIFY( pp0.second == irt4.first ); + + insert_return_type irt5 = s0.insert(0); + s0.insert(1); + s0.insert(1); + s0.insert(1); + + pp0 = s0.equal_range(1); + VERIFY( s0.count(1) == 1 ); + VERIFY( *pp0.first == 1 ); + VERIFY( *pp0.second == 2 ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt5.first ); + VERIFY( pp0.second == irt1.first ); + + insert_return_type irt6 = s0.insert(5); + s0.insert(5); + s0.insert(5); + + pp0 = s0.equal_range(5); + VERIFY( s0.count(5) == 1 ); + VERIFY( *pp0.first == 5 ); + VERIFY( pp0.first == irt6.first ); + VERIFY( --pp0.first == irt4.first ); + VERIFY( pp0.second == s0.end() ); + + s0.insert(4); + s0.insert(4); + s0.insert(4); + + pp0 = s0.equal_range(4); + VERIFY( s0.count(4) == 1 ); + VERIFY( *pp0.first == 4 ); + VERIFY( *pp0.second == 5 ); + VERIFY( pp0.first == irt4.first ); + VERIFY( --pp0.first == irt3.first ); + VERIFY( pp0.second == irt6.first ); + + s0.insert(0); + insert_return_type irt7 = s0.insert(0); + s0.insert(1); + + pp0 = s0.equal_range(0); + VERIFY( s0.count(0) == 1 ); + VERIFY( *pp0.first == 0 ); + VERIFY( *pp0.second == 1 ); + VERIFY( pp0.first == irt5.first ); + VERIFY( pp0.first == s0.begin() ); + VERIFY( pp0.second == irt0.first ); + + pp0 = s0.equal_range(1); + VERIFY( s0.count(1) == 1 ); + VERIFY( *pp0.first == 1 ); + VERIFY( *pp0.second == 2 ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt7.first ); + VERIFY( pp0.second == irt1.first ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/count.cc new file mode 100644 index 000000000..69c41c95f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operations/count.cc @@ -0,0 +1,104 @@ +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0; + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 0 ); + + s0.insert(1); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 1 ); + + s0.insert(1); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 1 ); + + s0.insert(2); + VERIFY( s0.count(2) == 1 ); + + s0.insert(3); + s0.insert(3); + s0.insert(3); + VERIFY( s0.count(3) == 1 ); + + s0.erase(2); + VERIFY( s0.count(2) == 0 ); + + s0.erase(0); + VERIFY( s0.count(0) == 0 ); + + set<int> s1(s0); + VERIFY( s1.count(0) == 0 ); + VERIFY( s1.count(1) == 1 ); + VERIFY( s1.count(2) == 0 ); + VERIFY( s1.count(3) == 1 ); + + s0.clear(); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 0 ); + VERIFY( s0.count(2) == 0 ); + VERIFY( s0.count(3) == 0 ); + + s1.insert(4); + s1.insert(5); + s1.insert(5); + s1.insert(5); + s1.insert(5); + VERIFY( s1.count(4) == 1 ); + VERIFY( s1.count(5) == 1 ); + + s1.erase(1); + VERIFY( s1.count(1) == 0 ); + + s1.erase(s1.find(5)); + VERIFY( s1.count(5) == 0 ); + + s1.insert(1); + s1.insert(1); + VERIFY( s1.count(1) == 1 ); + + s1.erase(5); + VERIFY( s1.count(5) == 0 ); + + s1.erase(s1.find(4)); + VERIFY( s1.count(4) == 0 ); + + s1.clear(); + VERIFY( s1.count(0) == 0 ); + VERIFY( s1.count(1) == 0 ); + VERIFY( s1.count(2) == 0 ); + VERIFY( s1.count(3) == 0 ); + VERIFY( s1.count(4) == 0 ); + VERIFY( s1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc new file mode 100644 index 000000000..420caa3c9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.4 template class multiset negative tests +// 2000-09-07 bgarcia@laurelnetworks.com + +#include <set> +#include <string> + +// libstdc++/86: map & set iterator comparisons are not type-safe +void test01() +{ + bool test __attribute__((unused)) = true; + + std::set<unsigned int> setByIndex; + std::set<std::string> setByName; + + std::set<unsigned int>::iterator itr(setByIndex.begin()); + + // NB: it's not setByIndex!! + test &= itr != setByName.end(); // { dg-error "no" } + test &= itr == setByName.end(); // { dg-error "no" } +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/range_access.cc new file mode 100644 index 000000000..5c6c2b0e5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <set> + +void +test01() +{ + std::set<int> s{1, 2, 3}; + std::begin(s); + std::end(s); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/citerators.cc new file mode 100644 index 000000000..4948285f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::set<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/basic.cc new file mode 100644 index 000000000..efd65d66e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-additional-options "-static-libstdc++" { target *-*-mingw* } } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::set<value_type, compare_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..2e787c2e4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/generation_prohibited.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::set<value_type, compare_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..b7a393714 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/exception/propagation_consistent.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::less<value_type> compare_type; + typedef std::set<value_type, compare_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..30b2d0448 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +template class std::set<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..01f712333 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> + +template class std::set<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..fb9246270 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/2.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +template class std::set<__gnu_test::NonDefaultConstructible>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..ac21ea19d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +// libstdc++/21770 +template class std::set<int, std::less<int>, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..9798b9b00 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/4.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2010-2014 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::set<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..ad25e272f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::set<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int> >; +template class std::set<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc new file mode 100644 index 000000000..e0e58daf8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/explicit_instantiation/5_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::set<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::set<int, std::less<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..6b3fcc493 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <set> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Allocator> + class set<user_type, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/typedefs.cc new file mode 100644 index 000000000..2d916dd73 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/set/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <set> + +// Check container for required typedefs. +__gnu_test::types<std::set<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc new file mode 100644 index 000000000..acb26ba53 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/members/7158.cc @@ -0,0 +1,40 @@ +// 2002-06-28 pme + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.3 container adaptros + +#include <stack> +#include <testsuite_hooks.h> + +// libstdc++/7158 +void +test02() +{ + std::stack<int> st; + + st.push(1); + st.top() = 42; + st.pop(); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..620d81465 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers. + +#include <stack> + +template class std::stack<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..d39c1cf77 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers. + +#include <stack> + +template class std::stack<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/typedefs.cc new file mode 100644 index 000000000..9ba86fc62 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/stack/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <stack> + +// Check container for required typedefs. +__gnu_test::types<std::stack<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/55043.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/55043.cc new file mode 100644 index 000000000..8b23c3cd4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/55043.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/55043 + +#include <unordered_map> +#include <vector> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; +}; + +using hash = std::hash<int>; +using equal = std::equal_to<int>; + +template<typename Alloc> + using test_type = std::unordered_map<int, MoveOnly, hash, equal, Alloc>; + +void test01() +{ + typedef test_type<std::allocator<MoveOnly>> uim; + std::vector<uim> v; + v.emplace_back(uim()); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc new file mode 100644 index 000000000..1e81bb741 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// { dg-require-debug-mode "" } + +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/59548 + +#include <unordered_map> + +int main() +{ + std::unordered_map<int,int> foo{ {0,1} }; + auto i = foo.begin(); + { + auto bar = foo; + } + return i->first; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy.cc new file mode 100644 index 000000000..8d0a00ac6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy_assign.cc new file mode 100644 index 000000000..f6652e585 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/copy_assign.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/minimal.cc new file mode 100644 index 000000000..a4b211e1b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/minimal.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + + +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::SimpleAllocator; + +template class std::unordered_map<T, T, hash, equal_to, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v(alloc_type{}); + v.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move.cc new file mode 100644 index 000000000..8b5739410 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc new file mode 100644 index 000000000..eff287d13 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> +#include <testsuite_counter_type.h> + +using __gnu_test::propagating_allocator; +using __gnu_test::counter_type; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, false> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_map<counter_type, counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(1), std::make_tuple(1)); + + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(2), std::make_tuple(2)); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY( 1 == v1.get_allocator().get_personality() ); + VERIFY( 2 == v2.get_allocator().get_personality() ); + + // No move because key is const. + VERIFY( counter_type::move_assign_count == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, true> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_map<counter_type, counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(1), std::make_tuple(1)); + + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(2), std::make_tuple(2)); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); + + VERIFY( counter_type::move_assign_count == 0 ); + VERIFY( counter_type::destructor_count == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc new file mode 100644 index 000000000..4e03e0099 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/swap.cc new file mode 100644 index 000000000..ef60c3d1e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/swap.cc @@ -0,0 +1,96 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<std::pair<const T, T>, false>&, + const propagating_allocator<std::pair<const T, T>, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<std::pair<const T, T>, false>&, + const propagating_allocator<std::pair<const T, T>, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, T>, false> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, T>, true> alloc_type; + typedef std::unordered_map<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/56112.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/56112.cc new file mode 100644 index 000000000..95b4f6bad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/56112.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <utility> + +struct Key +{ + explicit Key(const int* p) : value(p) { } + ~Key() { value = nullptr; } + + bool operator==(const Key& k) const { return *value == *k.value; } + + const int* value; +}; + +struct hash +{ + std::size_t operator()(const Key& k) const noexcept { return *k.value; } +}; + +struct S +{ + int value; + operator std::pair<const Key, int>() const { return {Key(&value), value}; } +}; + +int main() +{ + S s[1] = { {2} }; + std::unordered_map<Key, int, hash> m(s, s+1); + std::unordered_multimap<Key, int, hash> mm(s, s+1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/moveable.cc new file mode 100644 index 000000000..b557d41d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on map (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_map> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::unordered_map<int, int> a,b; + a[2]=0; + b[1]=0; + b = std::move(a); + VERIFY( b.find(2) != b.end() && a.find(1) == a.end() ); + + std::unordered_map<int, int> c(std::move(b)); + VERIFY( c.find(2) != c.end() ); + VERIFY( b.find(2) == b.end() ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc new file mode 100644 index 000000000..7915f8ed9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <unordered_map> + +std::unordered_map<int, int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc new file mode 100644 index 000000000..7cc5de08c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.begin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc new file mode 100644 index 000000000..830648ef7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + const std::unordered_map<int, int>& cum = um; + cum.begin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc new file mode 100644 index 000000000..b0be7ad00 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.bucket_size(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc new file mode 100644 index 000000000..842d5e3e6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.cbegin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc new file mode 100644 index 000000000..d3d30b759 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.cend(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc new file mode 100644 index 000000000..8c7d9e568 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc new file mode 100644 index 000000000..059a0c3c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc new file mode 100644 index 000000000..7bed7761b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct4_neg.cc new file mode 100644 index 000000000..dc61a99df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc new file mode 100644 index 000000000..7197e24ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.end(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc new file mode 100644 index 000000000..eb2620616 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + const std::unordered_map<int, int>& cum = um; + cum.end(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc new file mode 100644 index 000000000..d8f16cc4a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc new file mode 100644 index 000000000..56b3b2957 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc new file mode 100644 index 000000000..ec06d8129 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert4_neg.cc new file mode 100644 index 000000000..a43693b56 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::unordered_map<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc new file mode 100644 index 000000000..d5e23853e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_compare<std::unordered_map<int, int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc new file mode 100644 index 000000000..1b2946ac5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_range<std::unordered_map<int, int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..0c150d98c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um1; + auto it1 = um1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc new file mode 100644 index 000000000..11db0a3f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_multimap<int, int> um; + um.max_load_factor(-1.0f); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..f81a96ace --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um1; + um1 = std::move(um1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc new file mode 100644 index 000000000..6ea5e3359 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_erased_local_iterator<std::unordered_map<int, int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc new file mode 100644 index 000000000..769c6a4af --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::use_invalid_iterator<std::unordered_map<int, int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc new file mode 100644 index 000000000..ae169484c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_invalid_local_iterator<std::unordered_map<int, int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc new file mode 100644 index 000000000..1f499118f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <stdexcept> +#include <testsuite_hooks.h> + +// DR 761. unordered_map needs an at() member function. +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::unordered_map<int, double> map_type; + + { + map_type m; + m[0] = 1.5; + + double& rd = m.at(0); + VERIFY( rd == 1.5 ); + try + { + m.at(1); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } + + { + map_type m; + m[1] = 2.5; + const map_type cm(m); + + const double& crd = cm.at(1); + VERIFY( crd == 2.5 ); + try + { + cm.at(0); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/1.cc new file mode 100644 index 000000000..4cbbf4df8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/1.cc @@ -0,0 +1,165 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_map<std::string, int>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef Map::iterator iterator; + typedef Map::const_iterator const_iterator; + typedef Map::value_type value_type; + + Map m1; + + m1.insert(value_type("because to why", 1)); + m1.insert(value_type("the stockholm syndrome", 2)); + m1.insert(value_type("a cereous night", 3)); + m1.insert(value_type("eeilo", 4)); + m1.insert(value_type("protean", 5)); + m1.insert(value_type("the way you are when", 6)); + m1.insert(value_type("tillsammans", 7)); + m1.insert(value_type("umbra/penumbra", 8)); + m1.insert(value_type("belonging (no longer mix)", 9)); + m1.insert(value_type("one line behind", 10)); + VERIFY( m1.size() == 10 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + + VERIFY( m1.erase("eeilo") == 1 ); + VERIFY( m1.size() == 9 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + iterator it1 = m1.find("eeilo"); + VERIFY( it1 == m1.end() ); + + VERIFY( m1.erase("tillsammans") == 1 ); + VERIFY( m1.size() == 8 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + iterator it2 = m1.find("tillsammans"); + VERIFY( it2 == m1.end() ); + + // Must work (see DR 526) + iterator it3 = m1.find("belonging (no longer mix)"); + VERIFY( it3 != m1.end() ); + VERIFY( m1.erase(it3->first) == 1 ); + VERIFY( m1.size() == 7 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + it3 = m1.find("belonging (no longer mix)"); + VERIFY( it3 == m1.end() ); + + VERIFY( !m1.erase("abra") ); + VERIFY( m1.size() == 7 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + + VERIFY( !m1.erase("eeilo") ); + VERIFY( m1.size() == 7 ); + + VERIFY( m1.erase("because to why") == 1 ); + VERIFY( m1.size() == 6 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + iterator it4 = m1.find("because to why"); + VERIFY( it4 == m1.end() ); + + iterator it5 = m1.find("umbra/penumbra"); + iterator it6 = m1.find("one line behind"); + VERIFY( it5 != m1.end() ); + VERIFY( it6 != m1.end() ); + + VERIFY( m1.find("the stockholm syndrome") != m1.end() ); + VERIFY( m1.find("a cereous night") != m1.end() ); + VERIFY( m1.find("the way you are when") != m1.end() ); + VERIFY( m1.find("a cereous night") != m1.end() ); + + VERIFY( m1.erase(it5->first) == 1 ); + VERIFY( m1.size() == 5 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + it5 = m1.find("umbra/penumbra"); + VERIFY( it5 == m1.end() ); + + VERIFY( m1.erase(it6->first) == 1 ); + VERIFY( m1.size() == 4 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + it6 = m1.find("one line behind"); + VERIFY( it6 == m1.end() ); + + iterator it7 = m1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( m1.erase(it8->first) == 1 ); + VERIFY( m1.size() == 3 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( m1.erase(it9->first) == 1 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + VERIFY( m1.size() == 2 ); + VERIFY( ++it10 == m1.end() ); + + VERIFY( m1.erase(m1.begin()) != m1.end() ); + VERIFY( m1.size() == 1 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + VERIFY( m1.begin() == it11 ); + + VERIFY( m1.erase(m1.begin()->first) == 1 ); + VERIFY( m1.size() == 0 ); + VERIFY( get_nb_bucket_elems(m1) == m1.size() ); + VERIFY( distance(m1.begin(), m1.end()) - m1.size() == 0 ); + VERIFY( m1.begin() == m1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/24061-map.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/24061-map.cc new file mode 100644 index 000000000..d7f789a64 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/24061-map.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef Map::iterator iterator; + typedef Map::const_iterator const_iterator; + typedef Map::value_type value_type; + + Map m1; + + m1.insert(value_type("all the love in the world", 1)); + m1.insert(value_type("you know what you are?", 2)); + m1.insert(value_type("the collector", 3)); + m1.insert(value_type("the hand that feeds", 4)); + m1.insert(value_type("love is not enough", 5)); + m1.insert(value_type("every day is exactly the same", 6)); + m1.insert(value_type("with teeth", 7)); + m1.insert(value_type("only", 8)); + m1.insert(value_type("getting smaller", 9)); + m1.insert(value_type("sunspots", 10)); + VERIFY( m1.size() == 10 ); + + iterator it1 = m1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = m1.erase(it1); + VERIFY( m1.size() == 9 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = m1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = m1.erase(it4, it5); + VERIFY( m1.size() == 7 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = m1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = m1.erase(it7); + VERIFY( m1.size() == 6 ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = m1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = m1.erase(it10, it11); + VERIFY( m1.size() == 2 ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + VERIFY( ++it12 == m1.end() ); + + iterator it13 = m1.erase(m1.begin(), m1.end()); + VERIFY( m1.size() == 0 ); + VERIFY( it13 == it12 ); + VERIFY( it13 == m1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc new file mode 100644 index 000000000..e3680f52a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +struct X_hash +{ std::size_t operator()(const X&) const { return 0; } }; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_map<X, int, X_hash>& s, X x) +{ + std::unordered_map<X, int, X_hash>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/54276.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/54276.cc new file mode 100644 index 000000000..af647ed2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/erase/54276.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <unordered_map> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +struct A +{ + int x; + static std::set<const A*> destroyed; + + A() + { destroyed.erase(this); } + + A(const A& a) + : x(a.x) + { destroyed.erase(this); } + + ~A() + { destroyed.insert(this); } + + bool + operator==(const A& other) const + { + VERIFY( destroyed.find(this) == destroyed.end() ); + VERIFY( destroyed.find(&other) == destroyed.end() ); + return x == other.x; + } +}; + +std::set<const A*> A::destroyed; + +struct hasher +{ + std::size_t operator()(const A& a) const + { + VERIFY( A::destroyed.find(&a) == A::destroyed.end() ); + return a.x / 10; + } +}; + +void test01() +{ + typedef std::unordered_map<A, A, hasher> UMap; + UMap map; + + A::destroyed.clear(); + A a; + a.x = 0; + map.insert({a, a}); + a.x = 1; + map.insert({a, a}); + VERIFY( map.size() == 2 ); + std::size_t bkt = map.bucket(a); + VERIFY( map.bucket_size(bkt) == 2 ); + + VERIFY( map.erase( map.begin(bkt)->first ) == 1 ); +} + +void test02() +{ + typedef std::unordered_map<A, A, hasher> UMap; + UMap map; + + A::destroyed.clear(); + A a; + a.x = 0; + map.insert({a, a}); + a.x = 1; + map.insert({a, a}); + VERIFY( map.size() == 2 ); + std::size_t bkt = map.bucket(a); + VERIFY( map.bucket_size(bkt) == 2 ); + + VERIFY( map.erase( map.begin(bkt)->second ) == 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/final_hash.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/final_hash.cc new file mode 100644 index 000000000..326ae40a7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/final_hash.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <unordered_map> + +namespace +{ + template<typename _Tp> + struct final_hash final + { + std::size_t operator() (const _Tp&) const noexcept + { return 0; } + }; +} + +// A non-integral type: +template class std::unordered_map<std::string, int, final_hash<std::string>>; + +// An integral type; +template class std::unordered_map<int, int, final_hash<int>>; + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/hash_policy/dr1189.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/hash_policy/dr1189.cc new file mode 100644 index 000000000..488e256d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/hash_policy/dr1189.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +// DR 1189. Awkward interface for changing the number of buckets +// in an unordered associative container +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_map<int, double> m1; + m1.reserve(10); + VERIFY( m1.bucket_count() >= 10 ); + + m1.reserve(100); + VERIFY( m1.bucket_count() >= 100 ); + + std::unordered_map<int, double> m2(100); + VERIFY( m2.bucket_count() >= 100 ); + + m2.reserve(1000); + VERIFY( m2.bucket_count() >= 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc new file mode 100644 index 000000000..f7c3d5f1e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_map<int,double> m({ { 1, 1.0 }, { 2, 2.0 }, { 42, 237.0 } }); + VERIFY(m.size() == 3); + VERIFY(m[1] == 1.0); + VERIFY(m[2] == 2.0); + VERIFY(m[42] == 237.0); + + m = { {5, 55.0}, { 6, 66.0 } }; + VERIFY(m.size() == 2); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + + m.insert({ { 7, 77.0 }, { 8, 88.0 } }); + VERIFY(m.size() == 4); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + VERIFY(m[7] == 77.0); + VERIFY(m[8] == 88.0); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/24061-map.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/24061-map.cc new file mode 100644 index 000000000..50b10ab27 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/24061-map.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef Map::iterator iterator; + typedef Map::const_iterator const_iterator; + typedef Map::value_type value_type; + + Map m1; + + iterator it1 = m1.insert(m1.begin(), + value_type("all the love in the world", 1)); + VERIFY( m1.size() == 1 ); + VERIFY( *it1 == value_type("all the love in the world", 1) ); + + const_iterator cit1(it1); + const_iterator cit2 = m1.insert(cit1, + value_type("you know what you are?", 2)); + VERIFY( m1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == value_type("you know what you are?", 2) ); + + iterator it2 = m1.insert(it1, value_type("all the love in the world", 3)); + VERIFY( m1.size() == 2 ); + VERIFY( it2 == it1 ); + VERIFY( *it2 == value_type("all the love in the world", 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/57619.C b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/57619.C new file mode 100644 index 000000000..f744f5d6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/57619.C @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + { + std::unordered_map<std::string, std::string> mymap; + std::pair<std::string, std::string> mypair{std::string("key"), + std::string("value")}; + mymap.insert(mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } + + { + std::unordered_map<std::string, std::string> mymap; + std::pair<std::string, std::string> mypair{std::string("key"), + std::string("value")}; + mymap.insert(mymap.begin(), mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax.cc new file mode 100644 index 000000000..5b2c906d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Array version of insert + +#include <string> +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + + Map m; + VERIFY( m.empty() ); + + m["red"] = 17; + VERIFY( m.size() == 1 ); + VERIFY( m.begin()->first == "red" ); + VERIFY( m.begin()->second == 17 ); + VERIFY( m["red"] == 17 ); + + m["blue"] = 9; + VERIFY( m.size() == 2 ); + VERIFY( m["blue"] == 9 ); + + m["red"] = 5; + VERIFY( m.size() == 2 ); + VERIFY( m["red"] == 5 ); + VERIFY( m["blue"] == 9 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax_move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax_move.cc new file mode 100644 index 000000000..dd25ab82b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/array_syntax_move.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Array version of insert + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_map<rvalstruct, rvalstruct> Map; + + Map m; + VERIFY( m.empty() ); + + m[rvalstruct(1)] = rvalstruct(17); + VERIFY( m.size() == 1 ); + VERIFY( (m.begin()->first).val == 1 ); + VERIFY( (m.begin()->second).val == 17 ); + VERIFY( m[rvalstruct(1)].val == 17 ); + + m[rvalstruct(2)] = rvalstruct(9); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(2)].val == 9 ); + + m[rvalstruct(1)] = rvalstruct(5); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(1)].val == 5 ); + VERIFY( m[rvalstruct(2)].val == 9 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_range.cc new file mode 100644 index 000000000..edd2f2901 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_range.cc @@ -0,0 +1,97 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <string> +#include <iterator> +#include <algorithm> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[5] = + { + Pair("red", 5), + Pair("green", 9), + Pair("blue", 3), + Pair("cyan", 8), + Pair("magenta", 7) + }; + + m.insert(A+0, A+5); + VERIFY(m.size() == 5); + VERIFY(std::distance(m.begin(), m.end()) == 5); + + VERIFY(m["red"] == 5); + VERIFY(m["green"] == 9); + VERIFY(m["blue"] == 3); + VERIFY(m["cyan"] == 8); + VERIFY(m["magenta"] == 7); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[9] = + { + Pair("red", 5), + Pair("green", 9), + Pair("red", 19), + Pair("blue", 3), + Pair("blue", 60), + Pair("cyan", 8), + Pair("magenta", 7), + Pair("blue", 99), + Pair("green", 33) + }; + + m.insert(A+0, A+9); + VERIFY(m.size() == 5); + VERIFY(std::distance(m.begin(), m.end()) == 5); + + VERIFY(m["red"] == 5); + VERIFY(m["green"] == 9); + VERIFY(m["blue"] == 3); + VERIFY(m["cyan"] == 8); + VERIFY(m["magenta"] == 7); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single.cc new file mode 100644 index 000000000..688879233 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <string> +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + std::pair<Map::iterator, bool> p = m.insert(Pair("abcde", 3)); + VERIFY(p.second); + VERIFY(m.size() == 1); + VERIFY(std::distance(m.begin(), m.end()) == 1); + VERIFY(p.first == m.begin()); + VERIFY(p.first->first == "abcde"); + VERIFY(p.first->second == 3); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_map<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + std::pair<Map::iterator, bool> p1 = m.insert(Pair("abcde", 3)); + std::pair<Map::iterator, bool> p2 = m.insert(Pair("abcde", 7)); + + VERIFY(p1.second); + VERIFY(!p2.second); + VERIFY(m.size() == 1); + VERIFY(p1.first == p2.first); + VERIFY(p1.first->first == "abcde"); + VERIFY(p2.first->second == 3); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-1.cc new file mode 100644 index 000000000..8f2956c27 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-1.cc @@ -0,0 +1,76 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + std::pair<Map::iterator, bool> p = m.insert(Pair(1, rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( p.first->first == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_map<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair<Map::iterator, bool> p1 = m.insert(Pair(2, rvalstruct(3))); + std::pair<Map::iterator, bool> p2 = m.insert(Pair(2, rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( p1.first->first == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-2.cc new file mode 100644 index 000000000..de319bbeb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/insert/map_single_move-2.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty()); + + std::pair<Map::iterator, bool> p = m.insert(Pair(rvalstruct(1), + rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( (p.first->first).val == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_map<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair<Map::iterator, bool> p1 = m.insert(Pair(rvalstruct(2), + rvalstruct(3))); + std::pair<Map::iterator, bool> p2 = m.insert(Pair(rvalstruct(2), + rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (p1.first->first).val == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/emplace.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/emplace.cc new file mode 100644 index 000000000..2700df625 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/emplace.cc @@ -0,0 +1,116 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <utility> +#include <tuple> +#include <vector> +#include <unordered_map> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_map<char, std::vector<double>> Map; + Map m; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = m.emplace('a', coord1); + VERIFY( ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + + coord1[0] = 3.0; + ret = m.emplace('a', coord1); + VERIFY( !ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + VERIFY( ret.first->second[0] == 0.0 ); + + auto it = m.emplace_hint(m.begin(), 'b', coord1); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second[0] == 3.0 ); + + double *px = &coord1[0]; + ret = m.emplace('c', std::move(coord1)); + VERIFY( ret.second ); + VERIFY( ret.first->first == 'c' ); + VERIFY( &(ret.first->second[0]) == px ); +} + +void test02() +{ + using namespace std; + typedef unordered_map<char, PathPoint> Map; + Map m; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple('a', coord1)); + VERIFY( ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + + coord1[0] = 3.0; + ret = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple( 'b', coord1)); + VERIFY( !ret.second ); + VERIFY( m.size() == 1 ); + VERIFY( ret.first->first == 'a' ); + VERIFY( ret.first->second.getCoords()[0] == 0.0 ); + + auto it = m.emplace_hint(m.begin(), piecewise_construct, + make_tuple('b'), make_tuple('c', coord1)); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + ret = m.emplace(piecewise_construct, + make_tuple('c'), make_tuple('d', move(coord1))); + VERIFY( ret.second ); + VERIFY( ret.first->first == 'c' ); + VERIFY( &(ret.first->second.getCoords()[0]) == px ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/reserve.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/reserve.cc new file mode 100644 index 000000000..aa21a29f5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/reserve.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + const int N = 1000; + + typedef std::unordered_map<int, int> Map; + Map m; + m.reserve(N); + + std::size_t bkts = m.bucket_count(); + for (int i = 0; i != N; ++i) + { + m.insert(std::make_pair(i, i)); + // As long as we insert less than the reserved number of elements we + // shouldn't experiment any rehash. + VERIFY( m.bucket_count() == bkts ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/observers.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/observers.cc new file mode 100644 index 000000000..3d3473268 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/observers.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +void +test01() +{ + std::unordered_map<int, int> um; + + auto ke __attribute__((unused)) = um.key_eq(); + auto h __attribute__((unused)) = um.hash_function(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc new file mode 100644 index 000000000..18fa4dcd3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef unordered_map<int, int>::value_type value_type; + + unordered_map<int, int> um0; + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 0 ); + + um0.insert(value_type(1, 1)); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 1 ); + + um0.insert(value_type(1, 2)); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 1 ); + + um0.insert(value_type(2, 1)); + VERIFY( um0.count(2) == 1 ); + + um0.insert(value_type(3, 1)); + um0.insert(value_type(3, 2)); + um0.insert(value_type(3, 3)); + VERIFY( um0.count(3) == 1 ); + + um0.erase(2); + VERIFY( um0.count(2) == 0 ); + + um0.erase(0); + VERIFY( um0.count(0) == 0 ); + + unordered_map<int, int> um1(um0); + VERIFY( um1.count(0) == 0 ); + VERIFY( um1.count(1) == 1 ); + VERIFY( um1.count(2) == 0 ); + VERIFY( um1.count(3) == 1 ); + + um0.clear(); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 0 ); + VERIFY( um0.count(2) == 0 ); + VERIFY( um0.count(3) == 0 ); + + um1.insert(value_type(4, 1)); + um1.insert(value_type(5, 1)); + um1.insert(value_type(5, 2)); + um1.insert(value_type(5, 3)); + um1.insert(value_type(5, 4)); + VERIFY( um1.count(4) == 1 ); + VERIFY( um1.count(5) == 1 ); + + um1.erase(1); + VERIFY( um1.count(1) == 0 ); + + um1.erase(um1.find(5)); + VERIFY( um1.count(5) == 0 ); + + um1.insert(value_type(1, 1)); + um1.insert(value_type(1, 2)); + VERIFY( um1.count(1) == 1 ); + + um1.erase(5); + VERIFY( um1.count(5) == 0 ); + + um1.erase(um1.find(4)); + VERIFY( um1.count(4) == 0 ); + + um1.clear(); + VERIFY( um1.count(0) == 0 ); + VERIFY( um1.count(1) == 0 ); + VERIFY( um1.count(2) == 0 ); + VERIFY( um1.count(3) == 0 ); + VERIFY( um1.count(4) == 0 ); + VERIFY( um1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc new file mode 100644 index 000000000..69f6aecc0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc @@ -0,0 +1,169 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_map<int, int> um1, um2; + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -1)); + um2.insert(Pair(2, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(3, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um2.insert(Pair(3, -3)); + VERIFY( (um1 == um2) ); + VERIFY( !(um1 != um2) ); + + um2.clear(); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(3, -3)); + um2.insert(Pair(4, -4)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(4, -4)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um2.insert(Pair(3, -3)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(4, -4)); + um2.insert(Pair(4, -4)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(2, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -3)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(2, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -3)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + const std::unordered_map<int, int> cum1(um1), cum2(um2); + VERIFY( cum1 != cum2 ); + VERIFY( !(cum1 == cum2) ); + VERIFY( cum1 != um2 ); + VERIFY( !(um1 == cum2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/2.cc new file mode 100644 index 000000000..492437bec --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/operators/2.cc @@ -0,0 +1,91 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.5.4 template class unordered_map + +// This test verifies that the value type of a unordered_map need not be +// default copyable. + +// { dg-options "-std=gnu++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> +#include <testsuite_counter_type.h> + +struct Mapped +{ + Mapped() = default; + explicit Mapped(const Mapped&) = default; +}; + +struct DefaultConstructibleType +{ + int val; + + DefaultConstructibleType() : val(123) + {} + + DefaultConstructibleType(const DefaultConstructibleType&) = delete; + DefaultConstructibleType(DefaultConstructibleType&&) = delete; + + DefaultConstructibleType& operator=(int x) + { + val = x; + return *this; + } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using __gnu_test::rvalstruct; + using __gnu_test::counter_type; + + std::unordered_map<int, Mapped> m1; + m1[0] = Mapped(); + + std::unordered_map<int, rvalstruct> m2; + m2[0] = rvalstruct(13); + + std::unordered_map<int, DefaultConstructibleType> m3; + VERIFY( m3[0].val == 123 ); + VERIFY( m3.size() == 1 ); + m3[0] = 2; + VERIFY( m3[0].val == 2 ); + + std::unordered_map<counter_type, int, + __gnu_test::counter_type_hasher> m4; + VERIFY( m4[counter_type(1)] == 0 ); + VERIFY( counter_type::specialize_count == 1 ); + VERIFY( counter_type::copy_count == 0 ); + VERIFY( counter_type::move_count == 1 ); + + counter_type k(2); + counter_type::reset(); + + VERIFY( m4[k] == 0 ); + VERIFY( counter_type::copy_count == 1 ); + VERIFY( counter_type::move_count == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/hash_map.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/hash_map.cc new file mode 100644 index 000000000..7939a35e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/hash_map.cc @@ -0,0 +1,22 @@ +// { dg-options "-Wno-deprecated" } +/* testing the gcc instrumented */ + +#include <ext/hash_map> +using namespace std; +using __gnu_cxx::hash_map; + +int main() +{ + hash_map <int, int> *tmp; + + for (int j=1; j<=10; j++) + { + tmp = new hash_map<int, int>; + // Insert more than default item + for (int i=0; i<10000*j; i++) { + (*tmp)[i]= i; + } + delete tmp; + } +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/unordered.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/unordered.cc new file mode 100644 index 000000000..93b506e98 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/profile/unordered.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +/* testing the gcc instrumented */ + +#include <unordered_map> +#include <unordered_set> +using std::unordered_map; +using std::unordered_set; + +void test_unordered_set() +{ + // Test for unordered set + unordered_set <int> *tmp2; + tmp2 = new unordered_set<int>; + tmp2->insert(1); + delete tmp2; +} +void test_unordered_map() +{ + unordered_map <int, int> *tmp; + for (int i=0; i<20; i++) + { + tmp = new unordered_map<int, int>(i+2); + // Insert more than default item + for (int j=0; j<10000; j++) { + (*tmp)[j]= j; + } + + delete tmp; + } + + tmp = new unordered_map<int, int>; + + // Insert more than default item + for (int i=0; i<150000; i++) { +// (*tmp)[i] = i; + (*tmp).insert(unordered_map<int, int>::value_type(i, i)); + } + + (*tmp).erase(1); + delete tmp; +} +int main() +{ + test_unordered_set(); + test_unordered_map(); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc new file mode 100644 index 000000000..8c429239e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <unordered_map> + +void +test01() +{ + std::unordered_map<int, double> um{{1, 1.0}, {2, 2.0}, {3, 3.0}}; + std::begin(um); + std::end(um); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc new file mode 100644 index 000000000..fa3095d5b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/52942.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <functional> + +struct TFoo {}; + +struct TFoo_hash +{ + std::size_t operator()(const TFoo &) const { return 0; } +}; + +void f1(std::unordered_map<TFoo, int, TFoo_hash> &) {} + +void f2() +{ + std::unordered_map<TFoo, int, TFoo_hash> map1; + std::bind(f1, std::ref(map1)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53067.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53067.cc new file mode 100644 index 000000000..e97f7a7d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53067.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <functional> + +void f() +{ + std::unordered_map<int, int> Foo; + ref(Foo); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53339.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53339.cc new file mode 100644 index 000000000..45e37e57b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/53339.cc @@ -0,0 +1,36 @@ +// XFAIL because of PR libstdc++/55043 fix +// { dg-do compile { xfail *-*-* } } +// { dg-excess-errors "" } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +struct LinkedHashMap +{ + struct Entry; + + typedef std::unordered_map<int, Entry> Storage; + typedef Storage::iterator EntryPtr; + + struct Entry + { + EntryPtr prev, next; + }; +}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/citerators.cc new file mode 100644 index 000000000..fd990b91f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/citerators.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_map<int, int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/cliterators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/cliterators.cc new file mode 100644 index 000000000..0f7ee70d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/cliterators.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_map<int, int> test_type; + typedef typename test_type::value_type value_type; + value_type v(1, 1); + __gnu_test::forward_members_unordered<test_type> test(v); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc new file mode 100644 index 000000000..abd9d2c0b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <debug/unordered_map> + +using namespace __gnu_debug; + +using std::allocator; +using std::equal_to; +using std::hash; +using std::pair; +using std::string; + +template class unordered_map<string, float>; +template class unordered_map<string, int, + hash<string>, equal_to<string>, + allocator<pair<const string, int> > >; +template class unordered_map<string, float, + hash<string>, equal_to<string>, + allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_mode.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_mode.cc new file mode 100644 index 000000000..b4d29828d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_mode.cc @@ -0,0 +1,30 @@ +// NB: This issue affected only debug-mode. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +//PR libstdc++/35922 +int main() +{ + std::unordered_map<int, int> m; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/basic.cc new file mode 100644 index 000000000..ad6732b25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_map<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..86d91a5e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_map<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..774f45ac8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_map<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..a1d7d1eed --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +template class std::unordered_map<int, float>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..608af74c0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/2.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::NonDefaultConstructible inst_type; +typedef __gnu_test::NonDefaultConstructible_hash hash_type; + +// N.B. We cannot instantiate with mapped_type == NonDefaultConstructible +// because of 23.5.1.2. +template class std::unordered_map<inst_type, double, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..de46c5ce6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/3.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +using namespace std; +template class unordered_map<int, int, hash<int>, equal_to<int>, allocator<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..f7fdd5201 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::OverloadedAddress inst_type; +typedef __gnu_test::OverloadedAddress_hash hash_type; + +// libstdc++/41792 +template class std::unordered_map<inst_type, inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..c03cb4513 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/5.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/typedefs.cc new file mode 100644 index 000000000..53e860f6d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <unordered_map> + +// Check container for required typedefs. +__gnu_test::types<std::unordered_map<int, long> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/55043.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/55043.cc new file mode 100644 index 000000000..aa6495798 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/55043.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/55043 + +#include <unordered_map> +#include <vector> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; +}; + +using hash = std::hash<int>; +using equal = std::equal_to<int>; + +template<typename Alloc> + using test_type = std::unordered_multimap<int, MoveOnly, hash, equal, Alloc>; + +void test01() +{ + typedef test_type<std::allocator<MoveOnly>> uim; + std::vector<uim> v; + v.emplace_back(uim()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy.cc new file mode 100644 index 000000000..38baeace8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc new file mode 100644 index 000000000..ac6495bbd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/minimal.cc new file mode 100644 index 000000000..5d7b21e98 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/minimal.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + + +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::SimpleAllocator; + +template class std::unordered_multimap<T, T, hash, equal_to, + SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v(alloc_type{}); + v.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move.cc new file mode 100644 index 000000000..b1f92b649 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc new file mode 100644 index 000000000..815ffdd90 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> +#include <testsuite_counter_type.h> + +using __gnu_test::propagating_allocator; +using __gnu_test::counter_type; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, false> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_multimap<counter_type, counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(1), std::make_tuple(1)); + + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(2), std::make_tuple(2)); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY( 1 == v1.get_allocator().get_personality() ); + VERIFY( 2 == v2.get_allocator().get_personality() ); + + // No move because key is const. + VERIFY( counter_type::move_assign_count == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, true> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_multimap<counter_type, counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(1), std::make_tuple(1)); + + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(2), std::make_tuple(2)); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); + + VERIFY( counter_type::move_assign_count == 0 ); + VERIFY( counter_type::destructor_count == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc new file mode 100644 index 000000000..94cacbc09 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/swap.cc new file mode 100644 index 000000000..869bc706c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/swap.cc @@ -0,0 +1,96 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<std::pair<const T, T>, false>&, + const propagating_allocator<std::pair<const T, T>, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<std::pair<const T, T>, false>&, + const propagating_allocator<std::pair<const T, T>, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, T>, false> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<std::pair<const T, T>, true> alloc_type; + typedef std::unordered_multimap<T, T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + test_type v2(alloc_type(2)); + v2.emplace(std::piecewise_construct, + std::make_tuple(T()), std::make_tuple(T())); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/moveable.cc new file mode 100644 index 000000000..861e805d3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on multimap (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_map> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multimap<int, int> a,b; + a.insert(std::make_pair(2,0)); + b.insert(std::make_pair(1,0)); + b = std::move(a); + VERIFY( b.find(2) != b.end() && a.find(1) == a.end() ); + + std::unordered_multimap<int, int> c(std::move(b)); + VERIFY( c.find(2) != c.end() ); + VERIFY( b.find(2) == b.end() ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc new file mode 100644 index 000000000..3a410392b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <unordered_map> + +std::unordered_multimap<int, int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc new file mode 100644 index 000000000..0c3064286 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_multimap<int, int> um; + um.begin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc new file mode 100644 index 000000000..830648ef7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + const std::unordered_map<int, int>& cum = um; + cum.begin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc new file mode 100644 index 000000000..b0be7ad00 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.bucket_size(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc new file mode 100644 index 000000000..842d5e3e6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.cbegin(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc new file mode 100644 index 000000000..d3d30b759 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.cend(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc new file mode 100644 index 000000000..44a192f11 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc new file mode 100644 index 000000000..f90f54c3c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc new file mode 100644 index 000000000..7317625cc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct4_neg.cc new file mode 100644 index 000000000..a9dc161c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc new file mode 100644 index 000000000..7197e24ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.end(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc new file mode 100644 index 000000000..eb2620616 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + const std::unordered_map<int, int>& cum = um; + cum.end(um.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc new file mode 100644 index 000000000..7bc8c8313 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc new file mode 100644 index 000000000..3e0ca5f5e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc new file mode 100644 index 000000000..0321ec815 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert4_neg.cc new file mode 100644 index 000000000..c771a0ad1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_map> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::unordered_multimap<int, int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc new file mode 100644 index 000000000..027a1db51 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + typedef std::unordered_multimap<int, int> cont_type; + __gnu_test::invalid_local_iterator_compare<cont_type>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc new file mode 100644 index 000000000..ef5d1f359 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + typedef std::unordered_multimap<int, int> cont_type; + __gnu_test::invalid_local_iterator_range<cont_type>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..5c71e3600 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_multimap<int, int> umm1; + auto it1 = umm1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc new file mode 100644 index 000000000..2f21f0654 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_map<int, int> um; + um.max_load_factor(-1.0f); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..c13a4eeb5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> + +void test01() +{ + std::unordered_multimap<int, int> umm1; + umm1 = std::move(umm1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc new file mode 100644 index 000000000..68348b000 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + typedef std::unordered_multimap<int, int> cont_type; + __gnu_test::use_erased_local_iterator<cont_type>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc new file mode 100644 index 000000000..70b30f288 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/checks.h> + +void test01() +{ + typedef std::unordered_multimap<int, int> cont_type; + __gnu_test::use_invalid_iterator<cont_type>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc new file mode 100644 index 000000000..0eed6012a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_map> +#include <debug/unordered_checks.h> + +void test01() +{ + typedef std::unordered_multimap<int, int> cont_type; + __gnu_test::use_invalid_local_iterator<cont_type>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/1.cc new file mode 100644 index 000000000..27f614353 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/1.cc @@ -0,0 +1,166 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multimap<std::string, int>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type("because to why", 1)); + mm1.insert(value_type("the stockholm syndrome", 2)); + mm1.insert(value_type("a cereous night", 3)); + mm1.insert(value_type("eeilo", 4)); + mm1.insert(value_type("protean", 5)); + mm1.insert(value_type("the way you are when", 6)); + mm1.insert(value_type("tillsammans", 7)); + mm1.insert(value_type("umbra/penumbra", 8)); + mm1.insert(value_type("belonging (no longer mix)", 9)); + mm1.insert(value_type("one line behind", 10)); + mm1.insert(value_type("because to why", 11)); + VERIFY( mm1.size() == 11 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + VERIFY( mm1.erase("eeilo") == 1 ); + VERIFY( mm1.size() == 10 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + iterator it1 = mm1.find("eeilo"); + VERIFY( it1 == mm1.end() ); + + VERIFY( mm1.erase("tillsammans") == 1 ); + VERIFY( mm1.size() == 9 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + iterator it2 = mm1.find("tillsammans"); + VERIFY( it2 == mm1.end() ); + + // Must work (see DR 526) + iterator it3 = mm1.find("belonging (no longer mix)"); + VERIFY( it3 != mm1.end() ); + VERIFY( mm1.erase(it3->first) == 1 ); + VERIFY( mm1.size() == 8 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + it3 = mm1.find("belonging (no longer mix)"); + VERIFY( it3 == mm1.end() ); + + VERIFY( !mm1.erase("abra") ); + VERIFY( mm1.size() == 8 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + VERIFY( !mm1.erase("eeilo") ); + VERIFY( mm1.size() == 8 ); + + VERIFY( mm1.erase("because to why") == 2 ); + VERIFY( mm1.size() == 6 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + iterator it4 = mm1.find("because to why"); + VERIFY( it4 == mm1.end() ); + + iterator it5 = mm1.find("umbra/penumbra"); + iterator it6 = mm1.find("one line behind"); + VERIFY( it5 != mm1.end() ); + VERIFY( it6 != mm1.end() ); + + VERIFY( mm1.find("the stockholm syndrome") != mm1.end() ); + VERIFY( mm1.find("a cereous night") != mm1.end() ); + VERIFY( mm1.find("the way you are when") != mm1.end() ); + VERIFY( mm1.find("a cereous night") != mm1.end() ); + + VERIFY( mm1.erase(it5->first) == 1 ); + VERIFY( mm1.size() == 5 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + it5 = mm1.find("umbra/penumbra"); + VERIFY( it5 == mm1.end() ); + + VERIFY( mm1.erase(it6->first) == 1 ); + VERIFY( mm1.size() == 4 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + it6 = mm1.find("one line behind"); + VERIFY( it6 == mm1.end() ); + + iterator it7 = mm1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( mm1.erase(it8->first) == 1 ); + VERIFY( mm1.size() == 3 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( mm1.erase(it9->first) == 1 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + VERIFY( mm1.size() == 2 ); + VERIFY( ++it10 == mm1.end() ); + + VERIFY( mm1.erase(mm1.begin()) != mm1.end() ); + VERIFY( mm1.size() == 1 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + VERIFY( mm1.begin() == it11 ); + + VERIFY( mm1.erase(mm1.begin()->first) == 1 ); + VERIFY( mm1.size() == 0 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + VERIFY( mm1.begin() == mm1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/2.cc new file mode 100644 index 000000000..948c7e2e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/2.cc @@ -0,0 +1,90 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multimap<std::string, int>& um) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != um.bucket_count(); ++b) + nb += um.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type("foo", 10)); + mm1.insert(value_type("foo", 11)); + mm1.insert(value_type("foo", 12)); + mm1.insert(value_type("foo", 13)); + mm1.insert(value_type("foo", 14)); + mm1.insert(value_type("foo", 15)); + mm1.insert(value_type("bar", 20)); + mm1.insert(value_type("bar", 21)); + mm1.insert(value_type("bar", 22)); + mm1.insert(value_type("bar", 23)); + mm1.insert(value_type("bar", 24)); + mm1.insert(value_type("bar", 25)); + VERIFY( mm1.size() == 12 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + VERIFY( mm1.erase(mm1.begin()) != mm1.end() ); + VERIFY( mm1.size() == 11 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + auto it = mm1.begin(); + advance(it, 2); + VERIFY( mm1.erase(mm1.begin(), it) != mm1.end() ); + VERIFY( mm1.size() == 9 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + VERIFY( mm1.erase(mm1.begin()->first) == 3 ); + VERIFY( mm1.size() == 6 ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); + + VERIFY( mm1.erase(mm1.begin(), mm1.end()) == mm1.end() ); + VERIFY( mm1.empty() ); + VERIFY( get_nb_bucket_elems(mm1) == mm1.size() ); + VERIFY( distance(mm1.begin(), mm1.end()) - mm1.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/24061-multimap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/24061-multimap.cc new file mode 100644 index 000000000..69cbf1de7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/24061-multimap.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type("all the love in the world", 1)); + mm1.insert(value_type("you know what you are?", 2)); + mm1.insert(value_type("the collector", 3)); + mm1.insert(value_type("the hand that feeds", 4)); + mm1.insert(value_type("love is not enough", 5)); + mm1.insert(value_type("every day is exactly the same", 6)); + mm1.insert(value_type("with teeth", 7)); + mm1.insert(value_type("only", 8)); + mm1.insert(value_type("getting smaller", 9)); + mm1.insert(value_type("sunspots", 10)); + + mm1.insert(value_type("you know what you are?", 5)); + mm1.insert(value_type("the collector", 6)); + mm1.insert(value_type("the hand that feeds", 7)); + VERIFY( mm1.size() == 13 ); + + iterator it1 = mm1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = mm1.erase(it1); + VERIFY( mm1.size() == 12 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = mm1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = mm1.erase(it4, it5); + VERIFY( mm1.size() == 10 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = mm1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = mm1.erase(it7); + VERIFY( mm1.size() == 9 ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = mm1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = mm1.erase(it10, it11); + VERIFY( mm1.size() == 5 ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + + iterator it13 = mm1.erase(mm1.begin(), mm1.end()); + VERIFY( mm1.size() == 0 ); + VERIFY( it13 == mm1.end() ); + VERIFY( it13 == mm1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc new file mode 100644 index 000000000..036fbc834 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> + +struct X +{ + template<typename T> + X(T&) {} +}; + +struct X_hash +{ std::size_t operator()(const X&) const { return 0; } }; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_multimap<X, int, X_hash>& s, X x) +{ + std::unordered_multimap<X, int, X_hash>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51845-multimap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51845-multimap.cc new file mode 100644 index 000000000..2b5b0ad77 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51845-multimap.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// 2012-01-19 Jakub Jelinek <jakub@redhat.com> +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +// libstdc++/51845 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<int, int> Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type(11135, 1)); + mm1.insert(value_type(11135, 17082)); + mm1.insert(value_type(9644, 24135)); + mm1.insert(value_type(9644, 9644)); + mm1.insert(value_type(13984, 19841)); + mm1.insert(value_type(9644, 1982)); + mm1.insert(value_type(13984, 1945)); + mm1.insert(value_type(7, 1982)); + mm1.insert(value_type(7, 1945)); + VERIFY( mm1.size() == 9 ); + + iterator it1 = mm1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + ++it2; + iterator it3 = mm1.erase(it1, it2); + VERIFY( mm1.size() == 7 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + const_iterator it4 = mm1.begin(); + ++it4; + const_iterator it5 = it4; + ++it5; + const_iterator it6 = mm1.erase(it4); + VERIFY( mm1.size() == 6 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/54276.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/54276.cc new file mode 100644 index 000000000..da919f1a7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/54276.cc @@ -0,0 +1,101 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <unordered_map> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +struct A +{ + int x; + static std::set<const A*> destroyed; + + A() + { destroyed.erase(this); } + + A(const A& a) + : x(a.x) + { destroyed.erase(this); } + + ~A() + { destroyed.insert(this); } + + bool + operator==(const A& other) const + { + VERIFY( destroyed.find(this) == destroyed.end() ); + VERIFY( destroyed.find(&other) == destroyed.end() ); + return x == other.x; + } +}; + +std::set<const A*> A::destroyed; + +struct hasher +{ + std::size_t operator()(const A& a) const + { + VERIFY( A::destroyed.find(&a) == A::destroyed.end() ); + return a.x / 10; + } +}; + +void test01() +{ + typedef std::unordered_multimap<A, A, hasher> UMMap; + UMMap map; + + A::destroyed.clear(); + A a; + a.x = 0; + map.insert({a, a}); + map.insert({a, a}); + VERIFY( map.size() == 2 ); + std::size_t bkt = map.bucket(a); + VERIFY( map.bucket_size(bkt) == 2 ); + + VERIFY( map.erase( map.begin(bkt)->first ) == 2 ); +} + +void test02() +{ + typedef std::unordered_multimap<A, A, hasher> UMMap; + UMMap map; + + A::destroyed.clear(); + A a; + a.x = 0; + map.insert({a, a}); + map.insert({a, a}); + VERIFY( map.size() == 2 ); + std::size_t bkt = map.bucket(a); + VERIFY( map.bucket_size(bkt) == 2 ); + + VERIFY( map.erase( map.begin(bkt)->second ) == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/final_hash.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/final_hash.cc new file mode 100644 index 000000000..c9201d41e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/final_hash.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <unordered_map> + +namespace +{ + template<typename _Tp> + struct final_hash final + { + std::size_t operator() (const _Tp&) const noexcept + { return 0; } + }; +} + +// A non-integral type: +template class std::unordered_multimap<std::string, int, + final_hash<std::string>>; + +// An integral type; +template class std::unordered_multimap<int, int, final_hash<int>>; + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/hash_policy/dr1189.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/hash_policy/dr1189.cc new file mode 100644 index 000000000..3a0e75195 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/hash_policy/dr1189.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +// DR 1189. Awkward interface for changing the number of buckets +// in an unordered associative container +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multimap<int, double> mm1; + mm1.reserve(10); + VERIFY( mm1.bucket_count() >= 10 ); + + mm1.reserve(100); + VERIFY( mm1.bucket_count() >= 100 ); + + std::unordered_map<int, double> mm2(100); + VERIFY( mm2.bucket_count() >= 100 ); + + mm2.reserve(1000); + VERIFY( mm2.bucket_count() >= 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc new file mode 100644 index 000000000..4ab6ef3e8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <unordered_map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + typedef unordered_multimap<int,double> Container; + typedef Container::const_iterator iterator; + typedef pair<iterator,iterator> itpair; + + Container m({ { 1, 1.0 }, { 1, 2.0 }, { 1, 237.0 } }); + VERIFY(m.size() == 3); + itpair ip = m.equal_range(1); + VERIFY(distance(ip.first, ip.second) == 3); + set<double> s = { 1.0, 2.0, 237.0 }; + for (iterator i = ip.first; i != ip.second; ++i) + s.erase (i->second); + VERIFY(s.empty()); + + m = { {5, 55.0}, { 5, 66.0 }, { 42, 4242.0 } }; + VERIFY(m.size() == 3); + ip = m.equal_range(5); + VERIFY(distance(ip.first, ip.second) == 2); + s = { 55.0, 66.0 }; + for (iterator i = ip.first; i != ip.second; ++i) + s.erase (i->second); + VERIFY(s.empty()); + + m.insert({ { 7, 77.0 }, { 7, 88.0 } }); + VERIFY(m.size() == 5); + VERIFY(m.count(5) == 2); + VERIFY(m.count(42) == 1); + VERIFY(m.count(7) == 2); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/24061-multimap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/24061-multimap.cc new file mode 100644 index 000000000..fec2df516 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/24061-multimap.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + iterator it1 = mm1.insert(mm1.begin(), + value_type("all the love in the world", 1)); + VERIFY( mm1.size() == 1 ); + VERIFY( *it1 == value_type("all the love in the world", 1) ); + + const_iterator cit1(it1); + const_iterator cit2 = mm1.insert(cit1, + value_type("you know what you are?", 2)); + VERIFY( mm1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == value_type("you know what you are?", 2) ); + + iterator it2 = mm1.insert(it1, value_type("all the love in the world", 3)); + VERIFY( mm1.size() == 3 ); + VERIFY( it2 != it1 ); + VERIFY( *it2 == value_type("all the love in the world", 3) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/51866.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/51866.cc new file mode 100644 index 000000000..ee9370faf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/51866.cc @@ -0,0 +1,87 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +struct num +{ + int value; + num(int n) : value(n) {} + num(num const&) = default; + num& operator=(num const&) = default; + num(num&& o) : value(o.value) + { o.value = -1; } + num& operator=(num&& o) + { + if (this != &o) + { + value = o.value; + o.value = -1; + } + return *this; + } +}; + +struct num_hash +{ + size_t operator()(num const& a) const + { return a.value; } +}; + +struct num_equal +{ + static bool _S_called_on_moved_instance; + bool operator()(num const& a, num const& b) const + { + if (a.value == -1 || b.value == -1) + _S_called_on_moved_instance = true; + return a.value == b.value; + } +}; + +bool num_equal::_S_called_on_moved_instance = false; + +// libstdc++/51866 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multimap<num, int, num_hash, num_equal> mmap; + mmap.insert(std::make_pair(num(1), 1)); + mmap.insert(std::make_pair(num(2), 2)); + mmap.insert(std::make_pair(num(1), 3)); + mmap.insert(std::make_pair(num(2), 4)); + VERIFY( mmap.size() == 4 ); + auto iter = mmap.cbegin(); + auto x0 = (iter++)->first.value; + auto x1 = (iter++)->first.value; + auto x2 = (iter++)->first.value; + auto x3 = (iter++)->first.value; + VERIFY( iter == mmap.cend() ); + VERIFY( (x0 == 1 && x1 == 1 && x2 == 2 && x3 == 2) + || (x0 == 2 && x1 == 2 && x2 == 1 && x3 == 1) ); + VERIFY( !num_equal::_S_called_on_moved_instance ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/52476.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/52476.cc new file mode 100644 index 000000000..414933794 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/52476.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <vector> +#include <algorithm> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + unordered_multimap<int, int> mmap; + vector<int> values; + + size_t nb_bkts = mmap.bucket_count(); + int i = 0; + for (;; ++i) + { + mmap.insert(make_pair(0, i)); + if (mmap.bucket_count() != nb_bkts) + // Container got rehash + break; + values.clear(); + transform(mmap.begin(), mmap.end(), back_inserter(values), + [](const pair<int, int>& p) { return p.second; }); + } + + vector<int> rehash_values; + transform(mmap.begin(), mmap.end(), back_inserter(rehash_values), + [](const pair<int, int>& p) { return p.second; }); + // Remove the value that result in a rehash + rehash_values.erase(remove(rehash_values.begin(), rehash_values.end(), i)); + + VERIFY( rehash_values == values ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/53115.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/53115.cc new file mode 100644 index 000000000..846cb4928 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/53115.cc @@ -0,0 +1,101 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multimap<int, int>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + std::unordered_multimap<int, int> umm; + umm.insert(make_pair(10, 1)); + VERIFY( umm.size() == 1 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(10, 2)); + VERIFY( umm.size() == 2 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(10, 3)); + VERIFY( umm.size() == 3 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(10, 4)); + VERIFY( umm.size() == 4 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(10, 5)); + VERIFY( umm.size() == 5 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(24, 6)); + VERIFY( umm.size() == 6 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(25, 7)); + VERIFY( umm.size() == 7 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(2, 8)); + VERIFY( umm.size() == 8 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(2, 9)); + VERIFY( umm.size() == 9 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(1, 10)); + VERIFY( umm.size() == 10 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); + + umm.insert(make_pair(10, 11)); + VERIFY( umm.size() == 11 ); + VERIFY( distance(umm.begin(), umm.end()) - umm.size() == 0 ); + VERIFY( get_nb_bucket_elems(umm) == umm.size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/55028-debug.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/55028-debug.cc new file mode 100644 index 000000000..6ea97c6d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/55028-debug.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/55028 +#include <string> +#include <unordered_map> +#include <testsuite_hooks.h> + +struct MyType +{ }; + +void test() +{ + // using MyMap = std::multimap<std::string, MyType *>; // works + using MyMap = std::unordered_multimap<std::string, MyType*>; // fails to link + MyMap m; + m.insert(std::make_pair(std::string("blah"), new MyType)); +} + +int main() +{ + test(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/57619.C b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/57619.C new file mode 100644 index 000000000..d44a7cef4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/57619.C @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + { + std::unordered_multimap<std::string, std::string> mymmap; + std::pair<std::string, std::string> mypair{std::string("key"), + std::string("value")}; + mymmap.insert(mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } + + { + std::unordered_multimap<std::string, std::string> mymmap; + std::pair<std::string, std::string> mypair{std::string("key"), + std::string("value")}; + mymmap.insert(mymmap.begin(), mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/hint.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/hint.cc new file mode 100644 index 000000000..8e0ff94c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/hint.cc @@ -0,0 +1,123 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// Insert with hint, specific to this library implementation. + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<int, int> Map; + typedef typename Map::value_type Pair; + + Map m; + + auto it1 = m.insert(Pair(0, 0)); + VERIFY( it1 != m.end() ); + VERIFY( it1->first == 0 ); + VERIFY( it1->second == 0 ); + + auto it2 = m.insert(it1, Pair(0, 2)); + VERIFY( it2 != m.end() ); + VERIFY( it2 != it1 ); + VERIFY( it2->second == 2 ); + VERIFY( it2 == std::next(it1) ); + + Pair p(0, 1); + it2 = m.insert(it1, p); + VERIFY( it2 == std::next(it1) ); +} + +struct hasher +{ + std::size_t operator()(int val) const + { return val / 2; } +}; + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<int, int, hasher> Map; + typedef typename Map::value_type Pair; + + Map m; + + auto it1 = m.insert(Pair(0, 0)); + auto it2 = m.insert(it1, Pair(1, 0)); + VERIFY( m.bucket(it1->first) == m.bucket(it2->first) ); + VERIFY( m.bucket_size(m.bucket(it1->first)) == 2 ); + + auto it3 = m.insert(it2, Pair(2, 0)); + VERIFY( m.bucket(it3->first) != m.bucket(it2->first) ); + VERIFY( m.bucket_size(m.bucket(it3->first)) == 1 ); + + auto it4 = m.insert(it1, Pair(0, 1)); + VERIFY( it4 == std::next(it1) ); + VERIFY( m.bucket_size(m.bucket(it1->first)) == 3 ); + VERIFY( m.bucket_size(m.bucket(it3->first)) == 1 ); + + Pair p(1, 1); + it4 = m.insert(it2, p); + VERIFY( it4 == std::next(it2) ); + VERIFY( m.bucket_size(m.bucket(it1->first)) == 4 ); + auto range = m.equal_range(0); + VERIFY( std::distance(range.first, range.second) == 2 ); + range = m.equal_range(1); + VERIFY( std::distance(range.first, range.second) == 2 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<int, int> Map; + typedef typename Map::value_type Pair; + + Map m; + + auto it1 = m.insert(Pair(0, 0)); + VERIFY( it1 != m.end() ); + VERIFY( it1->first == 0 ); + VERIFY( it1->second == 0 ); + + auto it2 = m.emplace_hint(it1, std::piecewise_construct, + std::make_tuple(0), + std::make_tuple(2)); + VERIFY( it2 != m.end() ); + VERIFY( it2 != it1 ); + VERIFY( it2->second == 2 ); + VERIFY( it2 == std::next(it1) ); + + Pair p(0, 1); + it2 = m.emplace_hint(it1, p); + VERIFY( it2 == std::next(it1) ); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_range.cc new file mode 100644 index 000000000..705c2b904 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_range.cc @@ -0,0 +1,91 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <string> +#include <iterator> +#include <algorithm> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[5] = + { + Pair("red", 5), + Pair("green", 9), + Pair("blue", 3), + Pair("cyan", 8), + Pair("magenta", 7) + }; + + m.insert(A+0, A+5); + VERIFY(m.size() == 5); + VERIFY(std::distance(m.begin(), m.end()) == 5); + + for (int i = 0; i < 5; ++i) + VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[9] = + { + Pair("red", 5), + Pair("green", 9), + Pair("red", 19), + Pair("blue", 3), + Pair("blue", 60), + Pair("cyan", 8), + Pair("magenta", 7), + Pair("blue", 99), + Pair("green", 33) + }; + + m.insert(A+0, A+9); + VERIFY(m.size() == 9); + VERIFY(std::distance(m.begin(), m.end()) == 9); + + for (int i = 0; i < 9; ++i) + VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single.cc new file mode 100644 index 000000000..df4d142a4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single.cc @@ -0,0 +1,76 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <string> +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + Map::iterator i = m.insert(Pair("abcde", 3)); + VERIFY(m.size() == 1); + VERIFY(std::distance(m.begin(), m.end()) == 1); + VERIFY(i == m.begin()); + VERIFY(i->first == "abcde"); + VERIFY(i->second == 3); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multimap<std::string, int> Map; + typedef std::pair<const std::string, int> Pair; + + Map m; + VERIFY(m.empty()); + + m.insert(Pair("abcde", 3)); + m.insert(Pair("abcde", 7)); + + VERIFY(m.size() == 2); + VERIFY(std::distance(m.begin(), m.end()) == 2); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY(i1->first == "abcde"); + VERIFY(i2->first == "abcde"); + VERIFY((i1->second == 3 && i2->second == 7) || + (i1->second == 7 && i2->second == 3)); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-1.cc new file mode 100644 index 000000000..fa52a2bf5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-1.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(Pair(1, rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( i->first == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multimap<int, rvalstruct> Map; + typedef std::pair<const int, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + m.insert(Pair(2, rvalstruct(3))); + m.insert(Pair(2, rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( i1->first == 2 ); + VERIFY( i2->first == 2 ); + VERIFY( ((i1->second).val == 3 && (i2->second).val == 7) + || ((i1->second).val == 7 && (i2->second).val == 3) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-2.cc new file mode 100644 index 000000000..ad3e6be40 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/multimap_single_move-2.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator i = m.insert(Pair(rvalstruct(1), rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( i == m.begin() ); + VERIFY( (i->first).val == 1 ); + VERIFY( (i->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multimap<rvalstruct, rvalstruct> Map; + typedef std::pair<rvalstruct, rvalstruct> Pair; + + Map m; + VERIFY( m.empty() ); + + m.insert(Pair(rvalstruct(2), rvalstruct(3))); + m.insert(Pair(rvalstruct(2), rvalstruct(7))); + + VERIFY( m.size() == 2 ); + VERIFY( std::distance(m.begin(), m.end()) == 2 ); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY( (i1->first).val == 2 ); + VERIFY( (i2->first).val == 2 ); + VERIFY( ((i1->second).val == 3 && (i2->second).val == 7) + || ((i1->second).val == 7 && (i2->second).val == 3) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/emplace.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/emplace.cc new file mode 100644 index 000000000..af9a743e6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/emplace.cc @@ -0,0 +1,110 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <tuple> +#include <vector> +#include <unordered_map> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_multimap<char, std::vector<double>> MMap; + MMap mm; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = mm.emplace('a', coord1); + VERIFY( mm.size() == 1 ); + VERIFY( it->first == 'a' ); + + coord1[0] = 3.0; + it = mm.emplace('a', coord1); + VERIFY( mm.size() == 2 ); + VERIFY( it->first == 'a' ); + VERIFY( it->second[0] == 3.0 ); + + it = mm.emplace_hint(mm.begin(), 'b', coord1); + VERIFY( it != mm.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second[0] == 3.0 ); + + double *px = &coord1[0]; + it = mm.emplace('c', std::move(coord1)); + VERIFY( it->first == 'c' ); + VERIFY( &(it->second[0]) == px ); +} + +void test02() +{ + using namespace std; + typedef unordered_multimap<char, PathPoint> Map; + Map m; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple('a', coord1)); + VERIFY( m.size() == 1 ); + VERIFY( it->first == 'a' ); + + coord1[0] = 3.0; + it = m.emplace(piecewise_construct, + make_tuple('a'), make_tuple( 'b', coord1)); + VERIFY( m.size() == 2 ); + VERIFY( it->first == 'a' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + it = m.emplace_hint(m.begin(), piecewise_construct, + make_tuple('b'), make_tuple('c', coord1)); + VERIFY( it != m.end() ); + VERIFY( it->first == 'b' ); + VERIFY( it->second.getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + it = m.emplace(piecewise_construct, + make_tuple('c'), make_tuple('d', move(coord1))); + VERIFY( it->first == 'c' ); + VERIFY( &(it->second.getCoords()[0]) == px ); +} + + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/reserve.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/reserve.cc new file mode 100644 index 000000000..93073701d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/reserve.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + const int N = 1000; + + typedef std::unordered_multimap<int, int> MMap; + MMap m; + m.reserve(N * 2); + + std::size_t bkts = m.bucket_count(); + for (int i = 0; i != N; ++i) + { + m.insert(std::make_pair(i, i)); + m.insert(std::make_pair(i, i)); + // As long as we insert less than the reserved number of elements we + // shouldn't experiment any rehash. + VERIFY( m.bucket_count() == bkts ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/observers.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/observers.cc new file mode 100644 index 000000000..008760f57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/observers.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +void +test01() +{ + std::unordered_multimap<int, int> um; + + auto ke __attribute__((unused)) = um.key_eq(); + auto h __attribute__((unused)) = um.hash_function(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc new file mode 100644 index 000000000..52efe78d1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef unordered_multimap<int, int>::value_type value_type; + + unordered_multimap<int, int> umm0; + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 0 ); + + umm0.insert(value_type(1, 1)); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 1 ); + + umm0.insert(value_type(1, 2)); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 2 ); + + umm0.insert(value_type(2, 1)); + VERIFY( umm0.count(2) == 1 ); + + umm0.insert(value_type(3, 1)); + umm0.insert(value_type(3, 2)); + umm0.insert(value_type(3, 3)); + VERIFY( umm0.count(3) == 3 ); + + umm0.erase(2); + VERIFY( umm0.count(2) == 0 ); + + umm0.erase(0); + VERIFY( umm0.count(0) == 0 ); + + unordered_multimap<int, int> umm1(umm0); + VERIFY( umm1.count(0) == 0 ); + VERIFY( umm1.count(1) == 2 ); + VERIFY( umm1.count(2) == 0 ); + VERIFY( umm1.count(3) == 3 ); + + umm0.clear(); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 0 ); + VERIFY( umm0.count(2) == 0 ); + VERIFY( umm0.count(3) == 0 ); + + umm1.insert(value_type(4, 1)); + umm1.insert(value_type(5, 1)); + umm1.insert(value_type(5, 2)); + umm1.insert(value_type(5, 3)); + umm1.insert(value_type(5, 4)); + VERIFY( umm1.count(4) == 1 ); + VERIFY( umm1.count(5) == 4 ); + + umm1.erase(1); + VERIFY( umm1.count(1) == 0 ); + + umm1.erase(umm1.find(5)); + VERIFY( umm1.count(5) == 3 ); + + umm1.insert(value_type(1, 1)); + umm1.insert(value_type(1, 2)); + VERIFY( umm1.count(1) == 2 ); + + umm1.erase(5); + VERIFY( umm1.count(5) == 0 ); + + umm1.erase(umm1.find(4)); + VERIFY( umm1.count(4) == 0 ); + + umm1.clear(); + VERIFY( umm1.count(0) == 0 ); + VERIFY( umm1.count(1) == 0 ); + VERIFY( umm1.count(2) == 0 ); + VERIFY( umm1.count(3) == 0 ); + VERIFY( umm1.count(4) == 0 ); + VERIFY( umm1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc new file mode 100644 index 000000000..8f53de471 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc @@ -0,0 +1,192 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_multimap<int, int> umm1, umm2; + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -1)); + umm2.insert(Pair(2, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -3)); + VERIFY( (umm1 == umm2) ); + VERIFY( !(umm1 != umm2) ); + + umm2.clear(); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(3, -3)); + umm2.insert(Pair(4, -4)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(4, -4)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -3)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(4, -4)); + umm2.insert(Pair(4, -4)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(2, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -3)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(2, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -3)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -3)); + umm2.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -4)); + umm2.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(1, -2)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -4)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + const std::unordered_multimap<int, int> cumm1(umm1), cumm2(umm2); + VERIFY( cumm1 == cumm2 ); + VERIFY( !(cumm1 != cumm2) ); + VERIFY( cumm1 == umm2 ); + VERIFY( !(umm1 != cumm2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc new file mode 100644 index 000000000..cc29c9e65 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <algorithm> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_multimap<int, int> umm1, umm2; + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + int second1[] = { -1, -2, -3, -4, -5 }; + int second2[] = { -1, -2, -3, -4, -5 }; + const unsigned size = sizeof(second1) / sizeof(int); + + for (unsigned perm1 = 0; perm1 < 120; ++perm1) + { + umm1.clear(); + std::next_permutation(second1, second1 + size); + for (unsigned i1 = 0; i1 < size; ++i1) + umm1.insert(Pair(0, second1[i1])); + + for (unsigned perm2 = 0; perm2 < 120; ++perm2) + { + umm2.clear(); + std::next_permutation(second2, second2 + size); + for (unsigned i2 = 0; i2 < size; ++i2) + umm2.insert(Pair(0, second2[i2])); + + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc new file mode 100644 index 000000000..987f1c234 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <unordered_map> + +void +test01() +{ + std::unordered_multimap<int, double> umm{{1, 1.0}, {2, 2.0}, {3, 3.0}}; + std::begin(umm); + std::end(umm); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/53339.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/53339.cc new file mode 100644 index 000000000..446cfcd54 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/53339.cc @@ -0,0 +1,36 @@ +// XFAIL because of PR libstdc++/55043 fix +// { dg-do compile { xfail *-*-* } } +// { dg-excess-errors "" } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +struct LinkedHashMap +{ + struct Entry; + + typedef std::unordered_multimap<int, Entry> Storage; + typedef Storage::iterator EntryPtr; + + struct Entry + { + EntryPtr prev, next; + }; +}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/citerators.cc new file mode 100644 index 000000000..3e94de1b9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_multimap<int, int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/cliterators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/cliterators.cc new file mode 100644 index 000000000..cc38ca11e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/cliterators.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_multimap<int, int> test_type; + typedef typename test_type::value_type value_type; + value_type v(1, 1); + __gnu_test::forward_members_unordered<test_type> test(v); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/debug.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/debug.cc new file mode 100644 index 000000000..488dbe5e9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/debug.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <debug/unordered_map> + +using namespace __gnu_debug; + +using std::string; + +template class unordered_multimap<string, float>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/basic.cc new file mode 100644 index 000000000..b83e165e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multimap<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..e5ec2a755 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multimap<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..bdbac57b9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multimap<value_type, value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..1562f6f5f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +template class std::unordered_multimap<int, float>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..99363d72a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::NonDefaultConstructible inst_type; +typedef __gnu_test::NonDefaultConstructible_hash hash_type; +template class std::unordered_multimap<inst_type, inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..e3d0f47c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/3.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> + +using namespace std; +template class unordered_multimap<int, int, hash<int>, equal_to<int>, allocator<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..c619fe3be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::OverloadedAddress inst_type; +typedef __gnu_test::OverloadedAddress_hash hash_type; + +// libstdc++/41792 +template class std::unordered_multimap<inst_type, inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..1a4f7dd68 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/5.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_map> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::unordered_multimap<int, int, std::hash<int>, + std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::unordered_multimap<int, int, std::hash<int>, + std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/typedefs.cc new file mode 100644 index 000000000..3443ed76f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <unordered_map> + +// Check container for required typedefs. +__gnu_test::types<std::unordered_multimap<int, long> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/55043.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/55043.cc new file mode 100644 index 000000000..d17ee0c2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/55043.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/55043 + +#include <unordered_set> +#include <vector> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; +}; + +struct equal { + bool operator()(const MoveOnly&, const MoveOnly&) const { return true; } +}; +struct hash { + std::size_t operator()(const MoveOnly&) const { return 0; } +}; + +template<typename Alloc> + using test_type = std::unordered_multiset<MoveOnly, hash, equal, Alloc>; + +void test01() +{ + typedef test_type<std::allocator<MoveOnly>> uim; + std::vector<uim> v; + v.emplace_back(uim()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy.cc new file mode 100644 index 000000000..7009d59f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy_assign.cc new file mode 100644 index 000000000..475cd54d9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/copy_assign.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/minimal.cc new file mode 100644 index 000000000..e5db626f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/minimal.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + + +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::SimpleAllocator; + +template class std::unordered_multiset<T, hash, equal_to, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v(alloc_type{}); + v.insert(T()); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move.cc new file mode 100644 index 000000000..44c45fde3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc new file mode 100644 index 000000000..8db50560d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> +#include <testsuite_counter_type.h> + +using __gnu_test::propagating_allocator; +using __gnu_test::counter_type; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, false> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_multiset<counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(0); + + test_type v2(alloc_type(2)); + v2.emplace(1); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY( 1 == v1.get_allocator().get_personality() ); + VERIFY( 2 == v2.get_allocator().get_personality() ); + + VERIFY( counter_type::move_count == 1 ); + VERIFY( counter_type::destructor_count == 2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, true> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_multiset<counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(0); + + test_type v2(alloc_type(2)); + v2.emplace(0); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); + + VERIFY( counter_type::move_count == 0 ); + VERIFY( counter_type::copy_count == 0 ); + VERIFY( counter_type::destructor_count == 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc new file mode 100644 index 000000000..ecaac98c2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/swap.cc new file mode 100644 index 000000000..b3ee03475 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/swap.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/copy.cc new file mode 100644 index 000000000..f52daa2e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/copy.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on set (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + const int nb = 10000; + std::unordered_multiset<int> ref; + for (int i = 0; i != nb; ++i) + { + ref.insert(i); + ref.insert(i); + } + + std::unordered_multiset<int> copy(ref); + VERIFY( copy.size() == ref.size() ); + VERIFY( std::equal(ref.begin(), ref.end(), copy.begin()) ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/moveable.cc new file mode 100644 index 000000000..b967c4dae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on set (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multiset<int> a,b; + a.insert(2); + b.insert(1); + b = std::move(a); + VERIFY( b.find(2) != b.end() && a.find(1) == a.end() ); + + std::unordered_multiset<int> c(std::move(b)); + VERIFY( c.find(2) != c.end() ); + VERIFY( b.find(2) == b.end() ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc new file mode 100644 index 000000000..7f61cc7bf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <unordered_set> + +std::unordered_multiset<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc new file mode 100644 index 000000000..48e4c6361 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.begin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc new file mode 100644 index 000000000..5a4f2760f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + const std::unordered_multiset<int>& cus = us; + cus.begin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc new file mode 100644 index 000000000..2619b27e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.bucket_size(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc new file mode 100644 index 000000000..7fd29b839 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.cbegin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc new file mode 100644 index 000000000..1c81e5dba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.cend(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc new file mode 100644 index 000000000..16825797e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc new file mode 100644 index 000000000..586fbd7b1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc new file mode 100644 index 000000000..6d7c9f6a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct4_neg.cc new file mode 100644 index 000000000..8b5ba761d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc new file mode 100644 index 000000000..4164c3213 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.end(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc new file mode 100644 index 000000000..0463ba332 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + const std::unordered_multiset<int>& cus = us; + cus.end(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc new file mode 100644 index 000000000..d0c06c2aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc new file mode 100644 index 000000000..0fc5f0fe5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc new file mode 100644 index 000000000..393b90630 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert4_neg.cc new file mode 100644 index 000000000..40ce51ccf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::unordered_multiset<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc new file mode 100644 index 000000000..eae193c4c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_compare<std::unordered_multiset<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc new file mode 100644 index 000000000..f963e9b67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_range<std::unordered_multiset<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..fa22f2bf8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> ums1; + auto it1 = ums1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc new file mode 100644 index 000000000..44b7bcf63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> us; + us.max_load_factor(-1.0f); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..86e46c94a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_multiset<int> ums1; + ums1 = std::move(ums1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc new file mode 100644 index 000000000..7e18471aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_erased_local_iterator<std::unordered_multiset<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc new file mode 100644 index 000000000..68c188b56 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::use_invalid_iterator<std::unordered_multiset<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc new file mode 100644 index 000000000..a52e16a4f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_invalid_local_iterator<std::unordered_multiset<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/1.cc new file mode 100644 index 000000000..89feeb579 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/1.cc @@ -0,0 +1,165 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<std::string>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Mset; + typedef Mset::iterator iterator; + typedef Mset::const_iterator const_iterator; + + Mset ms1; + + ms1.insert("because to why"); + ms1.insert("the stockholm syndrome"); + ms1.insert("a cereous night"); + ms1.insert("eeilo"); + ms1.insert("protean"); + ms1.insert("the way you are when"); + ms1.insert("tillsammans"); + ms1.insert("umbra/penumbra"); + ms1.insert("belonging (no longer mix)"); + ms1.insert("one line behind"); + ms1.insert("because to why"); + VERIFY( ms1.size() == 11 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + VERIFY( ms1.erase("eeilo") == 1 ); + VERIFY( ms1.size() == 10 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + iterator it1 = ms1.find("eeilo"); + VERIFY( it1 == ms1.end() ); + + VERIFY( ms1.erase("tillsammans") == 1 ); + VERIFY( ms1.size() == 9 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + iterator it2 = ms1.find("tillsammans"); + VERIFY( it2 == ms1.end() ); + + // Must work (see DR 526) + iterator it3 = ms1.find("belonging (no longer mix)"); + VERIFY( it3 != ms1.end() ); + VERIFY( ms1.erase(*it3) == 1 ); + VERIFY( ms1.size() == 8 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + it3 = ms1.find("belonging (no longer mix)"); + VERIFY( it3 == ms1.end() ); + + VERIFY( !ms1.erase("abra") ); + VERIFY( ms1.size() == 8 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + VERIFY( !ms1.erase("eeilo") ); + VERIFY( ms1.size() == 8 ); + + VERIFY( ms1.erase("because to why") == 2 ); + VERIFY( ms1.size() == 6 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + iterator it4 = ms1.find("because to why"); + VERIFY( it4 == ms1.end() ); + + iterator it5 = ms1.find("umbra/penumbra"); + iterator it6 = ms1.find("one line behind"); + VERIFY( it5 != ms1.end() ); + VERIFY( it6 != ms1.end() ); + + VERIFY( ms1.find("the stockholm syndrome") != ms1.end() ); + VERIFY( ms1.find("a cereous night") != ms1.end() ); + VERIFY( ms1.find("the way you are when") != ms1.end() ); + VERIFY( ms1.find("a cereous night") != ms1.end() ); + + VERIFY( ms1.erase(*it5) == 1 ); + VERIFY( ms1.size() == 5 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + it5 = ms1.find("umbra/penumbra"); + VERIFY( it5 == ms1.end() ); + + VERIFY( ms1.erase(*it6) == 1 ); + VERIFY( ms1.size() == 4 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + it6 = ms1.find("one line behind"); + VERIFY( it6 == ms1.end() ); + + iterator it7 = ms1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( ms1.erase(*it8) == 1 ); + VERIFY( ms1.size() == 3 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( ms1.erase(*it9) == 1 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + VERIFY( ms1.size() == 2 ); + VERIFY( ++it10 == ms1.end() ); + + VERIFY( ms1.erase(ms1.begin()) != ms1.end() ); + VERIFY( ms1.size() == 1 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + VERIFY( ms1.begin() == it11 ); + + VERIFY( ms1.erase(*ms1.begin()) == 1 ); + VERIFY( ms1.size() == 0 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + VERIFY( ms1.begin() == ms1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/2.cc new file mode 100644 index 000000000..69de04642 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/2.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<std::string>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Mset; + typedef Mset::iterator iterator; + typedef Mset::const_iterator const_iterator; + + Mset ms1; + + ms1.insert("foo"); + ms1.insert("foo"); + ms1.insert("foo"); + ms1.insert("foo"); + ms1.insert("foo"); + ms1.insert("foo"); + ms1.insert("bar"); + ms1.insert("bar"); + ms1.insert("bar"); + ms1.insert("bar"); + ms1.insert("bar"); + ms1.insert("bar"); + VERIFY( ms1.size() == 12 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + VERIFY( ms1.erase(ms1.begin()) != ms1.end() ); + VERIFY( ms1.size() == 11 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + auto it = ms1.begin(); + advance(it, 2); + VERIFY( ms1.erase(ms1.begin(), it) != ms1.end() ); + VERIFY( ms1.size() == 9 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + VERIFY( ms1.erase(*(ms1.begin())) == 3 ); + VERIFY( ms1.size() == 6 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); + + VERIFY( ms1.erase(ms1.begin(), ms1.end()) == ms1.end() ); + VERIFY( ms1.empty() ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( distance(ms1.begin(), ms1.end()) - ms1.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/24061-multiset.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/24061-multiset.cc new file mode 100644 index 000000000..e983c1705 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/24061-multiset.cc @@ -0,0 +1,127 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<std::string>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + { + nb += us.bucket_size(b); + } + return nb; + } +} + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Mset; + typedef Mset::iterator iterator; + typedef Mset::const_iterator const_iterator; + + Mset ms1; + + ms1.insert("all the love in the world"); + ms1.insert("you know what you are?"); + ms1.insert("the collector"); + ms1.insert("the hand that feeds"); + ms1.insert("love is not enough"); + ms1.insert("every day is exactly the same"); + ms1.insert("with teeth"); + ms1.insert("only"); + ms1.insert("getting smaller"); + ms1.insert("sunspots"); + + ms1.insert("the hand that feeds"); + ms1.insert("love is not enough"); + ms1.insert("every day is exactly the same"); + VERIFY( ms1.size() == 13 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + + iterator it1 = ms1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = ms1.erase(it1); + VERIFY( ms1.size() == 12 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = ms1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = ms1.erase(it4, it5); + VERIFY( ms1.size() == 10 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = ms1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = ms1.erase(it7); + VERIFY( ms1.size() == 9 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = ms1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = ms1.erase(it10, it11); + VERIFY( ms1.size() == 5 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + + iterator it13 = ms1.erase(ms1.begin(), ms1.end()); + VERIFY( ms1.size() == 0 ); + VERIFY( get_nb_bucket_elems(ms1) == ms1.size() ); + VERIFY( it13 == ms1.end() ); + VERIFY( it13 == ms1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc new file mode 100644 index 000000000..4c3b39d28 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +struct X_hash +{ std::size_t operator()(const X&) const { return 0; } }; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_multiset<X, X_hash>& s, X x) +{ + std::unordered_multiset<X, X_hash>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/final_hash.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/final_hash.cc new file mode 100644 index 000000000..79a3375e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/final_hash.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <unordered_set> + +namespace +{ + template<typename _Tp> + struct final_hash final + { + std::size_t operator() (const _Tp&) const noexcept + { return 0; } + }; +} + +// A non-integral type: +template class std::unordered_multiset<std::string, final_hash<std::string>>; + +// An integral type; +template class std::unordered_multiset<int, final_hash<int>>; + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/hash_policy/dr1189.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/hash_policy/dr1189.cc new file mode 100644 index 000000000..ce48e6705 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/hash_policy/dr1189.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +// DR 1189. Awkward interface for changing the number of buckets +// in an unordered associative container +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multiset<int> ms1; + ms1.reserve(10); + VERIFY( ms1.bucket_count() >= 10 ); + + ms1.reserve(100); + VERIFY( ms1.bucket_count() >= 100 ); + + std::unordered_multiset<int> ms2(100); + VERIFY( ms2.bucket_count() >= 100 ); + + ms2.reserve(1000); + VERIFY( ms2.bucket_count() >= 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc new file mode 100644 index 000000000..34cd33078 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_multiset<int> m({ 1, 5, 5, 37 }); + VERIFY(m.size() == 4); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 2); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 37, 37, 102 }; + VERIFY(m.size() == 5); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42, 42 }); + VERIFY(m.size() == 7); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 2); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/24061-multiset.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/24061-multiset.cc new file mode 100644 index 000000000..cdc7f87be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/24061-multiset.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Mset; + typedef Mset::iterator iterator; + typedef Mset::const_iterator const_iterator; + + Mset ms1; + + iterator it1 = ms1.insert(ms1.begin(), "all the love in the world"); + VERIFY( ms1.size() == 1 ); + VERIFY( *it1 == "all the love in the world" ); + + const_iterator cit1(it1); + const_iterator cit2 = ms1.insert(cit1, "you know what you are?"); + VERIFY( ms1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == "you know what you are?" ); + + iterator it2 = ms1.insert(it1, "all the love in the world"); + VERIFY( ms1.size() == 3 ); + VERIFY( it2 != it1 ); + VERIFY( *it2 == "all the love in the world" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/51866.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/51866.cc new file mode 100644 index 000000000..55905f305 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/51866.cc @@ -0,0 +1,87 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +struct num +{ + int value; + num(int n) : value(n) {} + num(num const&) = default; + num& operator=(num const&) = default; + num(num&& o) : value(o.value) + { o.value = -1; } + num& operator=(num&& o) + { + if (this != &o) + { + value = o.value; + o.value = -1; + } + return *this; + } +}; + +struct num_hash +{ + size_t operator()(num const& a) const + { return a.value; } +}; + +struct num_equal +{ + static bool _S_called_on_moved_instance; + bool operator()(num const& a, num const& b) const + { + if (a.value == -1 || b.value == -1) + _S_called_on_moved_instance = true; + return a.value == b.value; + } +}; + +bool num_equal::_S_called_on_moved_instance = false; + +// libstdc++/51866 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multiset<num, num_hash, num_equal> mset; + mset.insert(num(1)); + mset.insert(num(2)); + mset.insert(num(1)); + mset.insert(num(2)); + VERIFY( mset.size() == 4 ); + auto iter = mset.cbegin(); + int x0 = (iter++)->value; + int x1 = (iter++)->value; + int x2 = (iter++)->value; + int x3 = (iter++)->value; + VERIFY( iter == mset.cend() ); + VERIFY( (x0 == 1 && x1 == 1 && x2 == 2 && x3 == 2) + || (x0 == 2 && x1 == 2 && x2 == 1 && x3 == 1) ); + VERIFY( !num_equal::_S_called_on_moved_instance ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/52476.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/52476.cc new file mode 100644 index 000000000..ce9b5ca77 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/52476.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <vector> +#include <algorithm> +#include <testsuite_hooks.h> + +namespace +{ + struct pair_hash + { + std::size_t + operator()(const std::pair<int, int>& p) const noexcept + { return std::hash<int>()(p.first); } + }; + + struct pair_equal_to + { + bool + operator()(const std::pair<int, int>& x, + const std::pair<int, int>& y) const noexcept + { return x.first == y.first; } + }; +} + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + unordered_multiset<pair<int, int>, pair_hash, pair_equal_to> mset; + vector<int> values; + + size_t nb_bkts = mset.bucket_count(); + int i = 0; + for (;; ++i) + { + mset.insert(make_pair(0, i)); + if (mset.bucket_count() != nb_bkts) + // Container got rehash + break; + values.clear(); + transform(mset.begin(), mset.end(), back_inserter(values), + [](const pair<int, int>& p) { return p.second; }); + } + + vector<int> rehash_values; + transform(mset.begin(), mset.end(), back_inserter(rehash_values), + [](const pair<int, int>& p) { return p.second; }); + // Remove the value that result in a rehash + rehash_values.erase(remove(rehash_values.begin(), rehash_values.end(), i)); + + VERIFY( rehash_values == values ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/53115.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/53115.cc new file mode 100644 index 000000000..94f7f4952 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/53115.cc @@ -0,0 +1,101 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<int>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + std::unordered_multiset<int> mms; + mms.insert(10); + VERIFY( mms.size() == 1 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(10); + VERIFY( mms.size() == 2 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(10); + VERIFY( mms.size() == 3 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(10); + VERIFY( mms.size() == 4 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(10); + VERIFY( mms.size() == 5 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(24); + VERIFY( mms.size() == 6 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(25); + VERIFY( mms.size() == 7 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(2); + VERIFY( mms.size() == 8 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(2); + VERIFY( mms.size() == 9 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(1); + VERIFY( mms.size() == 10 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); + + mms.insert(10); + VERIFY( mms.size() == 11 ); + VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 ); + VERIFY( get_nb_bucket_elems(mms) == mms.size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/hash_policy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/hash_policy.cc new file mode 100644 index 000000000..5b70390e9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/hash_policy.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <limits> +#include <ext/throw_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::numeric_limits<size_t> nl_size_t; + std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, + __gnu_cxx::throw_allocator_limit<int> > us; + const int nb = 100; + int scheduled_throw_counter = 0; + std::size_t thrown_exceptions = 0; + for (int i = 0; i != nb; ++i) + { + if ((float)(us.size() + 1) + / (float)us.bucket_count() >= us.max_load_factor()) + { + // We are going to need a rehash, lets introduce allocation issues: + __gnu_cxx::limit_condition::set_limit(scheduled_throw_counter++); + } + try + { + us.insert(i / 2); + scheduled_throw_counter = 0; + } + catch (const __gnu_cxx::forced_error&) + { + ++thrown_exceptions; + --i; + } + VERIFY( us.load_factor() <= us.max_load_factor() ); + __gnu_cxx::limit_condition::set_limit(nl_size_t::max()); + } + + VERIFY( thrown_exceptions != 0 ); + // Check that all values have been inserted: + for (int i = 0; i != nb / 2; ++i) + { + VERIFY( us.count(i) == 2 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_range.cc new file mode 100644 index 000000000..d8cfa952c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_range.cc @@ -0,0 +1,95 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <string> +#include <iterator> +#include <algorithm> +#include <unordered_set> +#include <testsuite_hooks.h> + +namespace +{ + template <typename _Tp> + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<_Tp>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Set; + Set s; + VERIFY(s.empty()); + + const int N = 10; + const std::string A[N] = { "red", "green", "blue", "violet", "cyan", + "magenta", "yellow", "orange", "pink", "gray" }; + + s.insert(A + 0, A + N); + VERIFY( s.size() == static_cast<unsigned int>(N) ); + VERIFY( std::distance(s.begin(), s.end()) - N == 0 ); + VERIFY( get_nb_bucket_elems(s) - N == 0 ); + + for (int i = 0; i < N; ++i) + { + std::string str = A[i]; + Set::iterator it = std::find(s.begin(), s.end(), str); + VERIFY(it != s.end()); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<int> Set; + Set s; + VERIFY(s.empty()); + + const int N = 8; + const int A[N] = { 3, 7, 4, 8, 2, 4, 6, 7 }; + + s.insert(A+0, A+N); + VERIFY( s.size() == static_cast<unsigned int>(N) ); + VERIFY( std::distance(s.begin(), s.end()) - N == 0 ); + VERIFY( get_nb_bucket_elems(s) - N == 0 ); + + VERIFY( std::count(s.begin(), s.end(), 2) == 1 ); + VERIFY( std::count(s.begin(), s.end(), 3) == 1 ); + VERIFY( std::count(s.begin(), s.end(), 4) == 2 ); + VERIFY( std::count(s.begin(), s.end(), 6) == 1 ); + VERIFY( std::count(s.begin(), s.end(), 7) == 2 ); + VERIFY( std::count(s.begin(), s.end(), 8) == 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single.cc new file mode 100644 index 000000000..25cbd94e8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <string> +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<std::string>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Set; + Set s; + VERIFY(s.empty()); + + Set::iterator i = s.insert("abcde"); + VERIFY( s.size() == 1 ); + VERIFY( get_nb_bucket_elems(s) == 1 ); + VERIFY(std::distance(s.begin(), s.end()) == 1); + VERIFY(i == s.begin()); + VERIFY(*i == "abcde"); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_multiset<std::string> Set; + Set s; + VERIFY(s.empty()); + + s.insert("abcde"); + Set::iterator i = s.insert("abcde"); + VERIFY(s.size() == 2); + VERIFY( get_nb_bucket_elems(s) == 2 ); + VERIFY(std::distance(s.begin(), s.end()) == 2); + VERIFY(*i == "abcde"); + + Set::iterator i2 = s.begin(); + ++i2; + VERIFY(i == s.begin() || i == i2); + VERIFY(*(s.begin()) == "abcde" && *i2 == "abcde"); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single_move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single_move.cc new file mode 100644 index 000000000..fe6f0c505 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/insert/multiset_single_move.cc @@ -0,0 +1,86 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +namespace +{ + template <typename _Tp> + std::size_t + get_nb_bucket_elems(const std::unordered_multiset<_Tp>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator i = s.insert(rvalstruct(1)); + VERIFY( s.size() == 1 ); + VERIFY( get_nb_bucket_elems(s) == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( i == s.begin() ); + VERIFY( (*i).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_multiset<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + s.insert(rvalstruct(2)); + Set::iterator i = s.insert(rvalstruct(2)); + VERIFY( s.size() == 2 ); + VERIFY( get_nb_bucket_elems(s) == 2 ); + VERIFY( std::distance(s.begin(), s.end()) == 2 ); + VERIFY( (*i).val == 2 ); + + Set::iterator i2 = s.begin(); + ++i2; + VERIFY( i == s.begin() || i == i2 ); + VERIFY( (*(s.begin())).val == 2 && (*i2).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/emplace.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/emplace.cc new file mode 100644 index 000000000..619e4ddf7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/emplace.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <vector> +#include <unordered_set> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +struct PathPointHasher +{ + std::size_t operator() (const PathPoint& __pp) const + { return __pp.getType(); } +}; + +struct PathPointEqual +{ + bool operator() (const PathPoint& __lhs, const PathPoint& __rhs) const + { return __lhs.getType() == __rhs.getType(); } +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_multiset<PathPoint, PathPointHasher, + PathPointEqual> Mset; + Mset ms; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto it = ms.emplace('a', coord1); + VERIFY( ms.size() == 1 ); + VERIFY( it->getType() == 'a' ); + + coord1[0] = 3.0; + it = ms.emplace('a', coord1); + VERIFY( ms.size() == 2 ); + VERIFY( it->getType() == 'a' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + it = ms.emplace_hint(ms.begin(), 'b', coord1); + VERIFY( it != ms.end() ); + VERIFY( it->getType() == 'b' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + it = ms.emplace('c', std::move(coord1)); + VERIFY( ms.size() == 4 ); + VERIFY( it->getType() == 'c' ); + VERIFY( &(it->getCoords()[0]) == px ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/reserve.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/reserve.cc new file mode 100644 index 000000000..50a0c0aa0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/reserve.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + const int N = 1000; + + typedef std::unordered_multiset<int> MSet; + MSet s; + s.reserve(N * 2); + + std::size_t bkts = s.bucket_count(); + for (int i = 0; i != N; ++i) + { + s.insert(i); + s.insert(i); + // As long as we insert less than the reserved number of elements we + // shouldn't experiment any rehash. + VERIFY( s.bucket_count() == bkts ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/observers.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/observers.cc new file mode 100644 index 000000000..bb8f8418b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/observers.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +void +test01() +{ + std::unordered_multiset<int> us; + + auto ke __attribute__((unused)) = us.key_eq(); + auto h __attribute__((unused)) = us.hash_function(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc new file mode 100644 index 000000000..80bd3d967 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + unordered_multiset<int> ums0; + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 0 ); + + ums0.insert(1); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 1 ); + + ums0.insert(1); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 2 ); + + ums0.insert(2); + VERIFY( ums0.count(2) == 1 ); + + ums0.insert(3); + ums0.insert(3); + ums0.insert(3); + VERIFY( ums0.count(3) == 3 ); + + ums0.erase(2); + VERIFY( ums0.count(2) == 0 ); + + ums0.erase(0); + VERIFY( ums0.count(0) == 0 ); + + unordered_multiset<int> ums1(ums0); + VERIFY( ums1.count(0) == 0 ); + VERIFY( ums1.count(1) == 2 ); + VERIFY( ums1.count(2) == 0 ); + VERIFY( ums1.count(3) == 3 ); + + ums0.clear(); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 0 ); + VERIFY( ums0.count(2) == 0 ); + VERIFY( ums0.count(3) == 0 ); + + ums1.insert(4); + ums1.insert(5); + ums1.insert(5); + ums1.insert(5); + ums1.insert(5); + VERIFY( ums1.count(4) == 1 ); + VERIFY( ums1.count(5) == 4 ); + + ums1.erase(1); + VERIFY( ums1.count(1) == 0 ); + + ums1.erase(ums1.find(5)); + VERIFY( ums1.count(5) == 3 ); + + ums1.insert(1); + ums1.insert(1); + VERIFY( ums1.count(1) == 2 ); + + ums1.erase(5); + VERIFY( ums1.count(5) == 0 ); + + ums1.erase(ums1.find(4)); + VERIFY( ums1.count(4) == 0 ); + + ums1.clear(); + VERIFY( ums1.count(0) == 0 ); + VERIFY( ums1.count(1) == 0 ); + VERIFY( ums1.count(2) == 0 ); + VERIFY( ums1.count(3) == 0 ); + VERIFY( ums1.count(4) == 0 ); + VERIFY( ums1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc new file mode 100644 index 000000000..fb9553e54 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multiset<int> ums1, ums2; + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(2); + ums2.insert(2); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(3); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums2.insert(3); + VERIFY( (ums1 == ums2) ); + VERIFY( !(ums1 != ums2) ); + + ums2.clear(); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.clear(); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(2); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.insert(2); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(3); + ums2.insert(4); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.insert(4); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums2.insert(3); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(4); + ums2.insert(4); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + const std::unordered_multiset<int> cums1(ums1), cums2(ums2); + VERIFY( cums1 == cums2 ); + VERIFY( !(cums1 != cums2) ); + VERIFY( cums1 == ums2 ); + VERIFY( !(ums1 != cums2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc new file mode 100644 index 000000000..6b42c42e4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <unordered_set> + +void +test01() +{ + std::unordered_multiset<int> ums{1, 2, 3}; + std::begin(ums); + std::end(ums); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/citerators.cc new file mode 100644 index 000000000..bfe644add --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_multiset<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/cliterators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/cliterators.cc new file mode 100644 index 000000000..19b855140 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/cliterators.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_multiset<int> test_type; + typedef typename test_type::value_type value_type; + value_type v(1); + __gnu_test::forward_members_unordered<test_type> test(v); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/debug.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/debug.cc new file mode 100644 index 000000000..bc3544119 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/debug.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <debug/unordered_set> + +using namespace __gnu_debug; + +template class unordered_multiset<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/basic.cc new file mode 100644 index 000000000..929eb91a5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multiset<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..5521ab566 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multiset<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..2bd7ea788 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_multiset<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..c1592ffef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +template class std::unordered_multiset<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..21b4d6873 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::NonDefaultConstructible inst_type; +typedef __gnu_test::NonDefaultConstructible_hash hash_type; +template class std::unordered_multiset<inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..2a81347ee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +using namespace std; +template class unordered_multiset<int, hash<int>, equal_to<int>, allocator<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..779471ab2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::OverloadedAddress inst_type; +typedef __gnu_test::OverloadedAddress_hash hash_type; + +// libstdc++/41792 +template class std::unordered_multiset<inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..0f1eb2ee0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/5.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/typedefs.cc new file mode 100644 index 000000000..56898f7ee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <unordered_set> + +// Check container for required typedefs. +__gnu_test::types<std::unordered_multiset<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/55043.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/55043.cc new file mode 100644 index 000000000..74900508d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/55043.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/55043 + +#include <unordered_set> +#include <vector> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; +}; + +struct equal +{ + bool + operator()(const MoveOnly&, const MoveOnly&) const + { return true; } +}; + +struct hash +{ + std::size_t + operator()(const MoveOnly&) const + { return 0; } +}; + +template<typename Alloc> + using test_type = std::unordered_set<MoveOnly, hash, equal, Alloc>; + +void test01() +{ + typedef test_type<std::allocator<MoveOnly>> uim; + std::vector<uim> v; + v.emplace_back(uim()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc new file mode 100644 index 000000000..cae451a53 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <unordered_set> + +struct audrey2hash : std::hash<int> +{ + audrey2hash() { throw "Seed me, Seymour"; } // must not use default ctor + + audrey2hash(int) { } + + audrey2hash& + operator=(const audrey2hash&) { throw "Don't assign the plants"; } +}; + +void test01() +{ + typedef std::unordered_set<int, audrey2hash> test_type; + test_type::local_iterator it __attribute__((unused)); + test_type c{ {1, 2, 3}, 3u, audrey2hash{1} }; + it = c.begin(0); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267.cc new file mode 100644 index 000000000..4939168db --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56267.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/56267 + +#include <unordered_set> + +struct hash : std::hash<int> +{ + hash& operator=(const hash&) = delete; +}; + +int main() +{ + std::unordered_set<int, hash> s{ 0, 1, 2 }; + auto i = s.begin(0); + i = i; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc new file mode 100644 index 000000000..b22c8992a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// libstdc++/56278 + +#include <unordered_set> + +struct hash : std::hash<int> +{ + hash() { } +}; + +std::unordered_set<int, hash>::local_iterator i; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy.cc new file mode 100644 index 000000000..335560f25 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy_assign.cc new file mode 100644 index 000000000..4418f3364 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/copy_assign.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc new file mode 100644 index 000000000..7bf1c9fb7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <unordered_set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; +bool operator==(const T& l, const T& r) { return l.i == r.i; } +struct H { std::size_t operator()(const T& t) const noexcept { return t.i; } +}; +struct E : std::equal_to<T> { }; + +using __gnu_test::CustomPointerAlloc; + +template class std::unordered_set<T, H, E, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::unordered_set<T, H, E, alloc_type> test_type; + test_type v; + v.insert(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/minimal.cc new file mode 100644 index 000000000..cd349db50 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/minimal.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + + +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::SimpleAllocator; + +template class std::unordered_set<T, hash, equal_to, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v(alloc_type{}); + v.insert(T()); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move.cc new file mode 100644 index 000000000..d24df7452 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc new file mode 100644 index 000000000..321be0084 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> +#include <testsuite_counter_type.h> + +using __gnu_test::propagating_allocator; +using __gnu_test::counter_type; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, false> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_set<counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(0); + + test_type v2(alloc_type(2)); + v2.emplace(1); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY( 1 == v1.get_allocator().get_personality() ); + VERIFY( 2 == v2.get_allocator().get_personality() ); + + VERIFY( counter_type::move_count == 1 ); + VERIFY( counter_type::destructor_count == 2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<counter_type, true> alloc_type; + typedef __gnu_test::counter_type_hasher hash; + typedef std::unordered_set<counter_type, hash, + std::equal_to<counter_type>, + alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1.emplace(0); + + test_type v2(alloc_type(2)); + v2.emplace(0); + + counter_type::reset(); + + v2 = std::move(v1); + + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); + + VERIFY( counter_type::move_count == 0 ); + VERIFY( counter_type::copy_count == 0 ); + VERIFY( counter_type::destructor_count == 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc new file mode 100644 index 000000000..68787810f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/swap.cc new file mode 100644 index 000000000..1ddbcd7ea --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/swap.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=c++11" } + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +struct hash +{ + std::size_t operator()(const T t) const noexcept + { return t.i; } +}; + +struct equal_to +{ + bool operator()(const T& lhs, const T& rhs) const noexcept + { return lhs.i == rhs.i; } +}; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.insert(T()); + test_type v2(alloc_type(2)); + v2.insert(T()); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/buckets/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/buckets/swap.cc new file mode 100644 index 000000000..6aea63ae2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/buckets/swap.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=c++11" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <unordered_set> + +namespace +{ + struct hash + { + hash() = default; + hash(int modulo) + : _M_modulo(modulo) + { } + + std::size_t operator() (int val) const noexcept + { return val % _M_modulo; } + + int _M_modulo; + }; +} + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // static_assert(std::__cache_default<int, hash>::value, + // "Unexpected default cache value"); + typedef std::unordered_set<int, hash> us_t; + us_t us1(10, hash(13)); + us_t us2(10, hash(7)); + + VERIFY( us1.hash_function()._M_modulo == 13 ); + VERIFY( us2.hash_function()._M_modulo == 7 ); + + const int nb = 5; + for (int i = 0; i != nb * us1.hash_function()._M_modulo; ++i) + us1.insert(i); + + us_t::local_iterator lit = us1.begin(12); + us_t::local_iterator litend = us1.end(12); + VERIFY( std::distance(lit, litend) == nb ); + + us1.swap(us2); + + VERIFY( us1.hash_function()._M_modulo == 7 ); + VERIFY( us2.hash_function()._M_modulo == 13 ); + + VERIFY( std::distance(lit, litend) == nb ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc new file mode 100644 index 000000000..62bfd3e77 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on set (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> a,b; + a.insert(2); + b.insert(1); + b = std::move(a); + VERIFY( b.find(2) != b.end() && a.find(1) == a.end() ); + + std::unordered_set<int> c(std::move(b)); + VERIFY( c.find(2) != c.end() ); + VERIFY( b.find(2) == b.end() ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc new file mode 100644 index 000000000..a9c71a529 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <unordered_set> + +std::unordered_set<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc new file mode 100644 index 000000000..a66991439 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.begin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc new file mode 100644 index 000000000..b12159d2a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + const std::unordered_set<int>& cus = us; + cus.begin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc new file mode 100644 index 000000000..1e7d5fae9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.bucket_size(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc new file mode 100644 index 000000000..683df64b3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.cbegin(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc new file mode 100644 index 000000000..d5fb47c9a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.cend(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc new file mode 100644 index 000000000..aa90f8695 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc new file mode 100644 index 000000000..7ac40fe21 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc new file mode 100644 index 000000000..8c5d180be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc new file mode 100644 index 000000000..17bf10033 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/debug_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/debug_functions.cc new file mode 100644 index 000000000..471d730a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/debug_functions.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_debug; + + std::unordered_set<int> u = { 0, 1, 2 }; + VERIFY( __check_dereferenceable(u.begin()) ); + auto it = u.begin(); + VERIFY( __check_dereferenceable(it) ); + + VERIFY( __check_dereferenceable(u.cbegin()) ); + auto cit = u.begin(); + VERIFY( __check_dereferenceable(cit) ); + + VERIFY( !__check_dereferenceable(u.end()) ); + it = u.end(); + VERIFY( !__check_dereferenceable(it) ); + + auto bucket = u.bucket(0); + VERIFY( __check_dereferenceable(u.begin(bucket)) ); + auto lit = u.begin(bucket); + VERIFY( __check_dereferenceable(lit) ); + + VERIFY( !__check_dereferenceable(u.end(bucket)) ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_debug; + + std::unordered_set<int> u = { 0, 1, 2 }; + + VERIFY( !__check_singular(u.end()) ); + auto it = u.end(); + VERIFY( !__check_singular(it) ); + + VERIFY( !__check_singular(u.begin()) ); + it = u.begin(); + VERIFY( !__check_singular(it) ); + + u.clear(); + + VERIFY( it._M_singular() ); + VERIFY( __check_singular(it) ); + + it = u.end(); + VERIFY( !it._M_singular() ); + VERIFY( !__check_singular(it) ); + + u = { 0, 1, 2 }; + + auto bucket = u.bucket(0); + VERIFY( !__check_singular(u.begin(bucket)) ); + auto lit = u.begin(bucket); + VERIFY( !__check_singular(lit) ); + + VERIFY( !__check_singular(u.end(bucket)) ); + + u.clear(); + VERIFY( __check_singular(lit) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc new file mode 100644 index 000000000..52c696e3e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.end(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc new file mode 100644 index 000000000..71fbdae97 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + const std::unordered_set<int>& cus = us; + cus.end(us.bucket_count()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc new file mode 100644 index 000000000..5adb9d61f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc new file mode 100644 index 000000000..5b8d3596a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc new file mode 100644 index 000000000..57c659276 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc new file mode 100644 index 000000000..fb1d3099f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc new file mode 100644 index 000000000..1b221cded --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_compare<std::unordered_set<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc new file mode 100644 index 000000000..6498316df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::invalid_local_iterator_range<std::unordered_set<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..471913669 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us1; + auto it1 = us1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc new file mode 100644 index 000000000..fed2c58f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=c++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us; + us.max_load_factor(-1.0f); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..11b2cd0a7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> + +void test01() +{ + std::unordered_set<int> us1; + us1 = std::move(us1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc new file mode 100644 index 000000000..061f2ead0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_erased_local_iterator<std::unordered_set<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc new file mode 100644 index 000000000..2f9521e19 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::use_invalid_iterator<std::unordered_set<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc new file mode 100644 index 000000000..39cc7f3b6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/unordered_checks.h> + +void test01() +{ + __gnu_test::use_invalid_local_iterator<std::unordered_set<int>>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc new file mode 100644 index 000000000..35fe7819f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc @@ -0,0 +1,164 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +namespace +{ + std::size_t + get_nb_bucket_elems(const std::unordered_set<std::string>& us) + { + std::size_t nb = 0; + for (std::size_t b = 0; b != us.bucket_count(); ++b) + nb += us.bucket_size(b); + return nb; + } +} + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + s1.insert("because to why"); + s1.insert("the stockholm syndrome"); + s1.insert("a cereous night"); + s1.insert("eeilo"); + s1.insert("protean"); + s1.insert("the way you are when"); + s1.insert("tillsammans"); + s1.insert("umbra/penumbra"); + s1.insert("belonging (no longer mix)"); + s1.insert("one line behind"); + VERIFY( s1.size() == 10 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + + VERIFY( s1.erase("eeilo") == 1 ); + VERIFY( s1.size() == 9 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + iterator it1 = s1.find("eeilo"); + VERIFY( it1 == s1.end() ); + + VERIFY( s1.erase("tillsammans") == 1 ); + VERIFY( s1.size() == 8 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + iterator it2 = s1.find("tillsammans"); + VERIFY( it2 == s1.end() ); + + // Must work (see DR 526) + iterator it3 = s1.find("belonging (no longer mix)"); + VERIFY( it3 != s1.end() ); + VERIFY( s1.erase(*it3) == 1 ); + VERIFY( s1.size() == 7 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + it3 = s1.find("belonging (no longer mix)"); + VERIFY( it3 == s1.end() ); + + VERIFY( !s1.erase("abra") ); + VERIFY( s1.size() == 7 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + + VERIFY( !s1.erase("eeilo") ); + VERIFY( s1.size() == 7 ); + + VERIFY( s1.erase("because to why") == 1 ); + VERIFY( s1.size() == 6 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + iterator it4 = s1.find("because to why"); + VERIFY( it4 == s1.end() ); + + iterator it5 = s1.find("umbra/penumbra"); + iterator it6 = s1.find("one line behind"); + VERIFY( it5 != s1.end() ); + VERIFY( it6 != s1.end() ); + + VERIFY( s1.find("the stockholm syndrome") != s1.end() ); + VERIFY( s1.find("a cereous night") != s1.end() ); + VERIFY( s1.find("the way you are when") != s1.end() ); + VERIFY( s1.find("a cereous night") != s1.end() ); + + VERIFY( s1.erase(*it5) == 1 ); + VERIFY( s1.size() == 5 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + it5 = s1.find("umbra/penumbra"); + VERIFY( it5 == s1.end() ); + + VERIFY( s1.erase(*it6) == 1 ); + VERIFY( s1.size() == 4 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + it6 = s1.find("one line behind"); + VERIFY( it6 == s1.end() ); + + iterator it7 = s1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( s1.erase(*it8) == 1 ); + VERIFY( s1.size() == 3 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( s1.erase(*it9) == 1 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + VERIFY( s1.size() == 2 ); + VERIFY( ++it10 == s1.end() ); + + VERIFY( s1.erase(s1.begin()) != s1.end() ); + VERIFY( s1.size() == 1 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + VERIFY( s1.begin() == it11 ); + + VERIFY( s1.erase(*s1.begin()) == 1 ); + VERIFY( s1.size() == 0 ); + VERIFY( get_nb_bucket_elems(s1) == s1.size() ); + VERIFY( distance(s1.begin(), s1.end()) - s1.size() == 0 ); + VERIFY( s1.begin() == s1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc new file mode 100644 index 000000000..91c069c85 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc @@ -0,0 +1,104 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + s1.insert("all the love in the world"); + s1.insert("you know what you are?"); + s1.insert("the collector"); + s1.insert("the hand that feeds"); + s1.insert("love is not enough"); + s1.insert("every day is exactly the same"); + s1.insert("with teeth"); + s1.insert("only"); + s1.insert("getting smaller"); + s1.insert("sunspots"); + VERIFY( s1.size() == 10 ); + + iterator it1 = s1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = s1.erase(it1); + VERIFY( s1.size() == 9 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = s1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = s1.erase(it4, it5); + VERIFY( s1.size() == 7 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = s1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = s1.erase(it7); + VERIFY( s1.size() == 6 ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = s1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = s1.erase(it10, it11); + VERIFY( s1.size() == 2 ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + VERIFY( ++it12 == s1.end() ); + + iterator it13 = s1.erase(s1.begin(), s1.end()); + VERIFY( s1.size() == 0 ); + VERIFY( it13 == s1.end() ); + VERIFY( it13 == s1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc new file mode 100644 index 000000000..25691f394 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +struct X_hash +{ std::size_t operator()(const X&) const { return 0; } }; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_set<X, X_hash>& s, X x) +{ + std::unordered_set<X, X_hash>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/final_hash.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/final_hash.cc new file mode 100644 index 000000000..2af9ae436 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/final_hash.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <string> +#include <unordered_set> + +namespace +{ + template<typename _Tp> + struct final_hash final + { + std::size_t operator() (const _Tp&) const noexcept + { return 0; } + }; +} + +// A non-integral type: +template class std::unordered_set<std::string, final_hash<std::string>>; + +// An integral type; +template class std::unordered_set<int, final_hash<int>>; + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc new file mode 100644 index 000000000..de545dd17 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-08-13 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +// libstdc++/26132 +void test01() +{ + bool test __attribute__((unused)) = true; + + for (float lf = 1.0; lf < 101.0; lf *= 10.0) + for (int size = 1; size <= 6561; size *= 3) + { + std::unordered_set<int> us1; + typedef std::unordered_set<int>::size_type size_type; + + us1.max_load_factor(10.0); + + for (int i = 0; i < size; ++i) + us1.insert(i); + + us1.max_load_factor(lf); + + for (int i = 1; i <= 6561; i *= 81) + { + const size_type n = size * 81 / i; + us1.rehash(n); + VERIFY( us1.bucket_count() > us1.size() / us1.max_load_factor() ); + VERIFY( us1.bucket_count() >= n ); + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc new file mode 100644 index 000000000..6ae8fdb6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +// DR 1189. Awkward interface for changing the number of buckets +// in an unordered associative container +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> s1; + s1.reserve(10); + VERIFY( s1.bucket_count() >= 10 ); + + s1.reserve(100); + VERIFY( s1.bucket_count() >= 100 ); + + std::unordered_set<int> s2(100); + VERIFY( s2.bucket_count() >= 100 ); + + s2.reserve(1000); + VERIFY( s2.bucket_count() >= 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc new file mode 100644 index 000000000..9c535d196 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + { + std::unordered_set<int> us; + for (int i = 0; i != 100000; ++i) + { + us.insert(i); + VERIFY( us.load_factor() <= us.max_load_factor() ); + } + } + { + std::unordered_set<int> us; + us.max_load_factor(3.f); + for (int i = 0; i != 100000; ++i) + { + us.insert(i); + VERIFY( us.load_factor() <= us.max_load_factor() ); + } + } + { + std::unordered_set<int> us; + us.max_load_factor(.3f); + for (int i = 0; i != 100000; ++i) + { + us.insert(i); + VERIFY( us.load_factor() <= us.max_load_factor() ); + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc new file mode 100644 index 000000000..8768f35be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/rehash.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + std::unordered_set<int> us; + typedef typename std::unordered_set<int>::size_type size_type; + bool rehashed = false; + for (int i = 0; i != 100000; ++i) + { + size_type bkt_count = us.bucket_count(); + us.insert(i); + if (bkt_count != us.bucket_count()) + { + // Container has been rehashed, lets check that it won't be rehash again + // if we remove and restore the last 2 inserted elements: + rehashed = true; + bkt_count = us.bucket_count(); + VERIFY( us.erase(i) == 1 ); + VERIFY( bkt_count == us.bucket_count() ); + if (i > 0) + { + VERIFY( us.erase(i - 1) == 1 ); + VERIFY( bkt_count == us.bucket_count() ); + + VERIFY( us.insert(i - 1).second ); + VERIFY( bkt_count == us.bucket_count() ); + } + VERIFY( us.insert(i).second ); + VERIFY( bkt_count == us.bucket_count() ); + } + } + + // At lest we check a rehash once: + VERIFY( rehashed ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc new file mode 100644 index 000000000..48b1a9b2e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_set<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42 }); + VERIFY(m.size() == 4); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 1); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc new file mode 100644 index 000000000..ea12db008 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + iterator it1 = s1.insert(s1.begin(), "all the love in the world"); + VERIFY( s1.size() == 1 ); + VERIFY( *it1 == "all the love in the world" ); + + const_iterator cit1(it1); + const_iterator cit2 = s1.insert(cit1, "you know what you are?"); + VERIFY( s1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == "you know what you are?" ); + + iterator it2 = s1.insert(it1, "all the love in the world"); + VERIFY( s1.size() == 2 ); + VERIFY( it2 == it1 ); + VERIFY( *it2 == "all the love in the world" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/hash_policy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/hash_policy.cc new file mode 100644 index 000000000..c84783b6d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/hash_policy.cc @@ -0,0 +1,113 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <vector> +#include <limits> +#include <ext/throw_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::numeric_limits<std::size_t> nl_size_t; + std::unordered_set<int, std::hash<int>, std::equal_to<int>, + __gnu_cxx::throw_allocator_limit<int> > us; + const int nb = 100; + int scheduled_throw_counter = 0; + std::size_t thrown_exceptions = 0; + for (int i = 0; i != nb; ++i) + { + if ((float)(us.size() + 1) + / (float)us.bucket_count() >= us.max_load_factor()) + { + // We are going to need a rehash, lets introduce allocation issues: + __gnu_cxx::limit_condition::set_limit(scheduled_throw_counter++); + } + try + { + VERIFY(us.insert(i).second); + scheduled_throw_counter = 0; + } + catch (const __gnu_cxx::forced_error&) + { + ++thrown_exceptions; + --i; + } + VERIFY( us.load_factor() <= us.max_load_factor() ); + __gnu_cxx::limit_condition::set_limit(nl_size_t::max()); + } + + VERIFY( thrown_exceptions != 0 ); + // Check that all values have been inserted: + for (int i = 0; i != nb; ++i) + { + VERIFY( us.count(i) == 1 ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::numeric_limits<std::size_t> nl_size_t; + std::unordered_set<int, std::hash<int>, std::equal_to<int>, + __gnu_cxx::throw_allocator_limit<int> > us; + const int nb = 100; + int scheduled_throw_counter = 0; + std::size_t thrown_exceptions = 0; + for (int i = 0; i != nb; ++i) + { + if ((float)(us.size() + 2) + / (float)us.bucket_count() >= us.max_load_factor()) + { + // We are going to need a rehash, lets introduce allocation issues: + __gnu_cxx::limit_condition::set_limit(scheduled_throw_counter++); + } + try + { + std::vector<int> v = { i, i }; + // Check the insert range robustness + us.insert(v.begin(), v.end()); + scheduled_throw_counter = 0; + } + catch (const __gnu_cxx::forced_error&) + { + ++thrown_exceptions; + --i; + } + VERIFY( us.load_factor() <= us.max_load_factor() ); + __gnu_cxx::limit_condition::set_limit(nl_size_t::max()); + } + + VERIFY( thrown_exceptions != 0 ); + // Check that all values have been inserted: + for (int i = 0; i != nb; ++i) + { + VERIFY( us.count(i) == 1 ); + } +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/move_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/move_range.cc new file mode 100644 index 000000000..ba4000ba1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/move_range.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert using move iterator + +#include <iterator> +#include <vector> +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_counter_type.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + using namespace __gnu_test; + + std::vector<counter_type> ref = { 0, 1, 2, 3, 4, 5 }; + typedef std::unordered_set<counter_type, counter_type_hasher> Set; + Set s; + + counter_type::reset(); + + s.insert(std::make_move_iterator(ref.begin()), + std::make_move_iterator(ref.end())); + + VERIFY( s.size() == ref.size() ); + VERIFY( counter_type::move_count == ref.size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc new file mode 100644 index 000000000..36d4d3283 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <string> +#include <iterator> +#include <algorithm> +#include <unordered_set> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + const int N = 10; + const std::string A[N] = { "red", "green", "blue", "violet", "cyan", + "magenta", "yellow", "orange", "pink", "gray" }; + + s.insert(A+0, A+N); + VERIFY(s.size() == static_cast<unsigned int>(N)); + VERIFY(std::distance(s.begin(), s.end()) == N); + + for (int i = 0; i < N; ++i) { + std::string str = A[i]; + Set::iterator it = std::find(s.begin(), s.end(), str); + VERIFY(it != s.end()); + } +} + +void test02() +{ + typedef std::unordered_set<int> Set; + Set s; + VERIFY(s.empty()); + + const int N = 8; + const int A[N] = { 3, 7, 4, 8, 2, 4, 6, 7 }; + + s.insert(A+0, A+N); + VERIFY(s.size() == 6); + VERIFY(std::distance(s.begin(), s.end()) == 6); + + VERIFY(std::count(s.begin(), s.end(), 2) == 1); + VERIFY(std::count(s.begin(), s.end(), 3) == 1); + VERIFY(std::count(s.begin(), s.end(), 4) == 1); + VERIFY(std::count(s.begin(), s.end(), 6) == 1); + VERIFY(std::count(s.begin(), s.end(), 7) == 1); + VERIFY(std::count(s.begin(), s.end(), 8) == 1); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc new file mode 100644 index 000000000..aa01f303e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <string> +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + std::pair<Set::iterator, bool> p = s.insert("abcde"); + VERIFY(p.second); + VERIFY(s.size() == 1); + VERIFY(std::distance(s.begin(), s.end()) == 1); + VERIFY(p.first == s.begin()); + VERIFY(*p.first == "abcde"); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + std::pair<Set::iterator, bool> p1 = s.insert("abcde"); + std::pair<Set::iterator, bool> p2 = s.insert("abcde"); + VERIFY(p1.second); + VERIFY(!p2.second); + VERIFY(s.size() == 1); + VERIFY(p1.first == p2.first); + VERIFY(*p1.first == "abcde"); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc new file mode 100644 index 000000000..a54662ecc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// Single-element insert + +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p = s.insert(rvalstruct(1)); + VERIFY( p.second ); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( p.first == s.begin() ); + VERIFY( (*p.first).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p1 = s.insert(rvalstruct(2)); + std::pair<Set::iterator, bool> p2 = s.insert(rvalstruct(2)); + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( s.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (*p1.first).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc new file mode 100644 index 000000000..30784f85f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-normal-mode "" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-error "with noexcept" "" { target *-*-* } 266 } + +#include <unordered_set> + +namespace +{ + struct hash_without_noexcept + { + std::size_t operator() (int) const + { return 0; } + }; +} + +void +test01() +{ + using traits = std::__detail::_Hashtable_traits<false, true, true>; + using hashtable = std::__uset_hashtable<int, hash_without_noexcept, + std::equal_to<int>, + std::allocator<int>, traits>; + + hashtable ht; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc new file mode 100644 index 000000000..7654e56a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <limits> +#include <ext/throw_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::numeric_limits<std::size_t> nl_size_t; + std::unordered_set<int, std::hash<int>, std::equal_to<int>, + __gnu_cxx::throw_allocator_limit<int> > us; + int val = 0; + for (; val != 100; ++val) + { + VERIFY( us.insert(val).second) ; + VERIFY( us.load_factor() <= us.max_load_factor() ); + } + + float cur_max_load_factor = us.max_load_factor(); + int counter = 0; + std::size_t thrown_exceptions = 0; + while (true) + { + __gnu_cxx::limit_condition::set_limit(counter++); + bool do_break = false; + try + { + us.max_load_factor(.5f); + do_break = true; + } + catch (const __gnu_cxx::forced_error&) + { + VERIFY( us.max_load_factor() == cur_max_load_factor ); + ++thrown_exceptions; + } + // Lets check that unordered_set will still be correctly resized + // when needed + __gnu_cxx::limit_condition::set_limit(nl_size_t::max()); + for (;;) + { + VERIFY( us.load_factor() <= us.max_load_factor() ); + size_t nbkts = us.bucket_count(); + VERIFY( us.insert(val++).second ); + if (us.bucket_count() != nbkts) + break; + } + if (do_break) + break; + } + VERIFY( thrown_exceptions > 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/emplace.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/emplace.cc new file mode 100644 index 000000000..6cc69d4ba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/emplace.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// range insert + +#include <vector> +#include <unordered_set> +#include <testsuite_hooks.h> + +class PathPoint +{ +public: + PathPoint(char t, const std::vector<double>& c) + : type(t), coords(c) { } + PathPoint(char t, std::vector<double>&& c) + : type(t), coords(std::move(c)) { } + char getType() const { return type; } + const std::vector<double>& getCoords() const { return coords; } +private: + char type; + std::vector<double> coords; +}; + +struct PathPointHasher +{ + std::size_t operator() (const PathPoint& __pp) const + { return __pp.getType(); } +}; + +struct PathPointEqual +{ + bool operator() (const PathPoint& __lhs, const PathPoint& __rhs) const + { return __lhs.getType() == __rhs.getType(); } +}; + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_set<PathPoint, PathPointHasher, PathPointEqual> Set; + Set s; + + std::vector<double> coord1 = { 0.0, 1.0, 2.0 }; + + auto ret = s.emplace('a', coord1); + VERIFY( ret.second ); + VERIFY( s.size() == 1 ); + VERIFY( ret.first->getType() == 'a' ); + + coord1[0] = 3.0; + ret = s.emplace('a', coord1); + VERIFY( !ret.second ); + VERIFY( s.size() == 1 ); + VERIFY( ret.first->getType() == 'a' ); + VERIFY( ret.first->getCoords()[0] == 0.0 ); + + auto it = s.emplace_hint(s.begin(), 'b', coord1); + VERIFY( it != s.end() ); + VERIFY( it->getType() == 'b' ); + VERIFY( it->getCoords()[0] == 3.0 ); + + double *px = &coord1[0]; + ret = s.emplace('c', std::move(coord1)); + VERIFY( ret.second ); + VERIFY( ret.first->getType() == 'c' ); + VERIFY( &(ret.first->getCoords()[0]) == px ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/reserve.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/reserve.cc new file mode 100644 index 000000000..9cb796166 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/reserve.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + const int N = 1000; + + typedef std::unordered_set<int> Set; + Set s; + s.reserve(N); + + std::size_t bkts = s.bucket_count(); + for (int i = 0; i != N; ++i) + { + s.insert(i); + // As long as we insert less than the reserved number of elements we + // shouldn't experiment any rehash. + VERIFY( s.bucket_count() == bkts ); + } +} + +void test02() +{ + const int N = 1000; + + typedef std::unordered_set<int> Set; + Set s; + s.reserve(N); + s.reserve(N); + + std::size_t bkts = s.bucket_count(); + for (int i = 0; i != N; ++i) + { + s.insert(i); + // As long as we insert less than the reserved number of elements we + // shouldn't experiment any rehash. + VERIFY( s.bucket_count() == bkts ); + } +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/observers.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/observers.cc new file mode 100644 index 000000000..aca6e0e2f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/observers.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +void +test01() +{ + std::unordered_set<int> us; + + auto ke __attribute__((unused)) = us.key_eq(); + auto h __attribute__((unused)) = us.hash_function(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc new file mode 100644 index 000000000..dbea77ed6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + unordered_set<int> us0; + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 0 ); + + us0.insert(1); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 1 ); + + us0.insert(1); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 1 ); + + us0.insert(2); + VERIFY( us0.count(2) == 1 ); + + us0.insert(3); + us0.insert(3); + us0.insert(3); + VERIFY( us0.count(3) == 1 ); + + us0.erase(2); + VERIFY( us0.count(2) == 0 ); + + us0.erase(0); + VERIFY( us0.count(0) == 0 ); + + unordered_set<int> us1(us0); + VERIFY( us1.count(0) == 0 ); + VERIFY( us1.count(1) == 1 ); + VERIFY( us1.count(2) == 0 ); + VERIFY( us1.count(3) == 1 ); + + us0.clear(); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 0 ); + VERIFY( us0.count(2) == 0 ); + VERIFY( us0.count(3) == 0 ); + + us1.insert(4); + us1.insert(5); + us1.insert(5); + us1.insert(5); + us1.insert(5); + VERIFY( us1.count(4) == 1 ); + VERIFY( us1.count(5) == 1 ); + + us1.erase(1); + VERIFY( us1.count(1) == 0 ); + + us1.erase(us1.find(5)); + VERIFY( us1.count(5) == 0 ); + + us1.insert(1); + us1.insert(1); + VERIFY( us1.count(1) == 1 ); + + us1.erase(5); + VERIFY( us1.count(5) == 0 ); + + us1.erase(us1.find(4)); + VERIFY( us1.count(4) == 0 ); + + us1.clear(); + VERIFY( us1.count(0) == 0 ); + VERIFY( us1.count(1) == 0 ); + VERIFY( us1.count(2) == 0 ); + VERIFY( us1.count(3) == 0 ); + VERIFY( us1.count(4) == 0 ); + VERIFY( us1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc new file mode 100644 index 000000000..d2801ed2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> us1, us2; + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(2); + us2.insert(2); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( (us1 == us2) ); + VERIFY( !(us1 != us2) ); + + us2.clear(); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.clear(); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(2); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(2); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + us2.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(4); + us2.insert(4); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + const std::unordered_set<int> cus1(us1), cus2(us2); + VERIFY( cus1 == cus2 ); + VERIFY( !(cus1 != cus2) ); + VERIFY( cus1 == us2 ); + VERIFY( !(us1 != cus2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc new file mode 100644 index 000000000..657e550e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +// libstdc++/52309 +struct value {}; +struct hash { std::size_t operator()(const value&) const; }; +bool operator==(value const&, value const&); +std::unordered_set<value, hash> set; +bool z = (set == set); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc new file mode 100644 index 000000000..f7bb300d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <unordered_set> + +void +test01() +{ + std::unordered_set<int> us{1, 2, 3}; + std::begin(us); + std::end(us); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc new file mode 100644 index 000000000..97b6edc53 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/52942.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <functional> + +struct TFoo {}; + +struct TFoo_hash +{ + std::size_t operator()(const TFoo &) const { return 0; } +}; + +void f1(std::unordered_set<TFoo, TFoo_hash> &) {} + +void f2() +{ + std::unordered_set<TFoo, TFoo_hash> set1; + std::bind(f1, std::ref(set1)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/53067.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/53067.cc new file mode 100644 index 000000000..00d8e7d8f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/53067.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <functional> + +void f() +{ + std::unordered_set<int> Foo; + ref(Foo); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc new file mode 100644 index 000000000..a01080553 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_set<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc new file mode 100644 index 000000000..31463477d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_set<int> test_type; + typedef typename test_type::value_type value_type; + value_type v(1); + __gnu_test::forward_members_unordered<test_type> test(v); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc new file mode 100644 index 000000000..948c66266 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/unordered_set> + +using namespace __gnu_debug; + +template class unordered_set<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc new file mode 100644 index 000000000..956f3d092 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc @@ -0,0 +1,30 @@ +// NB: This issue affected only debug-mode. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +//PR libstdc++/35922 +int main() +{ + std::unordered_set<int> s; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc new file mode 100644 index 000000000..85f955f2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..c6464cfd4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..42d75c20b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..77eae96a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +template class std::unordered_set<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..791400b67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::NonDefaultConstructible inst_type; +typedef __gnu_test::NonDefaultConstructible_hash hash_type; +template class std::unordered_set<inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..5cdcb3e31 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +using namespace std; +template class unordered_set<int, hash<int>, equal_to<int>, allocator<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..b5088c7ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::OverloadedAddress inst_type; +typedef __gnu_test::OverloadedAddress_hash hash_type; + +// libstdc++/41792 +template class std::unordered_set<inst_type, hash_type>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc new file mode 100644 index 000000000..ce8d550de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/5.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_allocator.h> + +// { dg-do compile } + +// libstdc++/50118 +template class std::unordered_set<int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<int>>; +template class std::unordered_set<int, std::hash<int>, std::equal_to<int>, + __gnu_test::ExplicitConsAlloc<char>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc new file mode 100644 index 000000000..9ced75b94 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <unordered_set> + +// Check container for required typedefs. +__gnu_test::types<std::unordered_set<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/14340.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/14340.cc new file mode 100644 index 000000000..9fac86ae1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/14340.cc @@ -0,0 +1,33 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <vector> + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::vector<int> container; + __gnu_test::conversion<container>::iterator_to_const_iterator(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/15523.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/15523.cc new file mode 100644 index 000000000..664118426 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/15523.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// NB: This issue affected only debug-mode. + +#include <vector> + +// libstdc++/15523 +void test01() +{ + using namespace std; + + vector<vector<int>::const_iterator> x(2); + + vector<int>::iterator i2, i3; + vector<int>::const_iterator ci1(i2); + + i2 = i3; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/18604.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/18604.cc new file mode 100644 index 000000000..137115b63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/18604.cc @@ -0,0 +1,41 @@ +// 2005-05-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 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 <vector> diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-1.cc new file mode 100644 index 000000000..70c830b52 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-1.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// -*- C++ -*- + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> + +// libstdc++26412 +namespace debug +{ + int i; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-2.cc new file mode 100644 index 000000000..cb63fd304 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/26412-2.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// -*- C++ -*- + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + + +#define debug 0 + +#include <debug/vector> + +// libstdc++26412 diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/40192.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/40192.cc new file mode 100644 index 000000000..5085cf95f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/40192.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +// libstdc++/40192 + +#include <vector> + +void test01() +{ + typedef float float4[4]; + std::vector<float4> vals; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/52591.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/52591.cc new file mode 100644 index 000000000..81a86c5c3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/52591.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// libstdc++/52591 + +#include <vector> + +// As an extension we allow move-assignment of std::vector when the element +// type is not MoveAssignable, as long as the allocator type propagates or +// is known to always compare equal. + +struct C +{ + C& operator=(C&&) = delete; +}; + +void test01() +{ + std::vector<C> a; + a = std::vector<C>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/58764.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/58764.cc new file mode 100644 index 000000000..6a9823c71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/58764.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/58764 + +#include <vector> + +void test01() +{ + std::vector<int> a = {}; + std::vector<bool> b = {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/59829.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/59829.cc new file mode 100644 index 000000000..1818c8941 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/59829.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/59829 + +#include <vector> +#include <testsuite_allocator.h> + +// User-defined pointer type that throws if a null pointer is dereferenced. +template<typename T> +struct Pointer : __gnu_test::PointerBase<Pointer<T>, T> +{ + using __gnu_test::PointerBase<Pointer<T>, T>::PointerBase; + + T& operator*() const + { + if (!this->value) + throw "Dereferenced invalid pointer"; + return *this->value; + } +}; + +// Minimal allocator using Pointer<T> +template<typename T> +struct Alloc +{ + typedef T value_type; + typedef Pointer<T> pointer; + + Alloc() = default; + template<typename U> + Alloc(const Alloc<U>&) { } + + pointer allocate(std::size_t n) + { return pointer(std::allocator<T>().allocate(n)); } + + void deallocate(pointer p, std::size_t n) + { std::allocator<T>().deallocate(p.value, n); } +}; + +template<typename T> +bool operator==(Alloc<T> l, Alloc<T> r) { return true; } + +template<typename T> +bool operator!=(Alloc<T> l, Alloc<T> r) { return false; } + +int main() +{ + std::vector<int, Alloc<int>> a; + a.data(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy.cc new file mode 100644 index 000000000..92a6b56a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(0 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(v1, alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy_assign.cc new file mode 100644 index 000000000..f66c07b6a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/copy_assign.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(alloc_type(2)); + v2.push_back(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(alloc_type(2)); + v2.push_back(T()); + v2 = v1; + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc new file mode 100644 index 000000000..23848ba13 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <vector> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::CustomPointerAlloc; + +template class std::vector<T, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v; + v.push_back(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/minimal.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/minimal.cc new file mode 100644 index 000000000..cdeef4a49 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/minimal.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::SimpleAllocator; + +template class std::vector<T, SimpleAllocator<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef SimpleAllocator<T> alloc_type; + typedef std::allocator_traits<alloc_type> traits_type; + typedef std::vector<T, alloc_type> test_type; + test_type v(alloc_type{}); + v.push_back(T()); + VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move.cc new file mode 100644 index 000000000..c6f90d86e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::uneq_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { T() }; + auto it = v1.begin(); + test_type v2(std::move(v1)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); + VERIFY( it == v2.begin() ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef uneq_allocator<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1 = { T() }; + test_type v2(std::move(v1), alloc_type(2)); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc new file mode 100644 index 000000000..88c5ad0f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(alloc_type(2)); + v2.push_back(T()); + v2 = std::move(v1); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + auto it = v1.begin(); + test_type v2(alloc_type(2)); + v2.push_back(T()); + v2 = std::move(v1); + VERIFY( it == v2.begin() ); + VERIFY(0 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + auto it = v1.begin(); + test_type v2(alloc_type(1)); + v2.push_back(T()); + v2 = std::move(v1); + VERIFY( it == v2.begin() ); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc new file mode 100644 index 000000000..af9cd7334 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_allocator.h> + +struct T { int i; }; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc new file mode 100644 index 000000000..e1036fed7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::propagating_allocator; + +// It is undefined behaviour to swap() containers wth unequal allocators +// if the allocator doesn't propagate, so ensure the allocators compare +// equal, while still being able to test propagation via get_personality(). +bool +operator==(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return true; +} + +bool +operator!=(const propagating_allocator<T, false>&, + const propagating_allocator<T, false>&) +{ + return false; +} + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(alloc_type(2)); + v2.push_back(T()); + std::swap(v1, v2); + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + // swap back so assertions in uneq_allocator::deallocate don't fail + std::swap(v1, v2); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + v1.push_back(T()); + test_type v2(alloc_type(2)); + v2.push_back(T()); + std::swap(v1, v2); + VERIFY(2 == v1.get_allocator().get_personality()); + VERIFY(1 == v2.get_allocator().get_personality()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc new file mode 100644 index 000000000..d13bf2115 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/1.cc @@ -0,0 +1,36 @@ +// 2002-03-05 Stephen M. Webb <stephen.webb@bregmasoft.com> + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 class vector<bool> + +#include <vector> +#include <testsuite_hooks.h> + +void test01() +{ + std::vector<bool>::iterator i; + if (false) + ++i; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc new file mode 100644 index 000000000..1cb73b5b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/21244.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +// { dg-do compile } + +class Foo +{ +}; + +template<class T> Foo operator/(const Foo& arg1, T arg2) +{ + return Foo(); +} + +// libstdc++/21244 +void foo() +{ + std::vector<bool> bar(1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc new file mode 100644 index 000000000..f2406b188 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <vector> + +// libstdc++/23632 +void test01() +{ + std::vector<bool> v(100); + const std::vector<bool>::iterator fu = v.begin(); + if (!fu[0]) + fu[0] = true; + + const std::vector<bool>::const_iterator cfu = v.begin(); + if (cfu[0]) + ; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc new file mode 100644 index 000000000..5fccd3148 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/6886.cc @@ -0,0 +1,53 @@ +// 2002-03-05 Stephen M. Webb <stephen.webb@bregmasoft.com> + +// Copyright (C) 2002-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 class vector<bool> + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/6886 +void test02() +{ + bool test __attribute__((unused)) = true; + typedef std::vector<bool> bvec; + int i, num = 0; + bvec v; + + v.resize(66); + + for (i = 0 ; i < 66 ; ++i) + v[i] = 0; + + v[1] = 1; + v[33] = 1; + v[49] = 1; + v[65] = 1; + + for (bvec::iterator j = v.begin() ; j != v.end() ; j++) + if (bool(*j)) ++num; + + VERIFY( num == 4 ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc new file mode 100644 index 000000000..b0cc1f915 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc @@ -0,0 +1,137 @@ +// 2006-08-05 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool> resize + +#include <vector> +#include <testsuite_hooks.h> + +const bool A1[] = {0}; +const bool A2[] = {0, 0, 0}; +const bool A3[] = {0, 0}; +const bool A4[] = {0, 0, 1, 1, 1, 1, 1}; +const bool A5[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const bool A6[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1}; +const bool A7[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}; +const bool A8[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +const bool A9[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const bool A10[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1}; +const bool A11[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); +const unsigned N10 = sizeof(A10) / sizeof(bool); +const unsigned N11 = sizeof(A11) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<bool> vec_type; + + vec_type v; + + v.resize(1); + VERIFY( v.size() == 1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + v.resize(3); + VERIFY( v.size() == 3 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + v.resize(2); + VERIFY( v.size() == 2 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + v.resize(7, true); + VERIFY( v.size() == 7 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + v.resize(18, false); + VERIFY( v.size() == 18 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + v.resize(40, true); + VERIFY( v.size() == 40 ); + VERIFY( std::equal(v.begin(), v.end(), A6) ); + + v.resize(80, false); + VERIFY( v.size() == 80 ); + VERIFY( std::equal(v.begin(), v.end(), A7) ); + + v.resize(90, true); + VERIFY( v.size() == 90 ); + VERIFY( std::equal(v.begin(), v.end(), A8) ); + + v.resize(100, false); + VERIFY( v.size() == 100 ); + VERIFY( std::equal(v.begin(), v.end(), A9) ); + + v.resize(200, true); + VERIFY( v.size() == 200 ); + VERIFY( std::equal(v.begin(), v.end(), A10) ); + + v.resize(13, true); + VERIFY( v.size() == 13 ); + VERIFY( std::equal(v.begin(), v.end(), A11) ); + + v.resize(13, false); + VERIFY( v.size() == 13 ); + VERIFY( std::equal(v.begin(), v.end(), A11) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc new file mode 100644 index 000000000..a55da3630 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/29134.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 class vector<bool> [lib.vector.bool] + +#include <vector> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::vector; + using std::numeric_limits; + +#ifdef _GLIBCXX_DEBUG + using std::_GLIBCXX_STD_C::_S_word_bit; +#elif defined(_GLIBCXX_PROFILE) + using std::_GLIBCXX_STD_C::_S_word_bit; +#else + using std::_S_word_bit; +#endif + + // Actually, vector<bool> is special, see libstdc++/31370. + vector<bool> vb; + typedef vector<bool>::difference_type difference_type; + typedef vector<bool>::size_type size_type; + VERIFY( vb.max_size() + == size_type(numeric_limits<difference_type>::max() + - int(_S_word_bit) + 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/shrink_to_fit.cc new file mode 100644 index 000000000..98f0bb7b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/shrink_to_fit.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<bool> vb(__CHAR_BIT__ * sizeof(unsigned long) + 1); + vb.pop_back(); + + auto old_capacity = vb.capacity(); + vb.shrink_to_fit(); + VERIFY( vb.capacity() < old_capacity ); + VERIFY( vb.size() == vb.capacity() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc new file mode 100644 index 000000000..7d0b5a03c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/clear_allocator.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator<T>() + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + 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<std::vector<bool, clear_alloc<bool> > >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc new file mode 100644 index 000000000..67cf0c57d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc @@ -0,0 +1,178 @@ +// 2006-08-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool> copy construct + +#include <vector> +#include <testsuite_hooks.h> + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 1, 1}; +const bool A2[] = {1, 0, 1, 1, 1, 1, 1}; +const bool A3[] = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A4[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1}; +const bool A5[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1}; +const bool A6[] = {1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A7[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0}; +const bool A8[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; +const bool A9[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<bool> vec_type; + + const vec_type v1_ref(A1, A1 + N1); + vec_type v1(v1_ref); + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + vec_type v2(v2_ref); + VERIFY( v2.size() == v2_ref.size() ); + VERIFY( std::equal(v2.begin(), v2.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + vec_type v3(v3_ref); + VERIFY( v3.size() == v3_ref.size() ); + VERIFY( std::equal(v3.begin(), v3.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + vec_type v4(v4_ref); + VERIFY( v4.size() == v4_ref.size() ); + VERIFY( std::equal(v4.begin(), v4.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + vec_type v5(v5_ref); + VERIFY( v5.size() == v5_ref.size() ); + VERIFY( std::equal(v5.begin(), v5.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + vec_type v6(v6_ref); + VERIFY( v6.size() == v6_ref.size() ); + VERIFY( std::equal(v6.begin(), v6.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + vec_type v7(v7_ref); + VERIFY( v7.size() == v7_ref.size() ); + VERIFY( std::equal(v7.begin(), v7.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + vec_type v8(v8_ref); + VERIFY( v8.size() == v8_ref.size() ); + VERIFY( std::equal(v8.begin(), v8.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + vec_type v9(v9_ref); + VERIFY( v9.size() == v9_ref.size() ); + VERIFY( std::equal(v9.begin(), v9.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc new file mode 100644 index 000000000..62d1f3ea8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc @@ -0,0 +1,180 @@ +// 2006-08-09 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool> assignment operator + +#include <vector> +#include <testsuite_hooks.h> + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 1, 1}; +const bool A2[] = {1, 0, 1, 1, 1, 1, 1}; +const bool A3[] = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A4[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1}; +const bool A5[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1}; +const bool A6[] = {1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A7[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0}; +const bool A8[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; +const bool A9[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<bool> vec_type; + + vec_type v1; + + const vec_type v1_ref(A1, A1 + N1); + v1 = v1_ref; + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + v1 = v2_ref; + VERIFY( v1.size() == v2_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + v1 = v3_ref; + VERIFY( v1.size() == v3_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + v1 = v4_ref; + VERIFY( v1.size() == v4_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + v1 = v5_ref; + VERIFY( v1.size() == v5_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + v1 = v6_ref; + VERIFY( v1.size() == v6_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + v1 = v7_ref; + VERIFY( v1.size() == v7_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + v1 = v8_ref; + VERIFY( v1.size() == v8_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + v1 = v9_ref; + VERIFY( v1.size() == v9_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..fcc131a51 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +typedef std::vector<bool> vbtype; + +static_assert(std::is_nothrow_move_constructible<vbtype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/emplace.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/emplace.cc new file mode 100644 index 000000000..7d1f21c7c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/emplace.cc @@ -0,0 +1,51 @@ +// { dg-options " -std=gnu++11 " } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.3.8 class vector<bool> + +#include <vector> +#include <testsuite_hooks.h> + +void test01() +{ + std::vector<bool> v; + v.emplace_back(); + VERIFY( v[0] == false ); + v.emplace_back(1); + VERIFY( v[1] == true ); + VERIFY( v.size() == 2 ); +} + +void test02() +{ + std::vector<bool> v; + auto it = v.emplace(v.cbegin()); + VERIFY( it == v.begin() ); + VERIFY( *it == false ); + it = v.emplace(it, 1); + VERIFY( it == v.begin() ); + VERIFY( *it == true ); + VERIFY( v.size() == 2 ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc new file mode 100644 index 000000000..b4e4f2e10 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/hash/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<bool> b0; + std::hash<std::vector<bool>> h0; + h0(b0); + + std::vector<bool> b1(10); + std::hash<std::vector<bool>> h1; + h1(b1); + + std::vector<bool> b2(100); + std::hash<std::vector<bool>> h2; + h2(b2); + + std::vector<bool> b3(1000); + std::hash<std::vector<bool>> h3; + h3(b3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc new file mode 100644 index 000000000..e11e4ea8f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/1.cc @@ -0,0 +1,136 @@ +// 2005-12-23 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool> modifiers + +#include <vector> +#include <testsuite_hooks.h> + +const bool A[] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; +const bool A1[] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; +const bool A2[] = {0, 0, 1, 0, 0, 1, 0, 1, 0, 1}; +const bool A3[] = {0, 0, 1, 0, 0, 1}; +const bool A4[] = {0, 0, 1}; +const bool A5[] = {0, 0}; + +const unsigned N = sizeof(A) / sizeof(bool); +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<bool> vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v(A, A + N); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<std::vector<bool> > vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v, v1, v2, v3, v4, v5; + for (unsigned i = 0; i < N; ++i) + v.push_back(std::vector<bool>(1, A[i])); + for (unsigned i = 0; i < N1; ++i) + v1.push_back(std::vector<bool>(1, A1[i])); + for (unsigned i = 0; i < N2; ++i) + v2.push_back(std::vector<bool>(1, A2[i])); + for (unsigned i = 0; i < N3; ++i) + v3.push_back(std::vector<bool>(1, A3[i])); + for (unsigned i = 0; i < N4; ++i) + v4.push_back(std::vector<bool>(1, A4[i])); + for (unsigned i = 0; i < N5; ++i) + v5.push_back(std::vector<bool>(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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/54577.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/54577.cc new file mode 100644 index 000000000..e60284f33 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/erase/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<bool> vb1; + vb1.push_back(true); + vb1.erase(vb1.cbegin()); + + std::vector<bool> vb2; + vb2.push_back(false); + vb2.push_back(true); + vb2.erase(vb2.cbegin(), vb2.cend()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc new file mode 100644 index 000000000..76f31d431 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/1.cc @@ -0,0 +1,171 @@ +// 2006-08-05 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool> insert + +#include <vector> +#include <testsuite_hooks.h> + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1}; +const bool A2[] = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A3[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1}; +const bool A4[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1}; +const bool A5[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; +const bool A6[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1}; +const bool A7[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0}; +const bool A8[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; +const bool A9[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<bool> vec_type; + + vec_type v; + + v.insert(v.begin(), 7, true); + VERIFY( v.size() == 7 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + v.insert(v.begin() + 5, 10, false); + VERIFY( v.size() == 17 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + v.insert(v.begin(), 20, false); + VERIFY( v.size() == 37 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + v.insert(v.begin(), 40, true); + VERIFY( v.size() == 77 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + v.insert(v.begin() + 18, 80, false); + VERIFY( v.size() == 157 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + v.insert(v.begin() + 54, 80, true); + VERIFY( v.size() == 237 ); + VERIFY( std::equal(v.begin(), v.end(), A6) ); + + v.insert(v.end(), 1, false); + VERIFY( v.size() == 238 ); + VERIFY( std::equal(v.begin(), v.end(), A7) ); + + v.insert(v.begin(), 1, false); + VERIFY( v.size() == 239 ); + VERIFY( std::equal(v.begin(), v.end(), A8) ); + + v.insert(v.begin(), 180, true); + VERIFY( v.size() == 419 ); + VERIFY( std::equal(v.begin(), v.end(), A9) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc new file mode 100644 index 000000000..57594563a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc @@ -0,0 +1,200 @@ +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 class vector<bool> [lib.vector.bool] + +// { dg-skip-if "" { powerpc64-*-freebsd* } { "*" } { "" } } +// { dg-do run { xfail *-*-darwin8.[0-4].* } } + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> + +#ifdef _GLIBCXX_DEBUG + using std::_GLIBCXX_STD_C::_S_word_bit; +#elif defined(_GLIBCXX_PROFILE) + using std::_GLIBCXX_STD_C::_S_word_bit; +#else + using std::_S_word_bit; +#endif + +inline void +check_cap_ge_size(const std::vector<bool>& x) +{ + if (x.capacity() < x.size()) + throw std::logic_error(""); +} + +inline void +check_cap_eq_maxsize(const std::vector<bool>& x) +{ + if (x.capacity() != x.max_size()) + throw std::logic_error(""); +} + +// libstdc++/31370 +void test01() +{ + bool test __attribute__((unused)) = true; + int myexit = 0; + + try + { + std::vector<bool> x; + x.reserve(x.max_size()); + check_cap_eq_maxsize(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // When doubling is too big, but smaller is sufficient, the resize + // should do smaller and be happy. It certainly shouldn't throw + // other exceptions or crash. + try + { + std::vector<bool> x; + x.resize(x.max_size() / 2 + 1, false); + for(int i = 0; i < _S_word_bit; ++i) + x.push_back(false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() / 2 + 1, false); + x.insert(x.end(), _S_word_bit, false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() / 2 + 1, false); + std::vector<bool> y(_S_word_bit, false); + x.insert(x.end(), y.begin(), y.end()); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // These tests are currently only relevant to bool: don't get burned + // by the attempt to round up when near the max size. + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + for(int i = 0; i < _S_word_bit; ++i) + x.push_back(false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + x.insert(x.end(), _S_word_bit, false); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + std::vector<bool> y(_S_word_bit, false); + x.insert(x.end(), y.begin(), y.end()); + check_cap_ge_size(x); + } + catch(std::bad_alloc&) + { } + catch(std::exception&) + { ++myexit; } + + // Attempts to put in more than max_size() items should result in a + // length error. + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + for(int i = 0; i < _S_word_bit + 1; ++i) + x.push_back(false); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + x.insert(x.end(), _S_word_bit + 1, false); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + try + { + std::vector<bool> x; + x.resize(x.max_size() - _S_word_bit, false); + std::vector<bool> y(_S_word_bit + 1, false); + x.insert(x.end(), y.begin(), y.end()); + ++myexit; + } + catch(std::bad_alloc) + { } + catch(std::length_error) + { } + catch(std::exception) + { ++myexit; } + + VERIFY( !myexit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc new file mode 100644 index 000000000..79469bb90 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<bool> vb1, vb2{true, false}; + std::vector<bool>::iterator it = vb1.insert(vb1.cbegin(), true); + it = vb1.insert(vb1.cbegin(), {false, true}); + it = vb1.insert(vb1.cbegin(), 1, false); + it = vb1.insert(vb1.cbegin(), vb2.begin(), vb2.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc new file mode 100644 index 000000000..c0d45f65c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/1.cc @@ -0,0 +1,145 @@ +// 2005-12-23 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool>::swap + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<bool> my_alloc; + typedef vector<bool, my_alloc> my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + vector<bool> vec01_ref; + for (size_t i = 0; i < N1; ++i) + vec01_ref.push_back(bool(title01[i] > 96 ? 1 : 0)); + vector<bool> vec02_ref; + for (size_t i = 0; i < N2; ++i) + vec02_ref.push_back(bool(title02[i] > 96 ? 1 : 0)); + vector<bool> vec03_ref; + for (size_t i = 0; i < N3; ++i) + vec03_ref.push_back(bool(title03[i] > 96 ? 1 : 0)); + vector<bool> vec04_ref; + for (size_t i = 0; i < N4; ++i) + vec04_ref.push_back(bool(title04[i] > 96 ? 1 : 0)); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1); + + my_vector vec01(alloc01); + size01 = vec01.size(); + my_vector vec02(alloc01); + size02 = vec02.size(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + + my_vector vec03(alloc01); + size01 = vec03.size(); + my_vector vec04(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec04.size(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), vec02_ref.begin()) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + + my_vector vec05(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec05.size(); + my_vector vec06(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec06.size(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), vec02_ref.begin()) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), vec01_ref.begin()) ); + + my_vector vec07(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec07.size(); + my_vector vec08(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec08.size(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), vec03_ref.begin()) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), vec01_ref.begin()) ); + + my_vector vec09(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec09.size(); + my_vector vec10(vec04_ref.begin(), vec04_ref.end(), alloc01); + size02 = vec10.size(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), vec04_ref.begin()) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), vec03_ref.begin()) ); + + my_vector vec11(vec04_ref.begin(), vec04_ref.end(), alloc01); + size01 = vec11.size(); + my_vector vec12(vec01_ref.begin(), vec01_ref.end(), alloc01); + size02 = vec12.size(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), vec01_ref.begin()) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), vec04_ref.begin()) ); + + my_vector vec13(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec13.size(); + my_vector vec14(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec14.size(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), vec03_ref.begin()) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), vec03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc new file mode 100644 index 000000000..c63f8de5f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/swap/2.cc @@ -0,0 +1,174 @@ +// 2005-12-23 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.5 vector<bool>::swap + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<bool> my_alloc; + typedef vector<bool, my_alloc> my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + vector<bool> vec01_ref; + for (size_t i = 0; i < N1; ++i) + vec01_ref.push_back(bool(title01[i] > 96 ? 1 : 0)); + vector<bool> vec02_ref; + for (size_t i = 0; i < N2; ++i) + vec02_ref.push_back(bool(title02[i] > 96 ? 1 : 0)); + vector<bool> vec03_ref; + for (size_t i = 0; i < N3; ++i) + vec03_ref.push_back(bool(title03[i] > 96 ? 1 : 0)); + vector<bool> vec04_ref; + for (size_t i = 0; i < N4; ++i) + vec04_ref.push_back(bool(title04[i] > 96 ? 1 : 0)); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_vector vec01(alloc01); + size01 = vec01.size(); + personality01 = vec01.get_allocator().get_personality(); + my_vector vec02(alloc02); + size02 = vec02.size(); + personality02 = vec02.get_allocator().get_personality(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + VERIFY( vec01.get_allocator().get_personality() == personality02 ); + VERIFY( vec02.get_allocator().get_personality() == personality01 ); + + my_vector vec03(alloc02); + size01 = vec03.size(); + personality01 = vec03.get_allocator().get_personality(); + my_vector vec04(vec02_ref.begin(), vec02_ref.end(), alloc01); + size02 = vec04.size(); + personality02 = vec04.get_allocator().get_personality(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), vec02_ref.begin()) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + VERIFY( vec03.get_allocator().get_personality() == personality02 ); + VERIFY( vec04.get_allocator().get_personality() == personality01 ); + + my_vector vec05(vec01_ref.begin(), vec01_ref.end(), alloc01); + size01 = vec05.size(); + personality01 = vec05.get_allocator().get_personality(); + my_vector vec06(vec02_ref.begin(), vec02_ref.end(), alloc02); + size02 = vec06.size(); + personality02 = vec06.get_allocator().get_personality(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), vec02_ref.begin()) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), vec01_ref.begin()) ); + VERIFY( vec05.get_allocator().get_personality() == personality02 ); + VERIFY( vec06.get_allocator().get_personality() == personality01 ); + + my_vector vec07(vec01_ref.begin(), vec01_ref.end(), alloc02); + size01 = vec07.size(); + personality01 = vec07.get_allocator().get_personality(); + my_vector vec08(vec03_ref.begin(), vec03_ref.end(), alloc01); + size02 = vec08.size(); + personality02 = vec08.get_allocator().get_personality(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), vec03_ref.begin()) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), vec01_ref.begin()) ); + VERIFY( vec07.get_allocator().get_personality() == personality02 ); + VERIFY( vec08.get_allocator().get_personality() == personality01 ); + + my_vector vec09(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec09.size(); + personality01 = vec09.get_allocator().get_personality(); + my_vector vec10(vec04_ref.begin(), vec04_ref.end(), alloc02); + size02 = vec10.size(); + personality02 = vec10.get_allocator().get_personality(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), vec04_ref.begin()) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), vec03_ref.begin()) ); + VERIFY( vec09.get_allocator().get_personality() == personality02 ); + VERIFY( vec10.get_allocator().get_personality() == personality01 ); + + my_vector vec11(vec04_ref.begin(), vec04_ref.end(), alloc02); + size01 = vec11.size(); + personality01 = vec11.get_allocator().get_personality(); + my_vector vec12(vec01_ref.begin(), vec01_ref.end(), alloc01); + size02 = vec12.size(); + personality02 = vec12.get_allocator().get_personality(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), vec01_ref.begin()) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), vec04_ref.begin()) ); + VERIFY( vec11.get_allocator().get_personality() == personality02 ); + VERIFY( vec12.get_allocator().get_personality() == personality01 ); + + my_vector vec13(vec03_ref.begin(), vec03_ref.end(), alloc01); + size01 = vec13.size(); + personality01 = vec13.get_allocator().get_personality(); + my_vector vec14(vec03_ref.begin(), vec03_ref.end(), alloc02); + size02 = vec14.size(); + personality02 = vec14.get_allocator().get_personality(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), vec03_ref.begin()) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), vec03_ref.begin()) ); + VERIFY( vec13.get_allocator().get_personality() == personality02 ); + VERIFY( vec14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc new file mode 100644 index 000000000..566a922f8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_containers.h> + +int main() +{ + typedef std::vector<bool> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc new file mode 100644 index 000000000..f0818df65 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <vector> + +void f() +{ + std::vector<bool> vb(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/swap.cc new file mode 100644 index 000000000..6dafe649c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/bool/swap.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +template<class Cont> + void + my_reverse(Cont& c) + { + for (std::size_t i = 0, j = c.size(); i < j; ++i) + { + --j; + using std::swap; + swap(c[i], c[j]); + } + } + +template<class Cont> + void + my_compare(const Cont& c1, const Cont& c2) + { + bool test __attribute__((unused)) = true; + + VERIFY( c1.size() == c2.size() ); + + for (std::size_t i = 0; i < c1.size(); ++i) + VERIFY( c1[i] == c2[c1.size() - i - 1] ); + } + +void test01() +{ + const std::vector<bool> vb_ref{0, 1, 1, 0, 1}; + std::vector<bool> vb(vb_ref); + my_reverse(vb); + my_compare(vb_ref, vb); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc new file mode 100644 index 000000000..240d73686 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/1.cc @@ -0,0 +1,60 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity + +#include <vector> +#include <stdexcept> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +template<typename T> + struct A { }; + +struct B { }; + +void test01() +{ + // non POD types + bool test __attribute__((unused)) = true; + std::vector< A<B> > vec01; + typedef std::vector< A<B> >::size_type size_type; + + size_type sz01 = vec01.capacity(); + vec01.reserve(100); + size_type sz02 = vec01.capacity(); + VERIFY( sz02 >= sz01 ); + + sz01 = vec01.size() + 5; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY( sz01 == sz02 ); + + sz01 = vec01.size() - 5; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY( sz01 == sz02 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc new file mode 100644 index 000000000..5256b54d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc @@ -0,0 +1,102 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity + +#include <vector> +#include <stdexcept> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +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::destructor; + +// Verifies basic functionality of reserve() with forced reallocation. +void +test_reserve() +{ + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(3); + const X::size_type old_size = a.size(); + const X::size_type old_capacity = a.capacity(); + const X::size_type new_capacity = old_capacity + 10; + T::reset(); + + a.reserve(new_capacity); + + // [23.2.4.1 (2)] + VERIFY(new_capacity <= a.capacity()); + // [23.2.4.1 (3)] + VERIFY(old_size == a.size()); + VERIFY(copy_constructor::count() <= old_size); + VERIFY(destructor::count() <= old_size); + } + // check for memory leaks + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); +} + +// Verifies that reserve() with reallocation offers the strong +// exception guarantee. +void +test_reserve_exception_guarantee() +{ + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + const X::size_type old_size __attribute__((unused)) = a.size(); + const X::size_type old_capacity = a.capacity(); + const X::size_type new_capacity = old_capacity + 10; + T::reset(); + copy_constructor::throw_on(3); + + try + { + a.reserve(new_capacity); + VERIFY(false); + } + catch (...) + { + } + + VERIFY(old_capacity == a.capacity()); + VERIFY(copy_constructor::count() == destructor::count()+1); + } + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); +} + +int main() +{ + test_reserve(); + test_reserve_exception_guarantee(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc new file mode 100644 index 000000000..78e964406 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity [lib.vector.capacity] + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + vector<int> v; + + try + { + v.resize(size_t(-1)); + } + catch(const std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc new file mode 100644 index 000000000..828142a54 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2006-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity [lib.vector.capacity] + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> v; + + VERIFY( v.max_size() == v.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/44190.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/44190.cc new file mode 100644 index 000000000..31c06a775 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/44190.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/44190 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> v; + v.resize(10); + VERIFY( v.size() <= v.capacity() ); +} + +int main() +{ + + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc new file mode 100644 index 000000000..072b03169 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/8230.cc @@ -0,0 +1,77 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity + +#include <vector> +#include <stdexcept> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +// libstdc++/8230 +void test02() +{ + bool test __attribute__((unused)) = true; + { + std::vector<int> array; + const std::size_t size = array.max_size(); + try + { + array.reserve(size); + } + catch (const std::length_error& error) + { + test &= false; + } + catch (const std::bad_alloc& error) + { + test &= true; + } + catch (...) + { + test &= false; + } + VERIFY( test ); + } + + { + std::vector<int> array; + const std::size_t size = array.max_size() + 1; + try + { + array.reserve(size); + } + catch (const std::length_error& error) + { + test &= true; + } + catch (...) + { + test &= false; + } + VERIFY( test ); + } +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable.cc new file mode 100644 index 000000000..531ae01b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-28 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::vector<copycounter> a(40); + copycounter::copycount = 0; + + a.reserve(50); + VERIFY( copycounter::copycount == 0 ); + + a.reserve(200); + VERIFY( copycounter::copycount == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable2.cc new file mode 100644 index 000000000..e836343a9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/reserve/moveable2.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-06-07 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::vector<throwing_move_constructor> v(5); + + v.reserve(50); + VERIFY( v.capacity() >= 50 ); + + v.reserve(500); + VERIFY( v.capacity() >= 500 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/1.cc new file mode 100644 index 000000000..1c30ff5ae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/1.cc @@ -0,0 +1,55 @@ +// 1999-05-07 +// bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.2 vector capacity + +// This fails on some versions of Darwin 8 because malloc doesn't return +// NULL even if an allocation fails (filed as Radar 3884894). +// { dg-do run { xfail *-*-darwin8.[0-4].* } } + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + std::vector<int> v; + try + { + v.resize(v.max_size()); + v[v.max_size() - 1] = 2002; + } + catch (const std::bad_alloc& error) + { + test = true; + } + catch (...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc new file mode 100644 index 000000000..157864ae2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<copycounter> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable2.cc new file mode 100644 index 000000000..14fee1362 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable2.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-06-07 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::vector<throwing_move_constructor> v(5); + + v.resize(50); + VERIFY( v.size() == 50 ); + + v.reserve(200); + VERIFY( v.capacity() >= 200 ); + + v.resize(100); + VERIFY( v.size() == 100 ); + + v.resize(500, throwing_move_constructor()); + VERIFY( v.size() == 500 ); + + v.reserve(2000); + VERIFY( v.capacity() >= 2000 ); + + v.resize(1000, throwing_move_constructor()); + VERIFY( v.size() == 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc new file mode 100644 index 000000000..1fbfc506d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<__gnu_test::NonCopyConstructible> v; + VERIFY( std::distance(v.begin(), v.end()) == 0 ); + + v.resize(1000); + VERIFY( std::distance(v.begin(), v.end()) == 1000 ); + for(auto it = v.begin(); it != v.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc new file mode 100644 index 000000000..5fcc730f2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/42573 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> v(100); + v.push_back(1); + v.push_back(1); + VERIFY( v.size() < v.capacity() ); + v.shrink_to_fit(); + VERIFY( v.size() == v.capacity() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit2.cc new file mode 100644 index 000000000..dc9182639 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit2.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::propagating_allocator; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef propagating_allocator<int, true> alloc_type; + alloc_type alloc(5); + + std::vector<int, alloc_type> v(10u, 1, alloc); + v.reserve(100); + VERIFY( v.size() < v.capacity() ); + v.shrink_to_fit(); + VERIFY( v.size() == v.capacity() ); + VERIFY( v.get_allocator().get_personality() == alloc.get_personality() ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef propagating_allocator<int, false> alloc_type; + alloc_type alloc(5); + + std::vector<int, alloc_type> v(10u, 1, alloc); + v.reserve(100); + VERIFY( v.size() < v.capacity() ); + v.shrink_to_fit(); + VERIFY( v.size() == v.capacity() ); + VERIFY( v.get_allocator().get_personality() == alloc.get_personality() ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc new file mode 100644 index 000000000..8a1a99946 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc @@ -0,0 +1,76 @@ +// 2004-07-26 Matt Austern <austern@apple.com> +// +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <vector> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::vector<int, tracker_allocator<int> > 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); + c.reserve(100); + 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); + c.reserve(100); + 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); + c.reserve(100); + 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc new file mode 100644 index 000000000..cf7ae43fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc @@ -0,0 +1,46 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include <vector> +#include <string> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +template<typename T> + struct A { }; + +struct B { }; + +void test01() +{ + // 1 + std::vector< A<B> > vec01; + std::vector< A<B> > vec02(5); + typedef std::vector< A<B> >::size_type size_type; + + vec01 = vec02; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc new file mode 100644 index 000000000..b74ac929f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc @@ -0,0 +1,47 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include <vector> +#include <string> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +template<typename T> + struct A { }; + +struct B { }; + +// 2 +template class std::vector<double>; +template class std::vector< A<B> >; + +// libstdc++/102 +void test02() +{ + std::vector<int> v1; + std::vector<int> v2(v1); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc new file mode 100644 index 000000000..4d60f1e2e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc @@ -0,0 +1,52 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include <vector> +#include <string> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +// test range constructors and range-fill constructor +void +test03() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {7, 7, 7, 7, 7}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + + std::vector<int> v3(A, A + N); + VERIFY(std::equal(v3.begin(), v3.end(), A)); + + std::vector<int> v4(v3.begin(), v3.end()); + VERIFY(std::equal(v4.begin(), v4.end(), A)); + + std::vector<int> v5(M, 7); + VERIFY(std::equal(v5.begin(), v5.end(), B)); + VERIFY(std::equal(B, B + M, v5.begin())); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc new file mode 100644 index 000000000..7ee9680c7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc @@ -0,0 +1,584 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include <vector> +#include <string> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +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; + +// @fn test_default_ctor_exception_gurantee This test verifies that if +// one of the vector's contained objects throws an exception from its +// constructor while the vector is being constructed and filled with +// default values, all memory is returned to the allocator whence it +// came. +void +test_default_ctor_exception_gurantee() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + copy_tracker::reset(); + copy_constructor::throw_on(3); + tracker_allocator_counter::reset(); + + // run 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 +} + +// @fn test_copy_ctor_exception_gurantee This test verifies that if +// one of the vector's contained objects throws an exception from its +// constructor while the vector is being copy constructed, all memory +// is returned to the allocator whence it came. +void +test_copy_ctor_exception_gurantee() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + copy_tracker::reset(); + copy_constructor::throw_on(3); + + // run test + try + { + X u(a); + VERIFY(false); + } + catch (...) + { + } + } + + // assert postconditions + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +// operator=() +// +// case 1: lhs.size() > rhs.size() +// case 2: lhs.size() < rhs.size() < lhs.capacity() +// case 3: lhs.capacity() < rhs.size() +// +void +test_assignment_operator_1() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X r(9); + X a(r.size() - 2); + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // preconditions + VERIFY(r.size() > a.size()); + + // run test + r = a; + + // assert postconditions + VERIFY(r == a); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_assignment_operator_2() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X r(1); + r.reserve(17); + X a(r.size() + 7); + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // preconditions + VERIFY(r.size() < a.size()); + VERIFY(a.size() < r.capacity()); + + // run test + r = a; + + // assert postconditions + VERIFY(r == a); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_assignment_operator_3() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X r(1); + X a(r.capacity() + 7); + copy_tracker::reset(); + + // preconditions + VERIFY(r.capacity() < a.size()); + + // run test + r = a; + + // assert postconditions + VERIFY(r == a); + } + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_assignment_operator_3_exception_guarantee() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X r(1); + X a(r.capacity() + 7); + copy_tracker::reset(); + copy_constructor::throw_on(3); + + // preconditions + VERIFY(r.capacity() < a.size()); + + // run test + try + { + r = a; + VERIFY(false); + } + catch (...) + { + } + } + + // assert postconditions + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +// fill assign() +// +// case 1: [23.2.4.1 (3)] n <= size() +// case 2: [23.2.4.1 (3)] size() < n <= capacity() +// case 3: [23.2.4.1 (3)] n > capacity() +// case 4: [23.2.4.1 (3)] n > capacity(), exception guarantees +// case 5: [23.1.1 (9)] fill assign disguised as a range assign +// +void +test_fill_assign_1() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X a(7); + X::size_type old_size = a.size(); + X::size_type new_size = old_size - 2; + const T t; + + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // run test + a.assign(new_size, t); + + // assert postconditions + VERIFY(a.size() == new_size); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_fill_assign_2() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X a(7); + a.reserve(11); + X::size_type old_size = a.size(); + X::size_type old_capacity = a.capacity(); + X::size_type new_size = old_size + 2; + const T t; + + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // assert preconditions + VERIFY(old_size < new_size); + VERIFY(new_size <= old_capacity); + + // run test + a.assign(new_size, t); + + // assert postconditions + VERIFY(a.size() == new_size); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_fill_assign_3() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + X::size_type old_capacity = a.capacity(); + X::size_type new_size = old_capacity + 4; + const T t; + + copy_tracker::reset(); + + // assert preconditions + VERIFY(new_size > old_capacity); + + // run test + a.assign(new_size, t); + + // assert postconditions + VERIFY(a.size() == new_size); + } + + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_fill_assign_3_exception_guarantee() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + X::size_type old_size = a.size(); + X::size_type old_capacity = a.capacity(); + X::size_type new_size = old_capacity + 4; + const T t; + + copy_tracker::reset(); + copy_constructor::throw_on(3); + + // assert preconditions + VERIFY(new_size > old_capacity); + + // run test + try + { + a.assign(new_size, t); + VERIFY(false); + } + catch (...) + { + } + + // assert postconditions + VERIFY(a.size() == old_size); + VERIFY(a.capacity() == old_capacity); + } + + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_fill_assign_4() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X a(7); + X::size_type old_size = a.size(); + X::size_type new_size = old_size - 2; + X::size_type new_value = 117; + + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // run test + a.assign(new_size, new_value); + + // assert postconditions + VERIFY(a.size() == new_size); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +// range assign() +// +// case 1: [23.2.4.1 (2)] input iterator +// case 2: [23.2.4.1 (2)] forward iterator, distance(first, last) <= size() +// case 3: [23.2.4.1 (2)] +// forward iterator, size() < distance(first, last) <= capacity() +// case 4: [23.2.4.1 (2)] forward iterator, distance(first, last) > capacity() +// case 5: [23.2.4.1 (2)] +// forward iterator, distance(first, last) > capacity(), +// exception guarantees +void +test_range_assign_1() +{ + // @TODO +} + +void +test_range_assign_2() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X a(7); + X b(3); + + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // assert preconditions + VERIFY(b.size() < a.capacity()); + + // run test + a.assign(b.begin(), b.end()); + + // assert postconditions + VERIFY(a.size() == b.size()); + VERIFY(a == b); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_range_assign_3() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + X a(7); + a.reserve(a.size() + 7); + X b(a.size() + 3); + + copy_tracker::reset(); + tracker_allocator_counter::reset(); + + // assert preconditions + VERIFY(a.size() < b.size()); + VERIFY(b.size() < a.capacity()); + + // run test + a.assign(b.begin(), b.end()); + + // assert postconditions + VERIFY(a.size() == b.size()); + VERIFY(a == b); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_range_assign_4() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + X b(a.capacity() + 7); + + copy_tracker::reset(); + + // assert preconditions + VERIFY(b.size() > a.capacity()); + + // run test + a.assign(b.begin(), b.end()); + + // assert postconditions + VERIFY(a.size() == b.size()); + VERIFY(a == b); + } + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + +void +test_range_assign_4_exception_guarantee() +{ + // setup + bool test __attribute__((unused)) = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_allocator<T> > X; + + tracker_allocator_counter::reset(); + { + X a(7); + X b(a.capacity() + 7); + + copy_tracker::reset(); + copy_constructor::throw_on(3); + + // assert preconditions + VERIFY(b.size() > a.capacity()); + + // run test + try + { + a.assign(b.begin(), b.end()); + VERIFY(false); + } + catch (...) + { + } + } + + // assert postconditions + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); + + // teardown + copy_tracker::reset(); + tracker_allocator_counter::reset(); +} + + +int main() +{ + test_default_ctor_exception_gurantee(); + test_copy_ctor_exception_gurantee(); + test_assignment_operator_1(); + test_assignment_operator_2(); + test_assignment_operator_3(); + test_assignment_operator_3_exception_guarantee(); + test_fill_assign_1(); + test_fill_assign_2(); + test_fill_assign_3(); + test_fill_assign_3_exception_guarantee(); + test_fill_assign_4(); + test_range_assign_1(); + test_range_assign_2(); + test_range_assign_3(); + test_range_assign_4(); + test_range_assign_4_exception_guarantee(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/55977.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/55977.cc new file mode 100644 index 000000000..85263bbda --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/55977.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <memory> +#include <utility> +#include <vector> +#include <iterator> + +template <class T> +struct MyAllocator +{ + std::allocator<T> base; + typedef T value_type; + MyAllocator() = default; + template <class U> + MyAllocator(const MyAllocator<U>& other) : base(other.base) {} + T* allocate(std::size_t n) { return base.allocate(n); } + void deallocate(T* p, std::size_t n) { return base.deallocate(p, n); } + template <class U, class... Args> + void construct(U* p, Args&&... args) + { + ::new (static_cast<void*>(p)) U(std::forward<Args>(args)...); + } +}; + +struct A +{ +private: + friend class MyAllocator<A>; + A(int value) : value(value) {} + int value; +public: + A() : value() {} + int get() const { return value; } +}; + +void foo() +{ + std::vector<A, MyAllocator<A>> v1; + const int i = 1; + v1.emplace_back(i); // OK + std::vector<A, MyAllocator<A>> v2(std::istream_iterator<int>(), {}); // ERROR +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc new file mode 100644 index 000000000..8c5c62447 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc @@ -0,0 +1,38 @@ +// 1999-06-29 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.1 vector constructors, copy, and assignment + +#include <vector> +#include <string> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +// libstdc++/6513 +void test04() +{ + const char* c_strings[5] = { "1", "2", "3", "4", "5" }; + std::vector<std::string> strings(c_strings, c_strings + 5); +} + +int main() +{ + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc new file mode 100644 index 000000000..c1695dd37 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator<T>() + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + 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<std::vector<int, clear_alloc<int> > >(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc new file mode 100644 index 000000000..70542d850 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<__gnu_test::NonCopyConstructible> v(1000); + VERIFY( std::distance(v.begin(), v.end()) == 1000 ); + for(auto it = v.begin(); it != v.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc new file mode 100644 index 000000000..ce92482c1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on vector (via swap). If the implementation changed +// this test may begin to fail. + +#include <vector> +#include <utility> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); + + std::vector<int> c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == 1 ); + VERIFY( b.size() == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::vector<bool> a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 ); + + std::vector<bool> c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == 1 ); + VERIFY( b.size() == 0 ); +} + +int main(void) +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc new file mode 100644 index 000000000..4990fc3e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <iterator> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; +typedef std::vector<rvalstruct> 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<rvalstruct> begin, + input_iterator_wrapper<rvalstruct> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..01e35d77f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +typedef std::vector<int> vtype; + +static_assert(std::is_nothrow_move_constructible<vtype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/data_access/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/data_access/1.cc new file mode 100644 index 000000000..d6c036d00 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/data_access/1.cc @@ -0,0 +1,50 @@ +// 2005-08-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/23578 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::vector<int> vector_type; + + { + const int A[] = { 0, 1, 2, 3, 4 }; + vector_type v(A, A + 5); + VERIFY( v.data() == &v.front() ); + int* pi = v.data(); + VERIFY( *pi == 0 ); + } + + { + const int A[] = { 4, 3, 2, 1, 0 }; + const vector_type cv(A, A + 5); + VERIFY( cv.data() == &cv.front() ); + const int* pci = cv.data(); + VERIFY( *pci == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc new file mode 100644 index 000000000..54813d424 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// PR libstdc++/52433 + +#include <vector> + +struct X +{ + std::vector<int>::iterator i; + + X() = default; + X(const X&) = default; + X(X&&) = default; + X& operator=(const X&) = default; + X& operator=(X&&) = default; +}; + +X test01() +{ + X x; + x = X(); + return x; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc new file mode 100644 index 000000000..a317a839f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> + +void test01() +{ + std::vector<int> v; + for (int i = 0; i != 10; ++i) + v.push_back(i); + + v.insert(v.begin(), v.data() + 1, v.data() + 5); // Expected failure +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc new file mode 100644 index 000000000..9ba4dfeba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// PR libstdc++/60499 + +#define xfer_memory 1 +#include <vector> + +std::vector<int> a, b = std::move(a); diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587.cc new file mode 100644 index 000000000..73b4dac71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } + +// PR libstdc++/60587 + +#include <vector> + +int main() { + std::vector<int> a, b; + a.push_back(1); + a.insert(a.end(), b.begin(), b.end()); + b.push_back(1L); + a.insert(a.end(), b.begin(), b.end()); + + std::vector<long> c; + a.insert(a.end(), c.begin(), c.end()); + c.push_back(1L); + a.insert(a.end(), c.begin(), c.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc new file mode 100644 index 000000000..219271b73 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +// PR libstdc++/60587 + +#include <vector> + +int main() { + std::vector<int> a; + a.push_back(1); + a.insert(a.end(), a.begin(), a.begin()); // Expected to abort here +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/alloc_prop.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/alloc_prop.cc new file mode 100644 index 000000000..1fa57e381 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/alloc_prop.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <debug/vector> +#include <type_traits> +#include <testsuite_allocator.h> + +template<typename T, typename A> + void + test() + { + typedef std::vector<T, A> base; + typedef __gnu_debug::vector<T, A> debug; + + using std::is_nothrow_default_constructible; + using std::is_nothrow_copy_constructible; + using std::is_nothrow_move_constructible; + using std::is_nothrow_copy_assignable; + using std::is_nothrow_move_assignable; + + static_assert( + is_nothrow_default_constructible<base>::value + == is_nothrow_default_constructible<debug>::value, + "nothrow default constructible"); + + static_assert( + is_nothrow_copy_constructible<base>::value + == is_nothrow_copy_constructible<debug>::value, + "nothrow copy constructible"); + + static_assert( + is_nothrow_move_constructible<base>::value + == is_nothrow_move_constructible<debug>::value, + "nothrow move constructible"); + + static_assert( + is_nothrow_copy_assignable<base>::value + == is_nothrow_copy_assignable<debug>::value, + "nothrow move assignable"); + + static_assert( + is_nothrow_move_assignable<base>::value + == is_nothrow_move_assignable<debug>::value, + "nothrow move assignable"); + } + +struct X +{ + X() { } + ~X() { } + X(const X&) { } + X(X&&) { } + X& operator=(const X&) { return *this; } + X& operator=(X&&) { return *this; } +}; + +int main() +{ + using __gnu_test::propagating_allocator; + using __gnu_test::SimpleAllocator; + + test<int, std::allocator<int>>(); + test<int, SimpleAllocator<int>>(); + test<int, propagating_allocator<int, true>>(); + test<int, propagating_allocator<int, false>>(); + test<X, std::allocator<X>>(); + test<X, SimpleAllocator<X>>(); + test<X, propagating_allocator<X, true>>(); + test<X, propagating_allocator<X, false>>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc new file mode 100644 index 000000000..f2e92431a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc new file mode 100644 index 000000000..a579f80e6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign2<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc new file mode 100644 index 000000000..ce341deb0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign3<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc new file mode 100644 index 000000000..e826a3fa7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc new file mode 100644 index 000000000..2200b8f95 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <vector> + +void test01() +{ + using std::vector; + + vector<bool> vb(__CHAR_BIT__ * sizeof(unsigned long) + 1); + vb.pop_back(); + + vector<bool>::iterator it = vb.begin(); + vb.shrink_to_fit(); + + // Following line should assert + *it = true; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc new file mode 100644 index 000000000..631c7955e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc new file mode 100644 index 000000000..dc4333dd9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc new file mode 100644 index 000000000..6140faedf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc new file mode 100644 index 000000000..6535fb26c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/debug_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/debug_functions.cc new file mode 100644 index 000000000..e2dfd1a6b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/debug_functions.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } + +#include <vector> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_debug; + + std::vector<int> v1(3, 1); + VERIFY( __check_dereferenceable(v1.begin()) ); + std::vector<int>::iterator it = v1.begin(); + VERIFY( __check_dereferenceable(it) ); + + VERIFY( !__check_dereferenceable(v1.end()) ); + it = v1.end(); + VERIFY( !__check_dereferenceable(it) ); + + const volatile int* pi = 0; + VERIFY( !__check_dereferenceable(pi) ); + + int i; + pi = &i; + + VERIFY( __check_dereferenceable(pi) ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_debug; + + std::vector<int> v1(3, 1); + VERIFY( !__check_singular(v1.begin()) ); + std::vector<int>::iterator it = v1.begin(); + VERIFY( !__check_singular(it) ); + + VERIFY( !__check_singular(v1.end()) ); + it = v1.end(); + VERIFY( !__check_singular(it) ); + + v1.clear(); + + VERIFY( it._M_singular() ); + VERIFY( __check_singular(it) ); + + it = v1.end(); + VERIFY( !it._M_singular() ); + VERIFY( !__check_singular(it) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc new file mode 100644 index 000000000..c5392a2b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc new file mode 100644 index 000000000..7ae40fd95 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc new file mode 100644 index 000000000..64407739d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc new file mode 100644 index 000000000..8d6c43478 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <debug/vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc new file mode 100644 index 000000000..91c5bf46b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert4<std::vector<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc new file mode 100644 index 000000000..b2d23de0c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-do run { xfail *-*-* } } + +#include <vector> +#include <debug/vector> +#include <debug/checks.h> + +void test01() +{ + std::vector<bool> v; + __gnu_debug::vector<bool> dv; + for (int i = 0; i != 10; ++i) + { + v.push_back((i % 2) != 0); + dv.push_back((i % 2) == 0); + } + + dv.insert(dv.begin(), v.begin(), v.begin() + 5); + VERIFY( dv.size() == 15 ); +} + +void test02() +{ + __gnu_test::check_insert4<__gnu_debug::vector<bool> >(); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc new file mode 100644 index 000000000..88b36d4e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/1.cc @@ -0,0 +1,59 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include <debug/vector> +#include <testsuite_hooks.h> + +using __gnu_debug::vector; + +bool test = true; + +// Assignment +void test01() +{ + vector<int> v1; + vector<int> v2; + + vector<int>::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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc new file mode 100644 index 000000000..56a6bed12 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/2.cc @@ -0,0 +1,64 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include <debug/vector> +#include <testsuite_hooks.h> + +using __gnu_debug::vector; + +bool test = true; + +// Resize +void test02() +{ + vector<int> v(10, 17); + v.reserve(20); + + vector<int>::iterator before = v.begin() + 6; + vector<int>::iterator at = before + 1; + vector<int>::iterator after = at + 1; + + // Shrink + v.resize(7); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_singular()); + + // Grow, without reallocation + before = v.begin() + 6; + v.resize(17); + VERIFY(before._M_dereferenceable()); + + // Grow, with reallocation + v.resize(42); + VERIFY(before._M_singular()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc new file mode 100644 index 000000000..ca85b946f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/3.cc @@ -0,0 +1,89 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include <debug/vector> +#include <testsuite_hooks.h> + +using __gnu_debug::vector; + +bool test = true; + +// Insert +void test03() +{ + vector<int> v(10, 17); + v.reserve(30); + + // Insert a single element + vector<int>::iterator before = v.begin() + 6; + vector<int>::iterator at = before + 1; + vector<int>::iterator after = at; + at = v.insert(at, 42); + VERIFY(before._M_dereferenceable()); + 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_dereferenceable()); + 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_dereferenceable()); + VERIFY(at._M_singular()); + + // Insert with reallocation + before = v.begin() + 6; + at = before + 1; + v.insert(at, 30, 17); + VERIFY(before._M_singular()); + VERIFY(at._M_singular()); + + // Single insert with reallocation + vector<int> v2; + v2.reserve(100); + at = v2.begin(); + v2.insert(at, 100, 17); + at = v2.end() - 1; + before = v2.begin(); + VERIFY(at._M_dereferenceable()); + VERIFY(before._M_dereferenceable()); + at = v2.insert(at, 42); + VERIFY(at._M_dereferenceable()); + VERIFY(before._M_singular()); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc new file mode 100644 index 000000000..9dd6897e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/invalidation/4.cc @@ -0,0 +1,66 @@ +// Vector iterator invalidation tests + +// Copyright (C) 2003-2014 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 +// <http://www.gnu.org/licenses/>. + +// We need to be pedantic about reallocations for this testcase to be correct. +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#ifndef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDANTIC 1 +#endif + +#include <debug/vector> +#include <testsuite_hooks.h> + +using __gnu_debug::vector; + +bool test = true; + +// Erase +void test04() +{ + vector<int> v(20, 42); + + // Single element erase + vector<int>::iterator before = v.begin(); + vector<int>::iterator at = before + 3; + vector<int>::iterator after = at; + at = v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Multiple element erase + before = v.begin(); + at = before + 3; + v.erase(at, at + 3); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); +} + +int main() +{ + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc new file mode 100644 index 000000000..e277ac76e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <vector> + +void test01() +{ + std::vector<int> v1; + auto it1 = v1.begin(); + it1 = std::move(it1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/move_assign_neg.cc new file mode 100644 index 000000000..eb2233b35 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/move_assign_neg.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2013 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <debug/vector> + +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef __gnu_test::uneq_allocator<int> alloc_type; + typedef __gnu_debug::vector<int, alloc_type> test_type; + + test_type v1(alloc_type(1)); + v1 = { 0, 1, 2, 3 }; + + test_type v2(alloc_type(2)); + v2 = { 4, 5, 6, 7 }; + + auto it = v2.begin(); + + v1 = std::move(v2); + + VERIFY( it == v1.begin() ); // Error, it is singular +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc new file mode 100644 index 000000000..fb55a3a26 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/multithreaded_swap.cc @@ -0,0 +1,100 @@ +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-debug-mode "" } +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// This test check for potential deadlock when swaping sequences in debug +// mode as it requires acquiring 2 locks at the same time. + +#include <vector> +#include <thread> +#include <functional> +#include <testsuite_hooks.h> + +// The following function mimic the one in src/debug.cc to associate a mutex +// to a given safe sequence instance. +size_t +get_index(std::vector<int>& v) +{ + const size_t mask = 0xf; + // We have to check the address of the internal safe sequence that starts + // after the normal vector memory footprint that is to say a 3 pointers + // offset: + void* __address = reinterpret_cast<char*>(&v) + 3 * sizeof(void*); + return std::_Hash_impl::hash(__address) & mask; +} + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + vector<int> v1, v2; + vector<shared_ptr<vector<int> > > vs; + vector<int> *pv3 = 0, *pv4 = 0; + const int nb_attempts = 100; + for (int i = 0; i != nb_attempts; ++i) + { + vs.push_back(shared_ptr<vector<int> >(new vector<int>())); + if (!pv3) + { + if (get_index(*vs.back()) == get_index(v1)) + pv3 = vs.back().get(); + } + else if (!pv4) + { + if (get_index(*vs.back()) == get_index(v2)) + { + pv4 = vs.back().get(); + break; + } + } + } + + if (!pv3 || !pv4) + // Maybe an other time... + return; + + vector<int> &v3 = *pv3, &v4 = *pv4; + + // v1 and v3 shares the same mutex instance, like v2 and v4 + // thread t1 lock v1 and v2 + thread t1([&v1, &v2]() + { + for (int i = 0; i != 1000; ++i) + v1.swap(v2); + }); + // thread t2 lock v4 and v3 + thread t2([&v3, &v4]() + { + for (int i = 0; i != 1000; ++i) + v4.swap(v3); + }); + t2.join(); + t1.join(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc new file mode 100644 index 000000000..bb5f37928 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++11" } +// { dg-do run { xfail *-*-* } } + +#include <vector> + +void test01() +{ + std::vector<int> v1; + v1 = std::move(v1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc new file mode 100644 index 000000000..7178cabbe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <vector> + +void test01() +{ + using std::vector; + vector<int> v; + v.reserve(2); + v.push_back(0); + vector<int>::iterator it = v.begin(); + v.shrink_to_fit(); + // Following line should assert + *it = 1; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-1.cc new file mode 100644 index 000000000..ce74c3f46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-1.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// NB: This issue affected only debug-mode. + +#include <vector> +#include <algorithm> +#include <iterator> + +// http://gcc.gnu.org/ml/libstdc++/2008-05/msg00039.html +void test01() +{ + typedef std::vector<unsigned> array_t; + typedef std::back_insert_iterator<array_t> bii_t; + + array_t a; + + // Push 5 elements. + a.push_back(0); + a.push_back(1); + a.push_back(2); + a.push_back(3); + a.push_back(4); + // Ensure that there is enough space for other two elements. + // (2 + 5 = 7) + if (a.capacity() < 7) + a.reserve(7); + // Add two new elements. + std::copy(a.begin(), a.begin() + 2, bii_t(a)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-2.cc new file mode 100644 index 000000000..ab1ab51df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-2.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + +// NB: This issue affected only debug-mode, in pedantic mode. + +// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } + +#include <vector> +#include <algorithm> +#include <iterator> + +// http://gcc.gnu.org/ml/libstdc++/2008-05/msg00046.html +void test01() +{ + typedef std::vector<unsigned> array_t; + typedef std::back_insert_iterator<array_t> bii_t; + + array_t a; + + // Push 5 elements. + a.push_back(0); + a.push_back(1); + a.push_back(2); + a.push_back(3); + a.push_back(4); + // Ensure that there is enough space for other two elements. + // (2 + 5 = 7) + if (a.capacity() < 7) + a.reserve(7); + // Add two new elements. + std::copy(a.begin(), a.begin() + 2, bii_t(a)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/element_access/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/element_access/1.cc new file mode 100644 index 000000000..dd05683d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/element_access/1.cc @@ -0,0 +1,61 @@ +// 2000-09-06 +// bkoz + +// Copyright (C) 2000-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4 vector + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> + +template<typename T> +struct A { }; + +struct B { }; + +// http://gcc.gnu.org/ml/libstdc++/2000-09/msg00002.html +bool test01() +{ + bool test __attribute__((unused)) = true; + std::vector< A<B> > vec01; + std::vector< A<B> > vec02(5); + typedef std::vector< A<B> >::size_type size_type; + typedef std::vector< A<B> >::reference reference; + + try + { + reference r01 __attribute__((unused)) = vec01.at(6); + VERIFY( false ); // Should not get here, as exception thrown. + } + catch(std::out_of_range& err) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc new file mode 100644 index 000000000..35fc01431 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> + +// Ensures equivalence of iterators based on low-level comparison +// between const / non-const Pointer types. +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > v(7); + VERIFY( v.cbegin() == v.begin() ); + VERIFY( v.cend() == v.end() ); + VERIFY( v.crbegin() == v.rbegin() ); + VERIFY( v.crend() == v.rend() ); + VERIFY( v.cbegin() != v.cend() ); + VERIFY( v.crbegin() != v.crend() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc new file mode 100644 index 000000000..e5c6d3b87 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc @@ -0,0 +1,52 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> + +// libstdc++/23578 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vector_type; + + { + const int A[] = { 0, 1, 2, 3, 4 }; + vector_type v(A, A + 5); + VERIFY( v.data() == &v.front() ); + int* pi = &* v.data(); + VERIFY( *pi == 0 ); + } + + { + const int A[] = { 4, 3, 2, 1, 0 }; + const vector_type cv(A, A + 5); + VERIFY( cv.data() == &cv.front() ); + const int* pci = &* cv.data(); + VERIFY( *pci == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc new file mode 100644 index 000000000..cdf2060d3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc @@ -0,0 +1,26 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <ext/extptr_allocator.h> + +// { dg-do compile } + +template class std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/2.cc new file mode 100644 index 000000000..f8c18efae --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/2.cc @@ -0,0 +1,27 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <ext/extptr_allocator.h> + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template class std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc new file mode 100644 index 000000000..0dcb6fa99 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc @@ -0,0 +1,27 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <ext/extptr_allocator.h> + +// { dg-do compile } + +// libstdc++/21770 +template class std::vector<int, __gnu_cxx::_ExtPtr_allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc new file mode 100644 index 000000000..7bbf5f2d9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc @@ -0,0 +1,77 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> + +// General tests element access and manipulation +void test01() +{ + bool test __attribute__((unused)) = true; + + int A[] = { 0, 1, 2, 3, 4 }; + __gnu_cxx::_ExtPtr_allocator<int> alloc; + std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > mv( A, A+5, alloc ); + + VERIFY( mv.size() == 5 ); + VERIFY( mv.front() == 0 ); + VERIFY( mv.back() == 4 ); + VERIFY( mv.at(2) == 2 ); + VERIFY( mv[3] == 3); + mv.front() = 5; + mv.back() = 6; + mv.at(2) = 7; + mv[3] = 8; + VERIFY( mv.size() == 5 ); + VERIFY( mv.front() == 5 ); + VERIFY( mv.back() == 6 ); + VERIFY( mv.at(2) == 7 ); + VERIFY( mv[3] == 8 ); + + try + { + mv.at(100) = 8; + } + catch(std::out_of_range&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } + + const std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > cmv( mv ); + VERIFY( cmv.get_allocator() == mv.get_allocator() ); + VERIFY( mv.size() == 5 ); + VERIFY( mv.front() == 5 ); + VERIFY( mv.back() == 6 ); + VERIFY( mv.at(2) == 7 ); + VERIFY( mv[3] == 8 ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc new file mode 100644 index 000000000..d86afd2d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc @@ -0,0 +1,139 @@ +// Bob Walters 10-2008 + +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> + +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 int N = sizeof(A) / sizeof(int); +const unsigned int N1 = sizeof(A1) / sizeof(int); +const unsigned int N2 = sizeof(A2) / sizeof(int); +const unsigned int N3 = sizeof(A3) / sizeof(int); +const unsigned int N4 = sizeof(A4) / sizeof(int); +const unsigned int N5 = sizeof(A5) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v(A, A + N); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + typedef __gnu_cxx::_ExtPtr_allocator<int> int_alloc_type; + typedef __gnu_cxx::_ExtPtr_allocator< std::vector<int, int_alloc_type> > vec_alloc_type; + typedef std::vector<std::vector<int, int_alloc_type >,vec_alloc_type> vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v, v1, v2, v3, v4, v5; + for (unsigned int i = 0; i < N; ++i) + v.push_back(std::vector<int,int_alloc_type>(1, A[i])); + for (unsigned int i = 0; i < N1; ++i) + v1.push_back(std::vector<int,int_alloc_type>(1, A1[i])); + for (unsigned int i = 0; i < N2; ++i) + v2.push_back(std::vector<int,int_alloc_type>(1, A2[i])); + for (unsigned int i = 0; i < N3; ++i) + v3.push_back(std::vector<int,int_alloc_type>(1, A3[i])); + for (unsigned int i = 0; i < N4; ++i) + v4.push_back(std::vector<int,int_alloc_type>(1, A4[i])); + for (unsigned int i = 0; i < N5; ++i) + v5.push_back(std::vector<int,int_alloc_type>(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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc new file mode 100644 index 000000000..22a9ab117 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc @@ -0,0 +1,66 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> +#include <stdexcept> + +void test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::_ExtPtr_allocator<int> alloc; + std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > iv(alloc); + VERIFY( iv.get_allocator() == alloc ); + VERIFY( iv.size() == 0 ); + + int A[] = { 0, 1, 2, 3, 4 }; + int B[] = { 5, 5, 5, 5, 5 }; + int C[] = { 6, 7 }; + iv.insert(iv.end(), A, A+5 ); + VERIFY( iv.size() == 5 ); + iv.insert(iv.begin(), 5, 5 ); + iv.insert(iv.begin()+5, 7); + iv.insert(iv.begin()+5, 6); + VERIFY( std::equal(iv.begin(), iv.begin()+5, B )); + VERIFY( std::equal(iv.begin()+5, iv.begin()+7, C)); + VERIFY( std::equal(iv.begin()+7, iv.end(), A)); + VERIFY( iv.size() == 12 ); + + try + { + iv.insert(iv.end(), iv.max_size() + 1, 1); + } + catch(std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc new file mode 100644 index 000000000..35e0a8776 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc @@ -0,0 +1,64 @@ + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <stdexcept> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> +#include <ext/extptr_allocator.h> + + +void test01() +{ + // non POD types + bool test __attribute__((unused)) = true; + + std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vec01; + typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >::size_type size_type; + + VERIFY(vec01.empty()); + + const int A[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + // Test resize of the vector based on reserve + size_type sz01 = vec01.capacity(); + vec01.reserve(100); + size_type sz02 = vec01.capacity(); + VERIFY(sz02 >= sz01); + + // grow/shrink + vec01.assign( A, A+10 ); + sz01 = vec01.size() + 100; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY(sz01 == sz02); + VERIFY(std::equal(vec01.begin(), vec01.begin()+10, A)); + + sz01 = vec01.size() - 100; + vec01.resize(sz01); + sz02 = vec01.size(); + VERIFY(sz01 == sz02); + VERIFY(std::equal(vec01.begin(), vec01.end(), A)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc new file mode 100644 index 000000000..24f2de76a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc @@ -0,0 +1,60 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This is a copy of vector/types/1.cc with altered allocator. +// The operator+()s in this test initially failed the test - +// they stress the accurate recognition, by the compiler, +// of _Pointer_adapter's own pointer arithmetic functions, +// which have to match perfectly on the int type to get +// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc. + +#include <vector> +#include <ext/extptr_allocator.h> + +namespace N +{ + struct X { }; + + template<typename T> + X operator+(T, std::size_t) + { return X(); } + + template<typename T> + X operator-(T, T) + { return X(); } +} + +int main() +{ + std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5); + const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1); + + v[0]; + w[0]; + v.size(); + v.capacity(); + v.resize(1); + v.insert(v.begin(), N::X()); + v.insert(v.begin(), 1, N::X()); + v.insert(v.begin(), w.begin(), w.end()); + v = w; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc new file mode 100644 index 000000000..b2d23f9e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc @@ -0,0 +1,62 @@ +// Test for Container using non-standard pointer types. + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + + +// { dg-options "-std=gnu++0x" } + +// This is a copy of vector/types/1.cc with altered allocator. +// The operator+()s in this test initially failed the test - +// they stress the accurate recognition, by the compiler, +// of _Pointer_adapter's own pointer arithmetic functions, +// which have to match perfectly on the int type to get +// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc. + +#include <vector> +#include <ext/extptr_allocator.h> + +namespace N +{ + struct X { }; + + template<typename T> + X operator+(T, std::size_t) + { return X(); } + + template<typename T> + X operator-(T, T) + { return X(); } +} + +int main() +{ + std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5); + const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1); + + v[0]; + w[0]; + v.size(); + v.capacity(); + v.resize(1); + v.insert(v.begin(), N::X()); + v.insert(v.begin(), 1, N::X()); + v.insert(v.begin(), w.begin(), w.end()); + v = w; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/init-list.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/init-list.cc new file mode 100644 index 000000000..57c7ed6b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/init-list.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2008-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::vector<int, tracker_allocator<int> > 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", 13, 10) && ok; + ok &= (c[7] == 234); + } + ok = check_construct_destroy("Insert init-list", 13, 23) && 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc new file mode 100644 index 000000000..5ef4be8a5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/1.cc @@ -0,0 +1,55 @@ +// 1999-11-09 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.3 vector modifiers + +#include <vector> +#include "testsuite_hooks.h" + +bool test __attribute__((unused)) = true; + +template<typename T> + struct A { }; + +struct B { }; + +// vector::insert(iterator, inputiterator first, inputiterator last) +void +test01() +{ + // POD types + typedef std::vector<int> vec_POD; + vec_POD vec01; + int i01 = 5; + int* pi01 = &i01; + vec01.insert(vec01.begin(), pi01, pi01 + 1); + + // non POD types + typedef std::vector< A<B> > vec_nonPOD; + vec_nonPOD vec02; + A<B> np01; + A<B>* pnp01 = &np01; + vec02.insert(vec02.begin(), pnp01, pnp01 + 1); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc new file mode 100644 index 000000000..4fb0e3563 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/2.cc @@ -0,0 +1,61 @@ +// 1999-11-09 bkoz + +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.3 vector modifiers + +#include <vector> +#include "testsuite_hooks.h" + +bool test __attribute__((unused)) = true; + +// test the assign() function +void +test03() +{ + const int K = 417; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {K, K, K, K, K}; + const std::size_t N = sizeof(A) / sizeof(int); + const std::size_t M = sizeof(B) / sizeof(int); + bool test __attribute__((unused)) = true; + + // assign from pointer range + std::vector<int> v3; + v3.assign(A, A + N); + VERIFY(std::equal(v3.begin(), v3.end(), A)); + VERIFY(v3.size() == N); + + // assign from iterator range + std::vector<int> v4; + v4.assign(v3.begin(), v3.end()); + VERIFY(std::equal(v4.begin(), v4.end(), A)); + VERIFY(std::equal(A, A + N, v4.begin())); + + // assign from initializer range with resize + v4.assign(M, K); + VERIFY(std::equal(v4.begin(), v4.end(), B)); + VERIFY(std::equal(B, B + M, v4.begin())); + VERIFY((v4.size() == M) && (M != N)); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/52799.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/52799.cc new file mode 100644 index 000000000..b5d618cc8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/52799.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +// libstdc++/52799 +int main() +{ + std::vector<int> v; + v.emplace(v.begin()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc new file mode 100644 index 000000000..b030e1b59 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<int> v1; + v1.emplace(v1.cbegin(), 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/1.cc new file mode 100644 index 000000000..5bad1517a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/1.cc @@ -0,0 +1,135 @@ +// 2005-11-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.3 vector modifiers + +#include <vector> +#include <testsuite_hooks.h> + +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 int N = sizeof(A) / sizeof(int); +const unsigned int N1 = sizeof(A1) / sizeof(int); +const unsigned int N2 = sizeof(A2) / sizeof(int); +const unsigned int N3 = sizeof(A3) / sizeof(int); +const unsigned int N4 = sizeof(A4) / sizeof(int); +const unsigned int N5 = sizeof(A5) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<int> vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v(A, A + N); + + iterator_type it1 = v.erase(v.begin() + 1); + VERIFY( it1 == v.begin() + 1 ); + VERIFY( v.size() == N1 ); + VERIFY( std::equal(v.begin(), v.end(), A1) ); + + iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9); + VERIFY( it2 == v.begin() + 4 ); + VERIFY( v.size() == N2 ); + VERIFY( std::equal(v.begin(), v.end(), A2) ); + + iterator_type it3 = v.erase(v.begin() + 6, v.end()); + VERIFY( it3 == v.begin() + 6 ); + VERIFY( v.size() == N3 ); + VERIFY( std::equal(v.begin(), v.end(), A3) ); + + iterator_type it4 = v.erase(v.begin(), v.begin() + 3); + VERIFY( it4 == v.begin() ); + VERIFY( v.size() == N4 ); + VERIFY( std::equal(v.begin(), v.end(), A4) ); + + iterator_type it5 = v.erase(v.begin() + 2); + VERIFY( it5 == v.begin() + 2 ); + VERIFY( v.size() == N5 ); + VERIFY( std::equal(v.begin(), v.end(), A5) ); + + iterator_type it6 = v.erase(v.begin(), v.end()); + VERIFY( it6 == v.begin() ); + VERIFY( v.empty() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector<std::vector<int> > vec_type; + typedef vec_type::iterator iterator_type; + + vec_type v, v1, v2, v3, v4, v5; + for (unsigned int i = 0; i < N; ++i) + v.push_back(std::vector<int>(1, A[i])); + for (unsigned int i = 0; i < N1; ++i) + v1.push_back(std::vector<int>(1, A1[i])); + for (unsigned int i = 0; i < N2; ++i) + v2.push_back(std::vector<int>(1, A2[i])); + for (unsigned int i = 0; i < N3; ++i) + v3.push_back(std::vector<int>(1, A3[i])); + for (unsigned int i = 0; i < N4; ++i) + v4.push_back(std::vector<int>(1, A4[i])); + for (unsigned int i = 0; i < N5; ++i) + v5.push_back(std::vector<int>(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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc new file mode 100644 index 000000000..aedc36543 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-09-26 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_rvalref.h> + +// libstdc++/50529 +void test01() +{ + std::vector<__gnu_test::rvalstruct> v(10); + + for (auto it = v.begin(); it != v.end(); ++it) + v.erase(it, it); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/54577.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/54577.cc new file mode 100644 index 000000000..5eb2c6927 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<int> v1; + v1.push_back(1); + v1.erase(v1.cbegin()); + + std::vector<int> v2; + v2.push_back(2); + v2.push_back(3); + v2.erase(v2.cbegin(), v2.cend()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/moveable.cc new file mode 100644 index 000000000..f0e7e6219 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/moveable.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-28 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::vector<copycounter> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/1.cc new file mode 100644 index 000000000..e1062e3bc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/1.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + vector<int> iv; + + try + { + iv.insert(iv.end(), iv.max_size() + 1, 1); + } + catch(std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/58148.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/58148.cc new file mode 100644 index 000000000..3952fabc9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/58148.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include <vector> + +void +test01() +{ + std::vector<wchar_t> v; + char c = 'a'; + v.insert(v.begin(), &c, &c); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc new file mode 100644 index 000000000..5750aade6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +void test01() +{ + std::vector<int> v1, v2{5, 6}; + int n = 0; + std::vector<int>::iterator it = v1.insert(v1.cbegin(), n); + it = v1.insert(v1.cbegin(), 1); + it = v1.insert(v1.cbegin(), {2, 3}); + it = v1.insert(v1.cbegin(), 1, 4); + it = v1.insert(v1.cbegin(), v2.begin(), v2.end()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable.cc new file mode 100644 index 000000000..d6c990075 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable.cc @@ -0,0 +1,137 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +using namespace __gnu_test; + +// Test vector::push_back makes no unneeded copies. +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<copycounter> a; + copycounter c(1); + copycounter::copycount = 0; + for(int i = 0; i < 10; ++i) + a.push_back(c); + VERIFY(copycounter::copycount == 10); + + for(int i = 0; i < 100; ++i) + a.insert(a.begin() + i, c); + VERIFY(copycounter::copycount == 110); + + for(int i = 0; i < 1000; ++i) + a.insert(a.end(), c); + VERIFY(copycounter::copycount == 1110); +} + +// Test vector::insert(iterator, iterator, iterator) makes no unneeded copies +// when it has to also reallocate the vector's internal buffer. +void +test02() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::vector<copycounter> a(10, c), b(100, c); + copycounter::copycount = 0; + a.insert(a.begin(), b.begin(), b.begin() + 20); + VERIFY(copycounter::copycount == 20); + a.insert(a.end(), b.begin(), b.begin() + 50); + VERIFY(copycounter::copycount == 70); + a.insert(a.begin() + 50, b.begin(), b.end()); + VERIFY(copycounter::copycount == 170); +} + +// Test vector::insert(iterator, iterator, iterator) makes no unneeded copies +// when it doesn't have to reallocate the vector's internal buffer. +void +test03() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::vector<copycounter> a(10, c), b(100, c); + copycounter::copycount = 0; + a.reserve(1000); + VERIFY(copycounter::copycount == 0); + a.insert(a.begin(), b.begin(), b.begin() + 20); + VERIFY(copycounter::copycount == 20); + a.insert(a.end(), b.begin(), b.begin() + 50); + VERIFY(copycounter::copycount == 70); + a.insert(a.begin() + 50, b.begin(), b.end()); + VERIFY(copycounter::copycount == 170); +} + +// Test vector::insert(iterator, count, value) makes no unneeded copies +// when it has to also reallocate the vector's internal buffer. +void +test04() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::vector<copycounter> 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); + a.insert(a.begin() + 50, 100, c); + VERIFY(copycounter::copycount == 170); +} + +// Test vector::insert(iterator, count, value) makes no unneeded copies +// when it doesn't have to reallocate the vector's internal buffer. +void +test05() +{ + bool test __attribute__((unused)) = true; + + copycounter c(1); + std::vector<copycounter> a(10, c); + copycounter::copycount = 0; + a.reserve(1000); + a.insert(a.begin(), 20, c); + // NOTE : These values are each one higher than might be expected, as + // vector::insert(iterator, count, value) copies the value it is given + // when it doesn't reallocate the buffer. + VERIFY(copycounter::copycount == 20 + 1); + a.insert(a.end(), 50, c); + VERIFY(copycounter::copycount == 70 + 2); + a.insert(a.begin() + 50, 100, c); + VERIFY(copycounter::copycount == 170 + 3); +} + + + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable2.cc new file mode 100644 index 000000000..c38ef985a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/moveable2.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-06-07 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + std::vector<throwing_move_constructor> v1; + + throwing_move_constructor tmc; + + v1.push_back(tmc); + VERIFY( v1.size() == 1 ); + + v1.push_back(tmc); + VERIFY( v1.size() == 2 ); + + v1.insert(v1.end(), tmc); + VERIFY( v1.size() == 3 ); + + v1.insert(v1.end(), 100, tmc); + VERIFY( v1.size() == 103 ); + + v1.insert(v1.end(), 10, tmc); + VERIFY( v1.size() == 113 ); + + v1.insert(v1.end(), 1, tmc); + VERIFY( v1.size() == 114 ); + + std::vector<throwing_move_constructor> v2; + + throwing_move_constructor tmca[] + = { throwing_move_constructor(), throwing_move_constructor(), + throwing_move_constructor(), throwing_move_constructor() }; + + v2.insert(v2.end(), tmca, tmca + 1); + VERIFY( v2.size() == 1 ); + + v2.insert(v2.end(), tmca, tmca + 4); + VERIFY( v2.size() == 5 ); + + v2.insert(v2.end(), tmca, tmca + 2); + VERIFY( v2.size() == 7 ); + + v2.insert(v2.end(), tmca, tmca + 1); + VERIFY( v2.size() == 8 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/49836.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/49836.cc new file mode 100644 index 000000000..e294c9f8e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/49836.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// libstdc++/49836 +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::CopyConsOnlyType; + using __gnu_test::MoveConsOnlyType; + + std::vector<CopyConsOnlyType> v1; + CopyConsOnlyType t1(1); + v1.push_back(t1); + v1.push_back(t1); + v1.push_back(t1); + VERIFY( v1.size() == 3 ); + + std::vector<MoveConsOnlyType> v2; + MoveConsOnlyType t2(1); + v2.push_back(std::move(t2)); + v2.push_back(std::move(t2)); + v2.push_back(std::move(t2)); + VERIFY( v2.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc new file mode 100644 index 000000000..5babf9526 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_hooks.h> + +struct T { int i; }; + +int swap_calls; + +namespace std +{ + template<> + void + vector<T, allocator<T> >::swap(vector<T, allocator<T> >&) + { ++swap_calls; } +} + +// Should use vector specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::vector<T> A; + std::vector<T> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use vector specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + vector<T> A; + vector<T> 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/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/2.cc new file mode 100644 index 000000000..2c42f1f5c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/2.cc @@ -0,0 +1,132 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.3 vector::swap + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef vector<char, my_alloc> my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1); + + my_vector vec01(alloc01); + size01 = vec01.size(); + my_vector vec02(alloc01); + size02 = vec02.size(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + + my_vector vec03(alloc01); + size01 = vec03.size(); + my_vector vec04(title02, title02 + N2, alloc01); + size02 = vec04.size(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), title02) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + + my_vector vec05(title01, title01 + N1, alloc01); + size01 = vec05.size(); + my_vector vec06(title02, title02 + N2, alloc01); + size02 = vec06.size(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), title02) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), title01) ); + + my_vector vec07(title01, title01 + N1, alloc01); + size01 = vec07.size(); + my_vector vec08(title03, title03 + N3, alloc01); + size02 = vec08.size(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), title03) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), title01) ); + + my_vector vec09(title03, title03 + N3, alloc01); + size01 = vec09.size(); + my_vector vec10(title04, title04 + N4, alloc01); + size02 = vec10.size(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), title04) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), title03) ); + + my_vector vec11(title04, title04 + N4, alloc01); + size01 = vec11.size(); + my_vector vec12(title01, title01 + N1, alloc01); + size02 = vec12.size(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), title01) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), title04) ); + + my_vector vec13(title03, title03 + N3, alloc01); + size01 = vec13.size(); + my_vector vec14(title03, title03 + N3, alloc01); + size02 = vec14.size(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), title03) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), title03) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/3.cc new file mode 100644 index 000000000..e7c0398f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/3.cc @@ -0,0 +1,161 @@ +// 2005-12-20 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// 23.2.4.3 vector::swap + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef vector<char, my_alloc> my_vector; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + my_vector::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_vector vec01(alloc01); + size01 = vec01.size(); + personality01 = vec01.get_allocator().get_personality(); + my_vector vec02(alloc02); + size02 = vec02.size(); + personality02 = vec02.get_allocator().get_personality(); + + vec01.swap(vec02); + VERIFY( vec01.size() == size02 ); + VERIFY( vec01.empty() ); + VERIFY( vec02.size() == size01 ); + VERIFY( vec02.empty() ); + VERIFY( vec01.get_allocator().get_personality() == personality02 ); + VERIFY( vec02.get_allocator().get_personality() == personality01 ); + + my_vector vec03(alloc02); + size01 = vec03.size(); + personality01 = vec03.get_allocator().get_personality(); + my_vector vec04(title02, title02 + N2, alloc01); + size02 = vec04.size(); + personality02 = vec04.get_allocator().get_personality(); + + vec03.swap(vec04); + VERIFY( vec03.size() == size02 ); + VERIFY( equal(vec03.begin(), vec03.end(), title02) ); + VERIFY( vec04.size() == size01 ); + VERIFY( vec04.empty() ); + VERIFY( vec03.get_allocator().get_personality() == personality02 ); + VERIFY( vec04.get_allocator().get_personality() == personality01 ); + + my_vector vec05(title01, title01 + N1, alloc01); + size01 = vec05.size(); + personality01 = vec05.get_allocator().get_personality(); + my_vector vec06(title02, title02 + N2, alloc02); + size02 = vec06.size(); + personality02 = vec06.get_allocator().get_personality(); + + vec05.swap(vec06); + VERIFY( vec05.size() == size02 ); + VERIFY( equal(vec05.begin(), vec05.end(), title02) ); + VERIFY( vec06.size() == size01 ); + VERIFY( equal(vec06.begin(), vec06.end(), title01) ); + VERIFY( vec05.get_allocator().get_personality() == personality02 ); + VERIFY( vec06.get_allocator().get_personality() == personality01 ); + + my_vector vec07(title01, title01 + N1, alloc02); + size01 = vec07.size(); + personality01 = vec07.get_allocator().get_personality(); + my_vector vec08(title03, title03 + N3, alloc01); + size02 = vec08.size(); + personality02 = vec08.get_allocator().get_personality(); + + vec07.swap(vec08); + VERIFY( vec07.size() == size02 ); + VERIFY( equal(vec07.begin(), vec07.end(), title03) ); + VERIFY( vec08.size() == size01 ); + VERIFY( equal(vec08.begin(), vec08.end(), title01) ); + VERIFY( vec07.get_allocator().get_personality() == personality02 ); + VERIFY( vec08.get_allocator().get_personality() == personality01 ); + + my_vector vec09(title03, title03 + N3, alloc01); + size01 = vec09.size(); + personality01 = vec09.get_allocator().get_personality(); + my_vector vec10(title04, title04 + N4, alloc02); + size02 = vec10.size(); + personality02 = vec10.get_allocator().get_personality(); + + vec09.swap(vec10); + VERIFY( vec09.size() == size02 ); + VERIFY( equal(vec09.begin(), vec09.end(), title04) ); + VERIFY( vec10.size() == size01 ); + VERIFY( equal(vec10.begin(), vec10.end(), title03) ); + VERIFY( vec09.get_allocator().get_personality() == personality02 ); + VERIFY( vec10.get_allocator().get_personality() == personality01 ); + + my_vector vec11(title04, title04 + N4, alloc02); + size01 = vec11.size(); + personality01 = vec11.get_allocator().get_personality(); + my_vector vec12(title01, title01 + N1, alloc01); + size02 = vec12.size(); + personality02 = vec12.get_allocator().get_personality(); + + vec11.swap(vec12); + VERIFY( vec11.size() == size02 ); + VERIFY( equal(vec11.begin(), vec11.end(), title01) ); + VERIFY( vec12.size() == size01 ); + VERIFY( equal(vec12.begin(), vec12.end(), title04) ); + VERIFY( vec11.get_allocator().get_personality() == personality02 ); + VERIFY( vec12.get_allocator().get_personality() == personality01 ); + + my_vector vec13(title03, title03 + N3, alloc01); + size01 = vec13.size(); + personality01 = vec13.get_allocator().get_personality(); + my_vector vec14(title03, title03 + N3, alloc02); + size02 = vec14.size(); + personality02 = vec14.get_allocator().get_personality(); + + vec13.swap(vec14); + VERIFY( vec13.size() == size02 ); + VERIFY( equal(vec13.begin(), vec13.end(), title03) ); + VERIFY( vec14.size() == size01 ); + VERIFY( equal(vec14.begin(), vec14.end(), title03) ); + VERIFY( vec13.get_allocator().get_personality() == personality02 ); + VERIFY( vec14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/profile/vector.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/profile/vector.cc new file mode 100644 index 000000000..7806fb24b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/profile/vector.cc @@ -0,0 +1,24 @@ +// Test vector: performance difference 25% (0.444s vs 0.539s) +// Advice: set tmp as 10000 + +// { dg-options "-DITERATIONS=20" { target simulator } } + +#ifndef ITERATIONS +#define ITERATIONS 2000 +#endif + +#include <vector> + +using std::vector; + +int main() +{ + vector <int> tmp; + + for (int j=0; j<ITERATIONS; j++) + // Insert more than default item + for (int i=0; i<10000; i++) { + tmp.push_back(i); + } +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/range_access.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/range_access.cc new file mode 100644 index 000000000..bddb9ce1e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/range_access.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// 24.6.5, range access [iterator.range] + +#include <vector> + +void +test01() +{ + std::vector<double> v{1.0, 2.0, 3.0}; + std::begin(v); + std::end(v); + + std::vector<bool> vb{true, false, true}; + std::begin(vb); + std::end(vb); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/citerators.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/citerators.cc new file mode 100644 index 000000000..f0c4b1dc0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <testsuite_containers.h> + +int main() +{ + typedef std::vector<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/do_the_right_thing.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/do_the_right_thing.cc new file mode 100644 index 000000000..cd72177e6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/do_the_right_thing.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> + +// libstdc++/43813 +void test01() +{ + std::vector<double*> v(7, 0); + v.assign(7, 0); + v.insert(v.begin(), 7, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..191fbc7bf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -0,0 +1,34 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1320 } + +#include <vector> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::vector<A> v; + v.assign(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor.cc new file mode 100644 index 000000000..6676e3326 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor.cc @@ -0,0 +1,27 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <vector> + +void f() +{ + std::vector<int> v(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..8818a88cc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,28 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1246 } + +#include <vector> + +void f() +{ + std::vector<std::vector<int> > v(10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..09499bcba --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,29 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1246 } + +#include <vector> +#include <utility> + +void f() +{ + std::vector<std::vector<std::pair<char, char> > > v('a', 'b'); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..674e3b5d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -0,0 +1,34 @@ +// 2007-04-27 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1361 } + +#include <vector> + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + std::vector<A> v; + v.insert(v.begin(), 10, 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/basic.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/basic.cc new file mode 100644 index 000000000..704ab75c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/basic.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::vector<value_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/generation_prohibited.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..cf77bc8c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/generation_prohibited.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::vector<value_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/propagation_consistent.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..d065662cf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/exception/propagation_consistent.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <vector> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::vector<value_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..91495ccf9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <vector> + +// { dg-do compile } + +template class std::vector<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..651120815 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <vector> + +template class std::vector<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..edd81a9ff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/2.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <vector> +#include <testsuite_api.h> + +// { dg-do compile } + +// N.B. In C++0x mode we cannot instantiate with T == NonDefaultConstructible +// because of 23.4.1.1.4 +#if __cplusplus < 201103L +template class std::vector<__gnu_test::NonDefaultConstructible>; +#endif diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/3.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..edc70b6e8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests explicit instantiation of library containers + +#include <vector> + +// { dg-do compile } + +// libstdc++/21770 +template class std::vector<int, std::allocator<char> >; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..59c220766 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/explicit_instantiation/4.cc @@ -0,0 +1,29 @@ +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +// This file tests explicit instantiation of library containers + +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// { dg-do compile } + +// libstdc++/41792 +template class std::vector<__gnu_test::OverloadedAddress>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/partial_specialization/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..d0ec136e8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/partial_specialization/1.cc @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2014 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 +// <http://www.gnu.org/licenses/>. + + +// This file tests user specialization of library containers + +#include <vector> +#include <testsuite_hooks.h> + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template<typename Allocator> + class vector<user_type, Allocator> {}; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/typedefs.cc new file mode 100644 index 000000000..0de83b5c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <testsuite_containers.h> +#include <vector> + +// Check container for required typedefs. +__gnu_test::types<std::vector<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/1.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/1.cc new file mode 100644 index 000000000..31918903c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/1.cc @@ -0,0 +1,41 @@ +// 2005-12-01 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +#include <vector> +#include <testsuite_greedy_ops.h> + +int main() +{ + std::vector<greedy_ops::X> v(5); + const std::vector<greedy_ops::X> w(1); + + v[0]; + w[0]; + v.size(); + v.capacity(); + v.resize(1); + v.insert(v.begin(), greedy_ops::X()); + v.insert(v.begin(), 1, greedy_ops::X()); + v.insert(v.begin(), w.begin(), w.end()); + v = w; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/23767.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/23767.cc new file mode 100644 index 000000000..cdaf1c0f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/types/23767.cc @@ -0,0 +1,43 @@ +// 2005-09-12 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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 +// <http://www.gnu.org/licenses/>. +// + +// { dg-do compile } + +#include <vector> + +struct T +{ + typedef std::vector<int> Vector; + typedef Vector::iterator iterator; + typedef Vector::const_iterator const_iterator; + + int t(iterator f) { return *f; } + int t(const_iterator f) const { return *f; } +}; + +// libstdc++/23767 +void f() +{ + std::vector<int> v; + T t; + T::const_iterator i = v.begin(); + + t.t(i); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc new file mode 100644 index 000000000..29bb3ef94 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. +// + +#include <vector> +#include <cstdlib> +#include <testsuite_hooks.h> + +unsigned int zero_sized_news = 0; + +void *operator new(size_t size) throw (std::bad_alloc) +{ + /* malloc(0) is unpredictable; avoid it. */ + if (size == 0) + { + size = 1; + ++zero_sized_news; + } + + void *p = std::malloc(size); + + if (p == 0) + throw std::bad_alloc(); + + return p; +} + +void operator delete(void *ptr) throw() +{ + if (ptr != 0) + std::free(ptr); +} + +// http://gcc.gnu.org/ml/libstdc++/2007-09/msg00006.html +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<std::vector<int> > *v; + VERIFY( zero_sized_news == 0 ); + + v = new std::vector<std::vector<int> >; + VERIFY( zero_sized_news == 0 ); + + v->resize(10); + delete(v); + VERIFY( zero_sized_news == 0 ); +} + +int main() +{ + test01(); + return 0; +} |