2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-26 16:42:18 +00:00
Files
compute/test/check_macros.hpp
Kyle Lutz 1b9e904cc7 Add CHECK_RANGE_EQUAL() test macro
This adds a new macro for the unit-tests which checks a range of
values on the device against an array of values on the host. This
simplifies writing tests and removes the need to explicitly copy
values back to the host for verification.
2013-05-13 23:06:40 -04:00

34 lines
1.2 KiB
C++

//---------------------------------------------------------------------------//
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://kylelutz.github.com/compute for more information.
//---------------------------------------------------------------------------//
#ifndef BOOST_COMPUTE_TEST_CHECK_MACROS_HPP
#define BOOST_COMPUTE_TEST_CHECK_MACROS_HPP
#define LIST_ARRAY_VALUES(z, n, data) \
BOOST_PP_COMMA_IF(n) BOOST_PP_ARRAY_ELEM(n, data)
// checks 'size' values of 'type' in the device range '_actual`
// against the values given in the array '_expected'
#define CHECK_RANGE_EQUAL(type, size, _actual, _expected) \
{ \
type actual[size]; \
boost::compute::copy( \
_actual.begin(), _actual.end(), actual, queue \
); \
const type expected[size] = { \
BOOST_PP_REPEAT(size, LIST_ARRAY_VALUES, (size, _expected)) \
}; \
BOOST_CHECK_EQUAL_COLLECTIONS( \
actual, actual + size, expected, expected + size \
); \
}
#endif // BOOST_COMPUTE_TEST_CHECK_MACROS_HPP