]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_search_n.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #define BOOST_TEST_MODULE TestSearchN
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/command_queue.hpp>
15 #include <boost/compute/algorithm/search_n.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/types/fundamental.hpp>
19 #include "check_macros.hpp"
20 #include "context_setup.hpp"
22 namespace bc
= boost::compute
;
24 BOOST_AUTO_TEST_CASE(search_int
)
26 int data
[] = {1, 2, 2, 2, 3, 2, 2, 2, 4, 6, 6};
27 bc::vector
<bc::int_
> vectort(data
, data
+ 11, queue
);
29 bc::vector
<bc::int_
>::iterator iter
=
30 bc::search_n(vectort
.begin(), vectort
.end(), 3, 2, queue
);
32 BOOST_CHECK(iter
== vectort
.begin() + 1);
35 bc::search_n(vectort
.begin(), vectort
.end(), 5, 2, queue
);
37 BOOST_CHECK(iter
== vectort
.begin() + 11);
40 bc::search_n(vectort
.begin(), vectort
.end(), 2, 6, queue
);
42 BOOST_CHECK(iter
== vectort
.begin() + 9);
45 BOOST_AUTO_TEST_CASE(search_string
)
47 char text
[] = "asaaababaaca";
48 bc::vector
<bc::char_
> vectort(text
, text
+ 12, queue
);
50 bc::vector
<bc::char_
>::iterator iter
=
51 bc::search_n(vectort
.begin(), vectort
.end(), 2, 'a', queue
);
53 BOOST_CHECK(iter
== vectort
.begin() + 2);
56 BOOST_AUTO_TEST_SUITE_END()