]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/check_macros.hpp
a115e6a9360930b7b862e561f0380d40c9d23111
[ceph.git] / ceph / src / boost / libs / compute / test / check_macros.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@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 #ifndef BOOST_COMPUTE_TEST_CHECK_MACROS_HPP
12 #define BOOST_COMPUTE_TEST_CHECK_MACROS_HPP
13
14 #define LIST_ARRAY_VALUES(z, n, data) \
15 BOOST_PP_COMMA_IF(n) BOOST_PP_ARRAY_ELEM(n, data)
16
17 // checks 'size' values of 'type' in the device range 'actual`
18 // against the values given in the array 'expected'
19 #define CHECK_RANGE_EQUAL(type, size, actual, expected) \
20 { \
21 type _actual[size]; \
22 boost::compute::copy( \
23 actual.begin(), actual.begin()+size, _actual, queue \
24 ); \
25 const type _expected[size] = { \
26 BOOST_PP_REPEAT(size, LIST_ARRAY_VALUES, (size, expected)) \
27 }; \
28 BOOST_CHECK_EQUAL_COLLECTIONS( \
29 _actual, _actual + size, _expected, _expected + size \
30 ); \
31 }
32
33 #define CHECK_HOST_RANGE_EQUAL(type, size, actual, expected) \
34 { \
35 const type _expected[size] = { \
36 BOOST_PP_REPEAT(size, LIST_ARRAY_VALUES, (size, expected)) \
37 }; \
38 BOOST_CHECK_EQUAL_COLLECTIONS( \
39 actual, actual + size, _expected, _expected + size \
40 ); \
41 }
42
43 #define CHECK_STRING_EQUAL(actual, expected) \
44 { \
45 std::string _actual(actual.size(), '\0'); \
46 boost::compute::copy( \
47 actual.begin(), actual.end(), _actual.begin(), queue \
48 ); \
49 BOOST_CHECK_EQUAL(_actual, expected); \
50 }
51
52 #endif // BOOST_COMPUTE_TEST_CHECK_MACROS_HPP