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

Function BOOST_AUTO_TEST_CASE

test/test_binary_search.cpp:25–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include "context_setup.hpp"
24
25BOOST_AUTO_TEST_CASE(binary_search_int)
26{
27 // test data = { 1, ..., 2, ..., 4, 4, 5, 7, ..., 9, ..., 10 }
28 boost::compute::vector<int> vector(size_t(4096), int(1), queue);
29 boost::compute::vector<int>::iterator first = vector.begin() + 128;
30 boost::compute::vector<int>::iterator last = first + (1024 - 128);
31 boost::compute::fill(first, last, int(2), queue);
32 last.write(4, queue); last++;
33 last.write(4, queue); last++;
34 last.write(5, queue); last++;
35 first = last;
36 last = first + 127;
37 boost::compute::fill(first, last, 7, queue);
38 first = last;
39 last = vector.end() - 1;
40 boost::compute::fill(first, last, 9, queue);
41 last.write(10, queue);
42 queue.finish();
43
44 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(0), queue) == false);
45 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(1), queue) == true);
46 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(2), queue) == true);
47 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(3), queue) == false);
48 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(4), queue) == true);
49 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(5), queue) == true);
50 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(6), queue) == false);
51 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(7), queue) == true);
52 BOOST_CHECK(boost::compute::binary_search(vector.begin(), vector.end(), int(8), queue) == false);
53}
54
55BOOST_AUTO_TEST_CASE(range_bounds_int)
56{

Callers

nothing calls this directly

Calls 8

binary_searchFunction · 0.85
lower_boundFunction · 0.85
upper_boundFunction · 0.85
fillFunction · 0.50
beginMethod · 0.45
writeMethod · 0.45
endMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected