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 TestIncludes
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/command_queue.hpp>
15 #include <boost/compute/algorithm/includes.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/types/fundamental.hpp>
18
19 #include "check_macros.hpp"
20 #include "context_setup.hpp"
21
22 namespace bc = boost::compute;
23
BOOST_AUTO_TEST_CASE(includes_int)24 BOOST_AUTO_TEST_CASE(includes_int)
25 {
26 int dataset1[] = {1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 10};
27 bc::vector<bc::int_> set1(dataset1, dataset1 + 12, queue);
28
29 int dataset2[] = {2, 4, 5, 6};
30 bc::vector<bc::int_> set2(dataset2, dataset2 + 4, queue);
31
32 bool includes = bc::includes(set1.begin(), set1.begin() + 12,
33 set2.begin(), set2.begin() + 4, queue);
34 BOOST_VERIFY(includes == true);
35
36 set2[3] = 7;
37 includes = bc::includes(set1.begin(), set1.begin() + 12,
38 set2.begin(), set2.begin() + 4, queue);
39 BOOST_VERIFY(includes == false);
40 }
41
BOOST_AUTO_TEST_CASE(includes_string)42 BOOST_AUTO_TEST_CASE(includes_string)
43 {
44 char string1[] = "abcccdddeeff";
45 bc::vector<bc::char_> set1(string1, string1 + 12, queue);
46
47 char string2[] = "bccdf";
48 bc::vector<bc::char_> set2(string2, string2 + 5, queue);
49
50 bool includes = bc::includes(set1.begin(), set1.begin() + 12,
51 set2.begin(), set2.begin() + 5, queue);
52 BOOST_VERIFY(includes == true);
53
54 set2[0] = 'g';
55 includes = bc::includes(set1.begin(), set1.begin() + 12,
56 set2.begin(), set2.begin() + 4, queue);
57 BOOST_VERIFY(includes == false);
58 }
59
60 BOOST_AUTO_TEST_SUITE_END()
61