MCPcopy Create free account
hub / github.com/boostorg/compute / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

test/test_functional_as.cpp:25–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace compute = boost::compute;
24
25BOOST_AUTO_TEST_CASE(roundtrip_int_float)
26{
27 int data[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
28 compute::vector<int> input(8, context);
29 compute::copy_n(data, 8, input.begin(), queue);
30
31 // convert int -> float
32 compute::vector<float> output(8, context);
33 compute::transform(
34 input.begin(),
35 input.end(),
36 output.begin(),
37 compute::as<float>(),
38 queue
39 );
40
41 // zero out input
42 compute::fill(input.begin(), input.end(), 0, queue);
43
44 // convert float -> int
45 compute::transform(
46 output.begin(),
47 output.end(),
48 input.begin(),
49 compute::as<int>(),
50 queue
51 );
52
53 // check values
54 CHECK_RANGE_EQUAL(
55 int, 8, output, (1, 2, 3, 4, 5, 6, 7, 8)
56 );
57}
58
59BOOST_AUTO_TEST_SUITE_END()

Callers

nothing calls this directly

Calls 5

copy_nFunction · 0.85
transformFunction · 0.85
fillFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected