]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_next_permutation.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_next_permutation.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #define BOOST_TEST_MODULE TestNextPermutation
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/functional.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/next_permutation.hpp>
18 #include <boost/compute/container/vector.hpp>
19
20 #include "check_macros.hpp"
21 #include "context_setup.hpp"
22
23 namespace bc = boost::compute;
24
25 BOOST_AUTO_TEST_CASE(next_permutation_int)
26 {
27 int dataset[] = {1, 3, 4, 2, 5};
28 bc::vector<bc::int_> vector(dataset, dataset + 5, queue);
29
30 bool result =
31 bc::next_permutation(vector.begin(), vector.begin() + 5, queue);
32
33 CHECK_RANGE_EQUAL(int, 5, vector, (1, 3, 4, 5, 2));
34 BOOST_VERIFY(result == true);
35
36 vector[0] = 10; vector[1] = 9; vector[2] = 6;
37
38 result = bc::next_permutation(vector.begin(), vector.begin() + 5, queue);
39
40 CHECK_RANGE_EQUAL(int, 5, vector, (2, 5, 6, 9, 10));
41 BOOST_VERIFY(result == false);
42 }
43
44 BOOST_AUTO_TEST_CASE(next_permutation_string)
45 {
46 char dataset[] = "aaab";
47 bc::vector<bc::char_> vector(dataset, dataset + 4, queue);
48
49 bool result =
50 bc::next_permutation(vector.begin(), vector.begin() + 4, queue);
51
52 CHECK_RANGE_EQUAL(char, 4, vector, ('a', 'a', 'b', 'a'));
53 BOOST_VERIFY(result == true);
54
55 result = bc::next_permutation(vector.begin(), vector.begin() + 4, queue);
56
57 CHECK_RANGE_EQUAL(char, 4, vector, ('a', 'b', 'a', 'a'));
58 BOOST_VERIFY(result == true);
59
60 result = bc::next_permutation(vector.begin(), vector.begin() + 4, queue);
61
62 CHECK_RANGE_EQUAL(char, 4, vector, ('b', 'a', 'a', 'a'));
63 BOOST_VERIFY(result == true);
64
65 result = bc::next_permutation(vector.begin(), vector.begin() + 4, queue);
66
67 CHECK_RANGE_EQUAL(char, 4, vector, ('a', 'a', 'a', 'b'));
68 BOOST_VERIFY(result == false);
69 }
70
71 BOOST_AUTO_TEST_SUITE_END()