]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_rotate.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 TestRotate
12 #include <boost/test/unit_test.hpp>
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>
19 #include "check_macros.hpp"
20 #include "context_setup.hpp"
22 BOOST_AUTO_TEST_CASE(rotate_trivial
)
24 int data
[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
25 boost::compute::vector
<int> vector(10, context
);
27 boost::compute::copy_n(data
, 10, vector
.begin(), queue
);
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));
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));
36 BOOST_AUTO_TEST_CASE(rotate_1
)
38 int data
[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
39 boost::compute::vector
<int> vector(10, context
);
41 boost::compute::copy_n(data
, 10, vector
.begin(), queue
);
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));
47 BOOST_AUTO_TEST_CASE(rotate_4
)
49 int data
[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
50 boost::compute::vector
<int> vector(10, context
);
52 boost::compute::copy_n(data
, 10, vector
.begin(), queue
);
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));
58 BOOST_AUTO_TEST_CASE(rotate_9
)
60 int data
[] = {1, 4, 2, 6, 3, 2, 5, 3, 4, 6};
61 boost::compute::vector
<int> vector(10, context
);
63 boost::compute::copy_n(data
, 10, vector
.begin(), queue
);
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));
69 BOOST_AUTO_TEST_SUITE_END()