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

Function BOOST_AUTO_TEST_CASE

test/test_random_fill.cpp:25–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace compute = boost::compute;
24
25BOOST_AUTO_TEST_CASE(random_fill_float)
26{
27 using compute::lambda::_1;
28
29 compute::vector<float> vector(10, context);
30
31 // fill with values between 0 and 1
32 compute::detail::random_fill(
33 vector.begin(),
34 vector.end(),
35 0.0f,
36 1.0f,
37 queue
38 );
39
40 BOOST_CHECK_EQUAL(
41 compute::count_if(
42 vector.begin(), vector.end(), _1 < 0.0f || _1 > 1.0f, queue
43 ),
44 size_t(0)
45 );
46
47 // fill with values between 5 and 10
48 compute::detail::random_fill(
49 vector.begin(),
50 vector.end(),
51 5.0f,
52 10.0f,
53 queue
54 );
55
56 BOOST_CHECK_EQUAL(
57 compute::count_if(
58 vector.begin(), vector.end(), _1 < 5.0f || _1 > 10.0f, queue
59 ),
60 size_t(0)
61 );
62
63 // fill with values between -25 and 25
64 compute::detail::random_fill(
65 vector.begin(), vector.end(), -25.0f, 25.0f, queue
66 );
67
68 BOOST_CHECK_EQUAL(
69 compute::count_if(
70 vector.begin(), vector.end(), _1 < -25.0f || _1 > 25.0f, queue
71 ),
72 size_t(0)
73 );
74}
75
76BOOST_AUTO_TEST_SUITE_END()

Callers

nothing calls this directly

Calls 4

random_fillFunction · 0.85
count_ifFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected