]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_rotate.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_rotate.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 TestRotate
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.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_trivial)
23 {
24 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
25 boost::compute::vector<int> vector(10, context);
26
27 boost::compute::copy_n(data, 10, vector.begin(), queue);
28
29 boost::compute::rotate(vector.begin(), vector.begin(), vector.end(), queue);
30 CHECK_RANGE_EQUAL(int, 10, vector, (1, 4, 2, 6, 3, 2, 5, 3, 4, 6));
31
32 boost::compute::rotate(vector.begin(), vector.end(), vector.end(), queue);
33 CHECK_RANGE_EQUAL(int, 10, vector, (1, 4, 2, 6, 3, 2, 5, 3, 4, 6));
34 }
35
36 BOOST_AUTO_TEST_CASE(rotate_1)
37 {
38 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
39 boost::compute::vector<int> vector(10, context);
40
41 boost::compute::copy_n(data, 10, vector.begin(), queue);
42
43 boost::compute::rotate(vector.begin(), vector.begin()+1, vector.end(), queue);
44 CHECK_RANGE_EQUAL(int, 10, vector, (4, 2, 6, 3, 2, 5, 3, 4, 6, 1));
45 }
46
47 BOOST_AUTO_TEST_CASE(rotate_4)
48 {
49 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
50 boost::compute::vector<int> vector(10, context);
51
52 boost::compute::copy_n(data, 10, vector.begin(), queue);
53
54 boost::compute::rotate(vector.begin(), vector.begin()+4, vector.end(), queue);
55 CHECK_RANGE_EQUAL(int, 10, vector, (3, 2, 5, 3, 4, 6, 1, 4, 2, 6));
56 }
57
58 BOOST_AUTO_TEST_CASE(rotate_9)
59 {
60 int data[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
61 boost::compute::vector<int> vector(10, context);
62
63 boost::compute::copy_n(data, 10, vector.begin(), queue);
64
65 boost::compute::rotate(vector.begin(), vector.begin()+9, vector.end(), queue);
66 CHECK_RANGE_EQUAL(int, 10, vector, (6, 1, 4, 2, 6, 3, 2, 5, 3, 4));
67 }
68
69 BOOST_AUTO_TEST_SUITE_END()