diff options
Diffstat (limited to 'libstdc++-v3')
89 files changed, 5219 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index abf35d8..d84060a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,133 @@ +2005-05-24 Paolo Carlini <pcarlini@suse.de> + + * testsuite/25_algorithms/equal.cc: Move to... + * testsuite/25_algorithms/equal: ... here. + * testsuite/25_algorithms/lower_bound.cc: Move to... + * testsuite/25_algorithms/lower_bound: ... here. + +2005-05-24 Paolo Carlini <pcarlini@suse.de> + + Port from libstdcxx_so_7-branch: + 2005-20-05 Chris Jefferson <chris@bubblescope.net> + + * testsuite/25_algorithms/heap.cc: Move to... + * testsuite/25_algorithms/heap/heap.cc: ...here. + * testsuite/25_algorithms/partition.cc: Move to... + * testsuite/25_algorithms/partition/partition.cc: ...here. + + 2005-03-29 Christopher Jefferson <chris@bubblescope.net> + + * testsuite/25_algorithms/includes/1.cc: Add tests. + * testsuite/25_algorithms/search/1.cc: Likewise. + * testsuite/25_algorithms/unique_copy/1.cc: Likewise. + * testsuite/25_algorithms/swap_ranges/1.cc: New. + * testsuite/25_algorithms/swap_ranges/check_type.cc: New. + * testsuite/25_algorithms/rotate.cc: Move to... + * testsuite/25_algorithms/rotate/rotate.cc: ... here. + * testsuite/25_algorithms/rotate/1.cc: New. + * testsuite/25_algorithms/rotate/check_type.cc: New. + * testsuite/25_algorithms/search_n/iterator.cc: Fix typo. + + 2005-03-14 Christopher Jefferson <chris@bubblescope.net> + + * include/bits/stl_algo.h (replace_copy, replace_copy_if): + Don't assume that __new_value and *__first are convertible to + each other. + + * testsuite/25_algorithms/find/1.cc: New. + * testsuite/25_algorithms/find/check_type.cc: New. + * testsuite/25_algorithms/find_if/1.cc: New. + * testsuite/25_algorithms/find_if/check_type.cc: New. + * testsuite/25_algorithms/replace/1.cc: New. + * testsuite/25_algorithms/replace/check_type.cc: New. + * testsuite/25_algorithms/replace_if/1.cc: New. + * testsuite/25_algorithms/replace_if/check_type.cc: New. + * testsuite/25_algorithms/replace_copy/1.cc: New. + * testsuite/25_algorithms/replace_copy/check_type.cc: New. + * testsuite/25_algorithms/replace_copy_if/1.cc: New. + * testsuite/25_algorithms/replace_copy_if/check_type.cc: New. + * testsuite/25_algorithms/remove/1.cc: New. + * testsuite/25_algorithms/remove/check_type.cc: New. + * testsuite/25_algorithms/remove_if/1.cc: New. + * testsuite/25_algorithms/remove_if/check_type.cc: New. + * testsuite/25_algorithms/count/1.cc: New. + * testsuite/25_algorithms/count/check_type.cc: New. + * testsuite/25_algorithms/count_if/1.cc: New. + * testsuite/25_algorithms/count_if/check_type.cc: New. + + 2005-02-27 Christopher Jefferson <chris@bubblescope.net> + Paolo Carlini <pcarlini@suse.de> + + * testsuite/ext/is_heap/check_type.cc: New. + + 2005-02-27 Paolo Carlini <pcarlini@suse.de> + + * testsuite/ext/is_heap/1.cc: New. + + 2005-02-01 Christopher Jefferson <chris@bubblescope.net> + + * testsuite/ext/median.cc: New. + * testsuite/25_algorithms/adjacent_find/1.cc: New. + * testsuite/25_algorithms/adjacent_find/check_type.cc: New. + * testsuite/25_algorithms/search/1.cc: New. + * testsuite/25_algorithms/search/check_type.cc: New. + * testsuite/25_algorithms/unique_copy/1.cc: New. + * testsuite/25_algorithms/unique_copy/check_type.cc: New. + * testsuite/25_algorithms/partial_sort/1.cc: New. + * testsuite/25_algorithms/partial_sort/check_type.cc: New. + * testsuite/25_algorithms/partial_sort_copy/1.cc: New. + * testsuite/25_algorithms/partial_sort_copy/check_type.cc: New. + * testsuite/25_algorithms/lower_bound/1.cc: New. + * testsuite/25_algorithms/lower_bound/check_type.cc: New. + * testsuite/25_algorithms/upper_bound/1.cc: New. + * testsuite/25_algorithms/upper_bound/check_type.cc: New. + * testsuite/25_algorithms/merge/1.cc: New. + * testsuite/25_algorithms/merge/check_type.cc: New. + * testsuite/25_algorithms/inplace_merge/1.cc: New. + * testsuite/25_algorithms/inplace_merge/check_type.cc: New. + * testsuite/25_algorithms/stable_sort/1.cc: New. + * testsuite/25_algorithms/stable_sort/check_type.cc: New. + * testsuite/25_algorithms/nth_element/1.cc: New. + * testsuite/25_algorithms/nth_element/check_type.cc: New. + * testsuite/25_algorithms/equal_range/1.cc: New. + * testsuite/25_algorithms/equal_range/check_type.cc: New. + * testsuite/25_algorithms/binary_search/1.cc: New. + * testsuite/25_algorithms/binary_search/check_type.cc: New. + * testsuite/25_algorithms/includes/1.cc: New. + * testsuite/25_algorithms/includes/check_type.cc: New. + * testsuite/25_algorithms/set_union/1.cc: New. + * testsuite/25_algorithms/set_union/check_type.cc: New. + * testsuite/25_algorithms/set_intersection/1.cc: New. + * testsuite/25_algorithms/set_intersection/check_type.cc: New. + * testsuite/25_algorithms/set_difference/1.cc: New. + * testsuite/25_algorithms/set_difference/check_type.cc: New. + * testsuite/25_algorithms/set_symmetric_difference/1.cc: New. + * testsuite/25_algorithms/set_symmetric_difference/check_type.cc: New. + * testsuite/25_algorithms/min_element/1.cc: New. + * testsuite/25_algorithms/min_element/check_type.cc: New. + * testsuite/25_algorithms/max_element/1.cc: New. + * testsuite/25_algorithms/max_element/check_type.cc: New. + * testsuite/25_algorithms/prev_permutation/1.cc: New. + * testsuite/25_algorithms/prev_permutation/check_type.cc: New. + * testsuite/25_algorithms/next_permutation/1.cc: New. + * testsuite/25_algorithms/next_permutation/check_type.cc: New. + * testsuite/25_algorithms/find_first_of/1.cc: New. + * testsuite/25_algorithms/find_first_of/check_type.cc: New. + * testsuite/25_algorithms/find_end/1.cc: New. + * testsuite/25_algorithms/find_end/check_type.cc: New. + * testsuite/25_algorithms/equal/check_type.cc: Insert iterator type. + * testsuite/25_algorithms/lexicographical_compare/check_type.cc: + Likewise. + + 2005-01-10 Christopher Jefferson <chris@bubblescope.net> + + * testsuite/25_algorithms/lexicographical_compare/check_type.cc: New. + * testsuite/25_algorithms/lexicographical_compare/1.cc: Likewise. + * testsuite/25_algorithms/mismatch/check_type.cc: Likewise. + * testsuite/25_algorithms/mismatch/1.cc: Likewise. + * testsuite/25_algorithms/equal/check_type.cc: New. + * testsuite/25_algorithms/equal/1.cc: New. + 2005-05-24 Benjamin Kosnik <bkoz@redhat.com> * include/bits/allocator.h: Change ___glibcxx_base_allocator to diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 469773c..ee73321 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -916,7 +916,10 @@ namespace std __glibcxx_requires_valid_range(__first, __last); for ( ; __first != __last; ++__first, ++__result) - *__result = *__first == __old_value ? __new_value : *__first; + if (*__first == __old_value) + *__result = __new_value; + else + *__result = *__first; return __result; } @@ -950,7 +953,10 @@ namespace std __glibcxx_requires_valid_range(__first, __last); for ( ; __first != __last; ++__first, ++__result) - *__result = __pred(*__first) ? __new_value : *__first; + if (__pred(*__first)) + *__result = __new_value; + else + *__result = *__first; return __result; } diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc new file mode 100644 index 0000000..fcce4b5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.adjacent_find] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::adjacent_find; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; + +void +test01() +{ + Container con(array, array); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test02() +{ + Container con(array, array + 1); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 1); +} + +void +test03() +{ + Container con(array, array + 2); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test04() +{ + Container con(array + 1, array + 10); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 10); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc new file mode 100644 index 0000000..65f725d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.adjacent_find] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator==(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::adjacent_find(s, s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::adjacent_find(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc new file mode 100644 index 0000000..5ee4441 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.4 [lib.binary.search] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::binary_search; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + int array[] = {0}; + Container con(array, array); + VERIFY(!binary_search(con.begin(), con.end(), 1)); +} + +void +test2() +{ + int array[] = {0, 2, 4, 6, 8}; + Container con(array, array + 5); + for(int i = 0; i < 10; i += 2) + VERIFY(binary_search(con.begin(), con.end(), i)); + for(int i = -1; i < 11; i += 2) + VERIFY(!binary_search(con.begin(), con.end(), i)); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc new file mode 100644 index 0000000..853a6d2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.4 [lib.binary.search] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +bool +test1(forward_iterator_wrapper<S>& s) +{ return std::binary_search(s, s, *s); } + +bool +test2(forward_iterator_wrapper<X>& x) +{ return std::binary_search(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count/1.cc b/libstdc++-v3/testsuite/25_algorithms/count/1.cc new file mode 100644 index 0000000..dec293c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.6 count + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count(con.begin(), con.end(), 1) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc new file mode 100644 index 0000000..389c8a0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +struct Y { }; + +using __gnu_test::input_iterator_wrapper; + +bool +operator==(const X&, const Y&) +{ return true; } + +typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count(begin, end, Y()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc new file mode 100644 index 0000000..d5e626f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.6 count_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc new file mode 100644 index 0000000..8530985 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count_if(begin, end, pred_function); } + +diff_type +test2(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc new file mode 100644 index 0000000..9a17c02 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0}; + +void test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test4() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test5() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::equal(con3.begin(), con3.end(), con2.begin()) ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc new file mode 100644 index 0000000..434d722 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.8 [lib.alg.equal] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool +predicate(const Lhs2&, const Rhs2&) {return true;} + +bool +test1(input_iterator_wrapper<Lhs1>& lhs1, + input_iterator_wrapper<Rhs1>& rhs1) +{ return std::equal(lhs1, lhs1, rhs1); } + +bool +test2(input_iterator_wrapper<Lhs2>& lhs2, + input_iterator_wrapper<Rhs2>& rhs2) +{ return std::equal(lhs2, lhs2, rhs2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal.cc b/libstdc++-v3/testsuite/25_algorithms/equal/equal.cc index abb0446..abb0446 100644 --- a/libstdc++-v3/testsuite/25_algorithms/equal.cc +++ b/libstdc++-v3/testsuite/25_algorithms/equal/equal.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc new file mode 100644 index 0000000..9a843e7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.3 [lib.equal.range] + +#include <algorithm> +#include <utility> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::equal_range; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; + +void +test1() +{ + for(int i = 0; i < 6; ++i) + for(int j = 6; j < 12; ++j) + { + Container con(array + i, array + j); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + std::max(i, 4)); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + std::min(j, 8)); + } +} + +void +test2() +{ + int array[]={0, 0, 2, 2, 2}; + Container con(array, array + 5); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + 2); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc new file mode 100644 index 0000000..6a299c7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.3 [lib.equal.range] + +// { dg-do compile } + +#include <algorithm> +#include <utility> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +std::pair<forward_iterator_wrapper<S>, forward_iterator_wrapper<S> > +test1(forward_iterator_wrapper<S>& s) +{ return std::equal_range(s, s, *s); } + +std::pair<forward_iterator_wrapper<X>, forward_iterator_wrapper<X> > +test2(forward_iterator_wrapper<X>& x) +{ return std::equal_range(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find/1.cc b/libstdc++-v3/testsuite/25_algorithms/find/1.cc new file mode 100644 index 0000000..19eb177 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 1); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc new file mode 100644 index 0000000..40bfee8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs { }; +struct Rhs { }; + +bool +operator==(const Lhs&, const Rhs&) +{ return true; } + +input_iterator_wrapper<Lhs> +test1(input_iterator_wrapper<Lhs>& begin, + input_iterator_wrapper<Lhs>& end, Rhs& val) +{ return std::find(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc new file mode 100644 index 0000000..9120e18 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.3 [lib.alg.find.end] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +using std::find_end; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_end(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_end(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {2, 2, 1, 2, 2, 1}; + int array2[] = {2, 2}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 2); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 3); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc new file mode 100644 index 0000000..1d998a7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.3 [lib.alg.find.end] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<Lhs1> +test1(forward_iterator_wrapper<Lhs1>& lhs1, + forward_iterator_wrapper<Rhs1>& rhs1) +{ + return std::find_end(lhs1, lhs1, rhs1, rhs1); +} + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, + forward_iterator_wrapper<X2>& x2) +{ + return std::find_end(x1, x1, x2, x2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc new file mode 100644 index 0000000..db441bd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.4 [lib.alg.find.first.of] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +using std::find_first_of; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_first_of(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_first_of(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {1 ,2, 3, 4, 5, 6}; + int array2[] = {3, 4, 9}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 3); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc new file mode 100644 index 0000000..9a075c9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.4 [lib.alg.find.first.of] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<Lhs1> +test1(forward_iterator_wrapper<Lhs1>& lhs1, + forward_iterator_wrapper<Rhs1>& rhs1) +{ return std::find_first_of(lhs1, lhs1, rhs1, rhs1); } + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, + forward_iterator_wrapper<X2>& x2) +{ return std::find_first_of(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc new file mode 100644 index 0000000..c1d9255 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array + 1); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array + 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc new file mode 100644 index 0000000..8d56be9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +input_iterator_wrapper<X> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::find_if(begin, end, pred_function); } + +input_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::find_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/heap.cc b/libstdc++-v3/testsuite/25_algorithms/heap/heap.cc index 6d564f2..6d564f2 100644 --- a/libstdc++-v3/testsuite/25_algorithms/heap.cc +++ b/libstdc++-v3/testsuite/25_algorithms/heap/heap.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/1.cc b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc new file mode 100644 index 0000000..88d1d2b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.1 [lib.includes] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using std::includes; + +typedef test_container<int, input_iterator_wrapper> Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[] = {0}; + Container con1(array, array); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array); + Container con2(array, array + 2); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array + 2); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 4, 6, 8, 9}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 7); + Container con2(array2, array2 + 4); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 5}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 4); + Container con2(array2, array2 + 4); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc new file mode 100644 index 0000000..4b1198e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.1 [lib.includes] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) +{ return true; } + +struct X { }; + +bool +predicate(const X&, const X&) +{ return true; } + +bool +test1(input_iterator_wrapper<S>& s) +{ return std::includes(s, s, s, s); } + +bool +test2(input_iterator_wrapper<X>& x) +{ return std::includes(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc new file mode 100644 index 0000000..f53c47e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::inplace_merge; + +typedef test_container<int, bidirectional_iterator_wrapper> container; + + +void +test1() +{ + int array[]={1}; + container con1(array, array); + inplace_merge(con1.begin(), con1.end(), con1.end()); + container con2(array, array + 1); + inplace_merge(con2.begin(), con2.end(), con2.end()); + inplace_merge(con2.begin(), con2.begin(), con2.end()); +} + +void +test2() +{ + int array[]={0,2,4,1,3,5}; + container con(array, array + 6); + inplace_merge(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4 && array[5] == 5); +} + +struct S +{ + int a; + int b; + S(int _a, int _b) : a(_a), b(_b) { } + S() { } + bool + operator<(const S& _s) const + { return _s.a < a; } +}; + +void +test3() +{ + S s[4]; + s[0].a = 0; + s[1].a = 1; + s[2].a = 0; + s[3].a = 1; + s[0].b = 0; + s[1].b = 0; + s[2].b = 1; + s[3].b = 1; + inplace_merge(s, s + 2, s + 4); + VERIFY(s[0].b == 0 && s[1].b == 1 && s[2].b == 0 && s[3].b == 1); +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc new file mode 100644 index 0000000..f8cacfa --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(bidirectional_iterator_wrapper<S>& s) +{ + std::inplace_merge(s, s, s); +} + +void +test2(bidirectional_iterator_wrapper<X>& x) +{ + std::inplace_merge(x, x, x, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc new file mode 100644 index 0000000..8d38dad --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.8 [lib.alg.lex.comparison] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void +test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( !std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con2.begin(), con2.end(), + con1.begin(), con1.end()) ); +} + +void +test4() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con2.begin(), con2.end(), + con3.begin(), con3.end()) ); +} + +void +test5() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con3.begin(), con3.end(), + con2.begin(), con2.end()) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc new file mode 100644 index 0000000..20b594c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.8 [lib.alg.lex.comparison] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool +operator<(const Lhs1&, const Rhs1&) {return true;} + +bool +operator<(const Rhs1&, const Lhs1&) {return false;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(input_iterator_wrapper<Lhs1>& lhs1, + input_iterator_wrapper<Rhs1>& rhs1) +{ return std::lexicographical_compare(lhs1, lhs1, rhs1, rhs1); } + +bool +test2(input_iterator_wrapper<X>& x) +{ return std::lexicographical_compare(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc new file mode 100644 index 0000000..baa00c1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.1 [lib.lower.bound] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::lower_bound; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(lower_bound(con.begin(), con.end(), 1).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc new file mode 100644 index 0000000..1ba48d3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.1 [lib.lower.bound] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::lower_bound(s, s, *s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::lower_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/lower_bound.cc index 6afb28f..6afb28f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/lower_bound.cc +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/lower_bound.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc new file mode 100644 index 0000000..02d870b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::max_element; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {0, 3, 6, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(max_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc new file mode 100644 index 0000000..f6bae76 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::max_element(s, s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::max_element(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc new file mode 100644 index 0000000..c0ccd78 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc @@ -0,0 +1,101 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::merge; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[]={0,1,4}; + int array2[]={2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 3); + Icontainer con2(array2, array2 + 2); + Ocontainer con3(array3, array3 + 5); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); + +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + S array1[] = { -1 , -3}; + S array2[] = { 1, 2, 3}; + S array3[5]; + merge(array1, array1 + 2, array2, array2 + 3, array3); + VERIFY(array3[0].j == 0 && array3[1].j == 1 && array3[2].j == 1 && + array3[3].j == 0 && array3[4].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc new file mode 100644 index 0000000..27681d8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, + output_iterator_wrapper<S>& out) +{ return std::merge(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, + output_iterator_wrapper<X>& out) +{ return std::merge(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc new file mode 100644 index 0000000..ba9a4a2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::min_element; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {6, 3, 0, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(min_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc new file mode 100644 index 0000000..e4ff8d3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::min_element(s,s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::min_element(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc new file mode 100644 index 0000000..a754059 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.7 [lib.mismatch] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void test1a() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test1b() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test2a() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test2b() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test3a() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).first.ptr + == array3 + 2 ); +} + +void test3b() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).second.ptr + == array2 + 2 ); +} + +int main() +{ + test1a(); + test1b(); + test2a(); + test2b(); + test3a(); + test3b(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc new file mode 100644 index 0000000..45f4629 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.7 [lib.mismatch] + +// { dg-do compile } + +#include <algorithm> +#include <utility> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool predicate(const Lhs2&, const Rhs2&) {return true;} + +std::pair<input_iterator_wrapper<Lhs1>, input_iterator_wrapper<Rhs1> > +test1(input_iterator_wrapper<Lhs1>& lhs1, input_iterator_wrapper<Rhs1>& rhs1) +{ + return std::mismatch(lhs1, lhs1, rhs1); +} + +std::pair<input_iterator_wrapper<Lhs2>, input_iterator_wrapper<Rhs2> > +test2(input_iterator_wrapper<Lhs2>& lhs2, input_iterator_wrapper<Rhs2>& rhs2) +{ + return std::mismatch(lhs2, lhs2, rhs2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc new file mode 100644 index 0000000..4c0496c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::next_permutation; + +typedef test_container<int, bidirectional_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); + VERIFY(!next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); +} + +void +test4() +{ + int array[6] = {0, 1, 2, 3, 4, 5}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(next_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6)); + } + VERIFY(!next_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc new file mode 100644 index 0000000..15aff15 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper<S>& s) +{ return std::next_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper<X>& x) +{ return std::next_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc new file mode 100644 index 0000000..469e64b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.2 [lib.alg.nth.element] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::nth_element; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + partial_sort(con.begin(), con.begin(), con.end()); +} + +void +test2() +{ + int array[]={2,1,0}; + Container con(array, array + 2); + partial_sort(con.begin(), con.begin(), con.end()); + partial_sort(con.begin(), con.end(), con.end()); +} + +void +test3() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +void +test4() +{ + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc new file mode 100644 index 0000000..3fd1eba --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.2 [lib.alg.nth.element] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ std::nth_element(s, s, s); } + +void +test2(random_access_iterator_wrapper<X>& x) +{ std::nth_element(x, x, x, predicate); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc new file mode 100644 index 0000000..35c64ca --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.3 [lib.partial.sort] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::partial_sort; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={2,1,0}; + Container con1(array, array + 2); + Container con2(array, array); + partial_sort(con2.begin(), con2.begin(), con2.end()); + partial_sort(con1.begin(), con1.begin(), con1.end()); + partial_sort(con1.begin(), con1.end(), con1.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +void +test3() +{ + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc new file mode 100644 index 0000000..1a6a2e0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.3 [lib.partial.sort] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ + std::partial_sort(s, s, s); +} + +void +test2(random_access_iterator_wrapper<X>& x) +{ + std::partial_sort(x, x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc new file mode 100644 index 0000000..0b7263d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.4 [lib.partial.sort.copy] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::input_iterator_wrapper; +using std::partial_sort_copy; + +typedef test_container<int, random_access_iterator_wrapper> Rcontainer; +typedef test_container<int, input_iterator_wrapper> Icontainer; + +void +test1() +{ + int array[]={2,1,0}; + Rcontainer rcon1(array, array); + Rcontainer rcon2(array, array + 2); + Icontainer icon1(array, array); + Icontainer icon2(array, array + 2); + partial_sort_copy(icon1.begin(), icon1.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon1.begin(), icon1.end(), rcon2.begin(), rcon2.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon2.begin(), rcon2.end()); +} + +void +test2() +{ + int array1[] = {4, 3, 2, 1, 0}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 5); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +void +test3() +{ + int array1[] = {4, 0, 1, 3, 2}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 2); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +void +test4() +{ + int array1[] = {4, 1, 3, 2, 0}; + int array2[20]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 20); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc new file mode 100644 index 0000000..140f15b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.4 [lib.partial.sort.copy] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; + +struct S1 { }; +struct S2 +{ + S2(const S1&) {} + S2() {} +}; + +bool +operator<(const S1&, const S1&) +{return true;} + +bool +operator<(const S2&, const S2&) +{return true;} + +struct X1 { }; +struct X2 +{ + X2(const X1&) {} + X2() {} +}; + +struct predicate +{ + bool + operator()(const X1&, const X1&) + {return true;} + + bool + operator()(const X2&, const X2&) + {return true;} +}; + +random_access_iterator_wrapper<S2> +test1(input_iterator_wrapper<S1>& s1, random_access_iterator_wrapper<S2>& s2) +{ return std::partial_sort_copy(s1, s1, s2, s2); } + +random_access_iterator_wrapper<X2> +test2(input_iterator_wrapper<X1>& x1, random_access_iterator_wrapper<X2>& x2) +{ return std::partial_sort_copy(x1, x1, x2, x2, predicate()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/partition.cc b/libstdc++-v3/testsuite/25_algorithms/partition/partition.cc index b05c203..b05c203 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partition.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partition/partition.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc new file mode 100644 index 0000000..530e032 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::prev_permutation; + +typedef test_container<int, bidirectional_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); + VERIFY(!prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); +} + +void +test4() +{ + int array[6] = {5, 4, 3, 2, 1, 0}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(prev_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(array, array + 6, + temp_array, temp_array + 6)); + } + VERIFY(!prev_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == 5 - i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc new file mode 100644 index 0000000..f0fafc6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper<S>& s) +{ return std::prev_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper<X>& x) +{ return std::prev_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc new file mode 100644 index 0000000..95ac53c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 remove + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove(con.begin(), con.end(), 0).ptr == array + 1); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc new file mode 100644 index 0000000..46a44de --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.7 Remove + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper<X> +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const Y& val) +{ return std::remove(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc new file mode 100644 index 0000000..b72e024 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 remove + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +bool equal1(int val) { return val == 1; } +bool equal0(int val) { return val == 0; } + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal0).ptr == array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc new file mode 100644 index 0000000..dbcde80 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.7 Remove_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) const + { return true; } +}; + +forward_iterator_wrapper<X> +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end) +{ return std::remove_if(begin, end, pred_fn); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end) +{ return std::remove_if(begin, end, pred_obj()); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc new file mode 100644 index 0000000..4878855 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + std::replace(con.begin(), con.end(), 1, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace(con.begin(), con.end(), 0, 1); + VERIFY(array[0] == 1); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace(con.begin(), con.end(), 1, 2); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 2 && array[4] == 0 && array[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc new file mode 100644 index 0000000..0833421 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 Replace + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +operator==(const X&, const X&) +{ return true; } + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& old_val, + const X& new_val) +{ return std::replace(begin, end, old_val, new_val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc new file mode 100644 index 0000000..ebaea0c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 0, 1).ptr == out + 1); + VERIFY(out[0] == 1); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc new file mode 100644 index 0000000..1a19a16 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { } + + Z& + operator=(const Y&) + { } +}; + +bool +operator==(const X&, const Y&) +{ return true; } + +output_iterator_wrapper<Z> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end, + output_iterator_wrapper<Z>& output, + const Y& old_val, const Y& new_val) +{ + return std::replace_copy(begin, end, output, old_val, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc new file mode 100644 index 0000000..2c9c32d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc @@ -0,0 +1,76 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +pred(int i) +{ return i == 1; } + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 1); + VERIFY(out[0] == 0); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc new file mode 100644 index 0000000..55b9040 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { } + + Z& + operator=(const Y&) + { } +}; + +bool +predicate(const X&) +{ return true; } + +output_iterator_wrapper<Z> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end, + output_iterator_wrapper<Z>& output, + const Y& new_val) +{ + return std::replace_copy_if(begin, end, output, predicate, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc new file mode 100644 index 0000000..98cf1f3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {1, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + std::replace_if(con.begin(), con.end(), predicate, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace_if(con.begin(), con.end(), predicate, 2); + VERIFY(array[0] == 2); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace_if(con.begin(), con.end(), predicate, 3); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 3 && array[4] == 0 && array[5] == 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc new file mode 100644 index 0000000..b8adaec --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& new_val) +{ return std::replace_if(begin, end, pred_fn, new_val); } + +void +test2(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& new_val) +{ return std::replace_if(begin, end, pred_obj(), new_val); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc new file mode 100644 index 0000000..be41d57 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc @@ -0,0 +1,126 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.10 rotate + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.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; + +typedef test_container<int, forward_iterator_wrapper> Fcontainer; +typedef test_container<int, bidirectional_iterator_wrapper> Bcontainer; +typedef test_container<int, random_access_iterator_wrapper> Rcontainer; + + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[]={1}; + Fcontainer fcon(array, array); + Bcontainer bcon(array, array); + Rcontainer rcon(array, array); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {1}; + Fcontainer fcon(array, array + 1); + Bcontainer bcon(array, array + 1); + Rcontainer rcon(array, array + 1); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); + std::rotate(fcon.begin(), fcon.end(), fcon.end()); + std::rotate(bcon.begin(), bcon.end(), bcon.end()); + std::rotate(rcon.begin(), rcon.end(), rcon.end()); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4, 5}; + Fcontainer fcon(array, array + 5); + Bcontainer bcon(array, array + 5); + Rcontainer rcon(array, array + 5); + std::rotate(fcon.begin(), fcon.it(2), fcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 5 && + array[3] == 1 && array[4] == 2); + std::rotate(bcon.begin(), bcon.it(2), bcon.end()); + VERIFY(array[0] == 5 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4); + std::rotate(rcon.begin(), rcon.it(2), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 5 && array[4] == 1); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Fcontainer fcon(array, array + 4); + Bcontainer bcon(array, array + 4); + Rcontainer rcon(array, array + 4); + + std::rotate(fcon.begin(), fcon.it(3), fcon.end()); + VERIFY(array[0] == 4 && array[1] == 1 && array[2] == 2 && + array[3] == 3); + + std::rotate(bcon.begin(), bcon.it(3), bcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); + + std::rotate(rcon.begin(), rcon.it(3), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 1); + +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Rcontainer con(array, array + 4); + std::rotate(con.begin(), con.it(2), con.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc new file mode 100644 index 0000000..31b7123 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.10 Rotate + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +bool operator<(X,X) { return true;} + +void +test1(__gnu_test::forward_iterator_wrapper<X>& begin, + __gnu_test::forward_iterator_wrapper<X>& middle, + __gnu_test::forward_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::bidirectional_iterator_wrapper<X>& begin, + __gnu_test::bidirectional_iterator_wrapper<X>& middle, + __gnu_test::bidirectional_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::random_access_iterator_wrapper<X>& begin, + __gnu_test::random_access_iterator_wrapper<X>& middle, + __gnu_test::random_access_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc index 00768a2..00768a2 100644 --- a/libstdc++-v3/testsuite/25_algorithms/rotate.cc +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/search/1.cc b/libstdc++-v3/testsuite/25_algorithms/search/1.cc new file mode 100644 index 0000000..5a0ed51 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/1.cc @@ -0,0 +1,113 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.search] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::search; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array1[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}; +int array2[] = {0, 0, 0}; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1); + Container con2(array1, array1 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1); + VERIFY(search(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array1); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 3); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 3, array1 + 10); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 6, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test6() +{ + bool test __attribute__((unused)) = true; + int array3[]={2, 2, 1, 2, 3, 5}; + int array4[]={1, 2, 3, 4}; + Container con1(array3, array3 + 3); + Container con2(array3, array3 + 4); + Container con3(array3, array3 + 5); + Container con4(array3, array3 + 6); + Container endcon(array4, array4 + 4); + VERIFY(search(con1.begin(), con1.end(), endcon.begin(), endcon.end()).ptr + == array3 + 3); + VERIFY(search(con2.begin(), con2.end(), endcon.begin(), endcon.end()).ptr + == array3 + 4); + VERIFY(search(con3.begin(), con3.end(), endcon.begin(), endcon.end()).ptr + == array3 + 5); + VERIFY(search(con4.begin(), con4.end(), endcon.begin(), endcon.end()).ptr + == array3 + 6); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc new file mode 100644 index 0000000..9e3a587 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.9 [lib.alg.search] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S1 { }; +struct S2 { }; + +bool +operator==(const S1&, const S2&) {return true;} + +struct X1 { }; +struct X2 { }; + +bool +predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<S1> +test1(forward_iterator_wrapper<S1>& s1, forward_iterator_wrapper<S2>& s2) +{ return std::search(s1, s1, s2, s2); } + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, forward_iterator_wrapper<X2>& x2) +{ return std::search(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc index f822745..fea009d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc @@ -76,7 +76,7 @@ int main() { { test_container<int, forward_iterator_wrapper> forwardcon(array2, array2 + i); - test_container<int, bidirectional_iterator_wrapper> + test_container<int, random_access_iterator_wrapper> randomcon(array2, array2 + i); test_container<int, bidirectional_iterator_wrapper> bidircon(array2, array2 + i); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc new file mode 100644 index 0000000..9d0fbe6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc @@ -0,0 +1,132 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.difference] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_difference; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 3); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 3); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -3, -4}; + S array2[] = { 1, 1, 1, 1, 2, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 7); + SIcontainer con2(array2, array2 + 7); + SOcontainer con3(array3, array3 + 2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + for(int i = 0; i < 2; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc new file mode 100644 index 0000000..43d54ad --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.4 [lib.set.difference] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_difference(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_difference(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc new file mode 100644 index 0000000..d0a648e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc @@ -0,0 +1,132 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.intersection] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_intersection; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + VERIFY(array3[0] == 1 && array3[1] == 2); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[5]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 5); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + for(int i = 0; i < 5; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc new file mode 100644 index 0000000..a1ef6f9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.intersection] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_intersection(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_intersection(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc new file mode 100644 index 0000000..932eb4f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc @@ -0,0 +1,134 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.5 [lib.set.symmetric.difference] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_symmetric_difference; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 4); + Ocontainer con3(array3, array3 + 5); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -2, -2, -4, -5}; + S array2[] = { 1, 1, 1, 2, 3, 4}; + S array3[4]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 6); + SOcontainer con3(array3, array3 + 4); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 4); + VERIFY(array3[0].j == 1 && array3[1].j == 0 && array3[2].j == 1 && + array3[3].j == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc new file mode 100644 index 0000000..c9c63a7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.5 [lib.set.symmetric.difference] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_symmetric_difference(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_symmetric_difference(in, in, in, in, out, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc new file mode 100644 index 0000000..03bfcac --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc @@ -0,0 +1,137 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.2 [lib.set.union] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_union; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 6); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 6); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 1 && + array3[3] == 2 && array3[4] == 3 && array3[5] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 9); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 9); + VERIFY(array3[0].j == 0 && array3[1].j == 0 && array3[2].j == 0 && + array3[3].j == 1 && array3[4].j == 0 && array3[5].j == 0 && + array3[6].j == 1 && array3[7].j == 0 && array3[8].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc new file mode 100644 index 0000000..286de97 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.2 [lib.set.union] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_union(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_union(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc new file mode 100644 index 0000000..659c278 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.2 [lib.stable.sort] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::stable_sort; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + stable_sort(con.begin(), con.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + stable_sort(con.begin(), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4 && array[5] == 5 && + array[6] == 6); +} +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + + S array[] = {-1, -2, 1, 2, -3 ,-5 ,3 , -4, 5, 4}; + test_container<S, random_access_iterator_wrapper> con(array,array + 10); + stable_sort(con.begin(), con.end()); + for(int i = 0; i < 10; ++i) + VERIFY(array[i].j == i % 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc new file mode 100644 index 0000000..8e7c51d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.1 [lib.stable.sort] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ + std::stable_sort(s, s); +} + +void +test2(random_access_iterator_wrapper<X>& x) +{ + std::stable_sort(x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc new file mode 100644 index 0000000..e4a23e2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.2 swap_ranges + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array1[]={1, 2}; + int array2[]={3, 4}; + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY(std::swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == + array2 + 2); + VERIFY(array1[0] == 3 && array1[1] == 4 && array2[0] == 1 && array2[1] == 2); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1}; + int array2[] = {1}; + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY(swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc new file mode 100644 index 0000000..a19d92c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 Swap Ranges + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { +}; + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, + forward_iterator_wrapper<X>& begin2) +{ std::swap_ranges(begin, end, begin2); } diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc new file mode 100644 index 0000000..4f96c3a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.5.8 [lib.alg.unique] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::unique; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, forward_iterator_wrapper> Fcontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +int array1[] = {0, 0, 0, 1, 1, 1}; +int array2[2]; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Ocontainer con2(array2, array2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Ocontainer con2(array2, array2 + 2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Fcontainer con2(array2, array2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Fcontainer con2(array2, array2 + 2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc new file mode 100644 index 0000000..1c6731e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.5.8 [lib.alg.unique_copy] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S1 { }; + +struct S2 +{ + S2(const S1& s1) {} +}; + +bool +operator==(const S1&, const S1&) {return true;} + +struct X1 { }; + +struct X2 +{ + X2(const X1& x1) {} +}; + +bool +predicate(const X1&, const X1&) {return true;} + +output_iterator_wrapper<S2> +test1(input_iterator_wrapper<S1>& s1, output_iterator_wrapper<S2>& s2) +{ return std::unique_copy(s1, s1, s2); } + +output_iterator_wrapper<X2> +test2(input_iterator_wrapper<X1>& x1, output_iterator_wrapper<X2>& x2) +{ return std::unique_copy(x1, x1, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc new file mode 100644 index 0000000..8b518ef --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.2 [lib.upper.bound] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::upper_bound; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(upper_bound(con.begin(), con.end(), 0).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc new file mode 100644 index 0000000..f0c0774 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.2 [lib.upper.bound] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::upper_bound(s, s, *s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::upper_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/ext/is_heap/1.cc b/libstdc++-v3/testsuite/ext/is_heap/1.cc new file mode 100644 index 0000000..3974f03 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/is_heap/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef test_container<int, random_access_iterator_wrapper> container; + +void +test1() +{ + int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + for(int i = 0; i < 10; ++i) + { + container con(array, array + i); + std::make_heap(con.begin(), con.end()); + VERIFY(std::__is_heap(con.begin(), con.end())); + VERIFY(std::__is_heap(con.begin(), i)); + } +} + +int +main() +{ + test1(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/is_heap/check_type.cc b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc new file mode 100644 index 0000000..6c791bd --- /dev/null +++ b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(random_access_iterator_wrapper<S>& start, + random_access_iterator_wrapper<S>& end) +{ return std::__is_heap(start, end) && std::__is_heap(start, 1); } + +bool +test2(random_access_iterator_wrapper<X>& start, + random_access_iterator_wrapper<X>& end) +{ + return std::__is_heap(start, end, predicate) && + std::__is_heap(start, predicate, 1); +} diff --git a/libstdc++-v3/testsuite/ext/median.cc b/libstdc++-v3/testsuite/ext/median.cc new file mode 100644 index 0000000..97e44ea --- /dev/null +++ b/libstdc++-v3/testsuite/ext/median.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// median - SGI extension + +#include <algorithm> +#include <testsuite_hooks.h> + +bool pred(const int& l, const int& r) +{ + return l<r; +} + +using std::__median; + +int main(void) +{ + const int i=1; + const int j=2; + const int k=3; + VERIFY(__median(i, j, k) == j && __median(i, j, k, pred) == j); + VERIFY(__median(i, k, j) == j && __median(i, k, j, pred) == j); + VERIFY(__median(j, i, k) == j && __median(j, i, k, pred) == j); + VERIFY(__median(j, k, i) == j && __median(j, k, i, pred) == j); + VERIFY(__median(k, i, j) == j && __median(k, i, j, pred) == j); + VERIFY(__median(k, j, i) == j && __median(k, j, i, pred) == j); +} |