| 23 | #include "context_setup.hpp" |
| 24 | |
| 25 | BOOST_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 | |
| 55 | BOOST_AUTO_TEST_CASE(range_bounds_int) |
| 56 | { |
nothing calls this directly
no test coverage detected