2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-19 02:12:19 +00:00

Add identity<T>() function

This commit is contained in:
Kyle Lutz
2014-11-28 14:08:59 -08:00
parent 85e03f7e69
commit 16fdb15395
5 changed files with 112 additions and 0 deletions

View File

@@ -138,6 +138,7 @@ add_compute_test("functional.bind" test_functional_bind.cpp)
add_compute_test("functional.convert" test_functional_convert.cpp)
add_compute_test("functional.get" test_functional_get.cpp)
add_compute_test("functional.hash" test_functional_hash.cpp)
add_compute_test("functional.identity" test_functional_identity.cpp)
add_compute_test("functional.popcount" test_functional_popcount.cpp)
add_compute_test("functional.unpack" test_functional_unpack.cpp)

View File

@@ -0,0 +1,39 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2013-2014 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.
//---------------------------------------------------------------------------//
#define BOOST_TEST_MODULE TestFunctionalIdentity
#include <boost/test/unit_test.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/transform.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/functional/identity.hpp>
#include "check_macros.hpp"
#include "context_setup.hpp"
namespace compute = boost::compute;
BOOST_AUTO_TEST_CASE(copy_with_identity_transform)
{
int data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
compute::vector<int> input(data, data + 8, queue);
compute::vector<int> output(8, context);
compute::transform(
input.begin(), input.end(), output.begin(), compute::identity<int>(), queue
);
CHECK_RANGE_EQUAL(
int, 8, output, (1, 2, 3, 4, 5, 6, 7, 8)
);
}
BOOST_AUTO_TEST_SUITE_END()