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

Function BOOST_AUTO_TEST_CASE

test/test_nth_element.cpp:24–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "context_setup.hpp"
23
24BOOST_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
51BOOST_AUTO_TEST_CASE(nth_element_median)
52{

Callers

nothing calls this directly

Calls 6

copy_nFunction · 0.85
nth_elementFunction · 0.85
is_partitionedFunction · 0.85
partition_pointFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected