]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_prev_permutation.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #define BOOST_TEST_MODULE TestPrevPermutation
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/functional.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/prev_permutation.hpp>
18 #include <boost/compute/container/vector.hpp>
20 #include "check_macros.hpp"
21 #include "context_setup.hpp"
23 namespace bc
= boost::compute
;
25 BOOST_AUTO_TEST_CASE(prev_permutation_int
)
27 int dataset
[] = {1, 3, 4, 2, 5};
28 bc::vector
<bc::int_
> vector(dataset
, dataset
+ 5, queue
);
31 bc::prev_permutation(vector
.begin(), vector
.begin() + 5, queue
);
33 CHECK_RANGE_EQUAL(int, 5, vector
, (1, 3, 2, 5, 4));
34 BOOST_VERIFY(result
== true);
36 vector
[1] = 1; vector
[4] = 6;
38 result
= bc::prev_permutation(vector
.begin(), vector
.begin() + 5, queue
);
40 CHECK_RANGE_EQUAL(int, 5, vector
, (6, 5, 2, 1, 1));
41 BOOST_VERIFY(result
== false);
44 BOOST_AUTO_TEST_CASE(prev_permutation_string
)
46 char dataset
[] = "baaa";
47 bc::vector
<bc::char_
> vector(dataset
, dataset
+ 4, queue
);
50 bc::prev_permutation(vector
.begin(), vector
.begin() + 4, queue
);
52 CHECK_RANGE_EQUAL(char, 4, vector
, ('a', 'b', 'a', 'a'));
53 BOOST_VERIFY(result
== true);
55 result
= bc::prev_permutation(vector
.begin(), vector
.begin() + 4, queue
);
57 CHECK_RANGE_EQUAL(char, 4, vector
, ('a', 'a', 'b', 'a'));
58 BOOST_VERIFY(result
== true);
60 result
= bc::prev_permutation(vector
.begin(), vector
.begin() + 4, queue
);
62 CHECK_RANGE_EQUAL(char, 4, vector
, ('a', 'a', 'a', 'b'));
63 BOOST_VERIFY(result
== true);
65 result
= bc::prev_permutation(vector
.begin(), vector
.begin() + 4, queue
);
67 CHECK_RANGE_EQUAL(char, 4, vector
, ('b', 'a', 'a', 'a'));
68 BOOST_VERIFY(result
== false);
71 BOOST_AUTO_TEST_SUITE_END()