| 22 | #include "context_setup.hpp" |
| 23 | |
| 24 | BOOST_AUTO_TEST_CASE(nth_element_int) |
| 25 | { |
| 26 | int data[] = { 9, 15, 1, 4, 9, 9, 4, 15, 12, 1 }; |
| 27 | boost::compute::vector<int> vector(10, context); |
| 28 | |
| 29 | boost::compute::copy_n(data, 10, vector.begin(), queue); |
| 30 | |
| 31 | boost::compute::nth_element( |
| 32 | vector.begin(), vector.begin() + 5, vector.end(), queue |
| 33 | ); |
| 34 | |
| 35 | BOOST_CHECK_EQUAL(vector[5], 9); |
| 36 | BOOST_VERIFY(boost::compute::is_partitioned( |
| 37 | vector.begin(), vector.end(), boost::compute::_1 <= 9, queue |
| 38 | )); |
| 39 | BOOST_VERIFY(boost::compute::partition_point( |
| 40 | vector.begin(), vector.end(), boost::compute::_1 <= 9, queue |
| 41 | ) > vector.begin() + 5); |
| 42 | |
| 43 | boost::compute::copy_n(data, 10, vector.begin(), queue); |
| 44 | |
| 45 | boost::compute::nth_element( |
| 46 | vector.begin(), vector.end(), vector.end(), queue |
| 47 | ); |
| 48 | CHECK_RANGE_EQUAL(int, 10, vector, (9, 15, 1, 4, 9, 9, 4, 15, 12, 1)); |
| 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_CASE(nth_element_median) |
| 52 | { |
nothing calls this directly
no test coverage detected