diff options
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms')
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc (renamed from libstdc++-v3/testsuite/25_algorithms/fill/5.cc) | 0 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc | 52 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc | 56 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc | 79 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc | 64 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc | 59 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc | 62 |
7 files changed, 372 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/5.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc index edabe1fcc29..edabe1fcc29 100644 --- a/libstdc++-v3/testsuite/25_algorithms/fill/5.cc +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc new file mode 100644 index 00000000000..4b07a63edee --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array[]={0,2,4,1,3,5}; + rvalstruct rv_array[6]; + std::copy(array, array + 6, rv_array); + container con(rv_array, rv_array + 6); + std::inplace_merge(con.begin(), con.it(3), con.end()); + VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2 + && rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc new file mode 100644 index 00000000000..32ab3c70c6b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container; + +bool +are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array[]={0,2,4,1,3,5}; + rvalstruct rv_array[6]; + std::copy(array, array + 6, rv_array); + container con(rv_array, rv_array + 6); + std::inplace_merge(con.begin(), con.it(3), con.end(), are_ordered); + VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2 + && rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc new file mode 100644 index 00000000000..d48d6029a52 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.2.10 rotate + +// Tests rotate when an moveable class is used + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, forward_iterator_wrapper> Fcontainer; +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> Bcontainer; +typedef test_container<rvalstruct, random_access_iterator_wrapper> Rcontainer; + +template<typename Con> + void + test_con(int length, int rotate_pos) + { + bool test __attribute__((unused)) = true; + + rvalstruct array[length]; + for(int i = 0; i < length; ++i) + array[i] = i; + Con con(array, array + length); + std::rotate(con.begin(), con.it(rotate_pos), con.end()); + + if(length != 0) + { + for(int i = 0; i < length; ++i) + VERIFY( array[i].valid && array[i].val == (i + rotate_pos) % length ); + } + } + +void +test01() +{ + for(int i = 0; i < 20; ++i) + { + for(int j = 0; j <= i; ++j) + { + test_con<Fcontainer>(i, j); + test_con<Bcontainer>(i, j); + test_con<Rcontainer>(i, j); + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc new file mode 100644 index 00000000000..193f1312849 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include <algorithm> +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +struct Pred +{ + bool + operator()(const rvalstruct& x) const + { return (x.val % 2) == 0; } +}; + +// 25.2.12 stable_partition() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + + std::stable_partition(con.begin(), con.end(), Pred()); + VERIFY( std::equal(s1, s1 + N, B) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc new file mode 100644 index 00000000000..09d6129c06c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end()); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc new file mode 100644 index 00000000000..86ff353967d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +bool order(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end(), order); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} |