gcc/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc

127 lines
3.7 KiB
C++
Raw Normal View History

[multiple changes] 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. From-SVN: r100127
2005-05-25 00:53:43 +02:00
// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
[multiple changes] 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. From-SVN: r100127
2005-05-25 00:53:43 +02:00
// 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();
}