]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_rotate_copy.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_rotate_copy.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 TestRotateCopy
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/command_queue.hpp>
15 #include <boost/compute/algorithm/copy_n.hpp>
16 #include <boost/compute/algorithm/rotate_copy.hpp>
17 #include <boost/compute/container/vector.hpp>
18
19 #include "check_macros.hpp"
20 #include "context_setup.hpp"
21
22 BOOST_AUTO_TEST_CASE(rotate_copy_trivial)
23 {
24 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
25 boost::compute::vector<int> vector(10, context);
26 boost::compute::vector<int> result(10, context);
27
28 boost::compute::copy_n(data, 10, vector.begin(), queue);
29
30 boost::compute::rotate_copy(vector.begin(), vector.begin(), vector.end(), result.begin(), queue);
31 CHECK_RANGE_EQUAL(int, 10, result, (1, 4, 2, 6, 3, 2, 5, 3, 4, 6));
32
33 boost::compute::rotate_copy(vector.begin(), vector.end(), vector.end(), result.begin(), queue);
34 CHECK_RANGE_EQUAL(int, 10, result, (1, 4, 2, 6, 3, 2, 5, 3, 4, 6));
35 }
36
37 BOOST_AUTO_TEST_CASE(rotate_copy_1)
38 {
39 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
40 boost::compute::vector<int> vector(10, context);
41 boost::compute::vector<int> result(10, context);
42
43 boost::compute::copy_n(data, 10, vector.begin(), queue);
44
45 boost::compute::rotate_copy(vector.begin(), vector.begin()+1, vector.end(), result.begin(), queue);
46 CHECK_RANGE_EQUAL(int, 10, result, (4, 2, 6, 3, 2, 5, 3, 4, 6, 1));
47 }
48
49 BOOST_AUTO_TEST_CASE(rotate_copy_4)
50 {
51 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
52 boost::compute::vector<int> vector(10, context);
53 boost::compute::vector<int> result(10, context);
54
55 boost::compute::copy_n(data, 10, vector.begin(), queue);
56
57 boost::compute::rotate_copy(vector.begin(), vector.begin()+4, vector.end(), result.begin(), queue);
58 CHECK_RANGE_EQUAL(int, 10, result, (3, 2, 5, 3, 4, 6, 1, 4, 2, 6));
59 }
60
61 BOOST_AUTO_TEST_CASE(rotate_copy_9)
62 {
63 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
64 boost::compute::vector<int> vector(10, context);
65 boost::compute::vector<int> result(10, context);
66
67 boost::compute::copy_n(data, 10, vector.begin(), queue);
68
69 boost::compute::rotate_copy(vector.begin(), vector.begin()+9, vector.end(), result.begin(), queue);
70 CHECK_RANGE_EQUAL(int, 10, result, (6, 1, 4, 2, 6, 3, 2, 5, 3, 4));
71 }
72
73 BOOST_AUTO_TEST_SUITE_END()