mirror of
https://github.com/boostorg/compute.git
synced 2026-01-27 06:42:19 +00:00
Now all tests work even if Context::context, Context::device, Context::queue are not default context, device and queue. This is required for developing better tests in the future. Note: Some tests may work only for default context/queue/device since classes that they test work only for default context/q/d. There are two solutions for this problem: either those tests run on default queue (no matter what) or they does not run when Context::context is not the default context. See test_string.cpp.
45 lines
1.3 KiB
C++
45 lines
1.3 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://boostorg.github.com/compute for more information.
|
|
//---------------------------------------------------------------------------//
|
|
|
|
#define BOOST_TEST_MODULE TestForEach
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <boost/compute/function.hpp>
|
|
#include <boost/compute/algorithm/iota.hpp>
|
|
#include <boost/compute/algorithm/for_each.hpp>
|
|
#include <boost/compute/algorithm/for_each_n.hpp>
|
|
#include <boost/compute/container/vector.hpp>
|
|
|
|
#include "context_setup.hpp"
|
|
|
|
namespace bc = boost::compute;
|
|
|
|
BOOST_AUTO_TEST_CASE(for_each_nop)
|
|
{
|
|
bc::vector<int> vector(4, context);
|
|
bc::iota(vector.begin(), vector.end(), 0, queue);
|
|
|
|
BOOST_COMPUTE_FUNCTION(void, nop, (int ignored), {});
|
|
|
|
bc::for_each(vector.begin(), vector.end(), nop, queue);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(for_each_n_nop)
|
|
{
|
|
bc::vector<int> vector(4, context);
|
|
bc::iota(vector.begin(), vector.end(), 0, queue);
|
|
|
|
BOOST_COMPUTE_FUNCTION(void, nop, (int ignored), {});
|
|
|
|
bc::for_each_n(vector.begin(), vector.size(), nop, queue);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|