]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_is_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 TestIsPermutation
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/is_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(is_permutation_int
)
27 bc::int_ dataset1
[] = {1, 3, 1, 2, 5};
28 bc::vector
<bc::int_
> vector1(dataset1
, dataset1
+ 5, queue
);
30 bc::int_ dataset2
[] = {3, 1, 5, 1, 2};
31 bc::vector
<bc::int_
> vector2(dataset2
, dataset2
+ 5, queue
);
34 bc::is_permutation(vector1
.begin(), vector1
.begin() + 5,
35 vector2
.begin(), vector2
.begin() + 5, queue
);
37 BOOST_VERIFY(result
== true);
39 vector2
.begin().write(bc::int_(1), queue
);
41 result
= bc::is_permutation(vector1
.begin(), vector1
.begin() + 5,
42 vector2
.begin(), vector2
.begin() + 5,
45 BOOST_VERIFY(result
== false);
48 BOOST_AUTO_TEST_CASE(is_permutation_string
)
50 bc::char_ dataset1
[] = "abade";
51 bc::vector
<bc::char_
> vector1(dataset1
, dataset1
+ 5, queue
);
53 bc::char_ dataset2
[] = "aadeb";
54 bc::vector
<bc::char_
> vector2(dataset2
, dataset2
+ 5, queue
);
57 bc::is_permutation(vector1
.begin(), vector1
.begin() + 5,
58 vector2
.begin(), vector2
.begin() + 5, queue
);
60 BOOST_VERIFY(result
== true);
62 vector2
.begin().write(bc::char_('b'), queue
);
64 result
= bc::is_permutation(vector1
.begin(), vector1
.begin() + 5,
65 vector2
.begin(), vector2
.begin() + 5,
68 BOOST_VERIFY(result
== false);
71 BOOST_AUTO_TEST_SUITE_END()