]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_remove.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@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 TestRemove
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/algorithm/remove.hpp>
15 #include <boost/compute/algorithm/remove_if.hpp>
16 #include <boost/compute/container/vector.hpp>
18 #include "check_macros.hpp"
19 #include "context_setup.hpp"
21 namespace bc
= boost::compute
;
23 BOOST_AUTO_TEST_CASE(remove_int
)
25 int data
[] = { 1, 2, 1, 3, 2, 4, 3, 4, 5 };
26 bc::vector
<int> vector(data
, data
+ 9, queue
);
27 BOOST_CHECK_EQUAL(vector
.size(), size_t(9));
30 bc::vector
<int>::const_iterator iter
=
31 bc::remove(vector
.begin(), vector
.end(), 2, queue
);
32 BOOST_VERIFY(iter
== vector
.begin() + 7);
33 CHECK_RANGE_EQUAL(int, 7, vector
, (1, 1, 3, 4, 3, 4, 5));
36 iter
= bc::remove(vector
.begin(), vector
.begin() + 7, 4, queue
);
37 BOOST_VERIFY(iter
== vector
.begin() + 5);
38 CHECK_RANGE_EQUAL(int, 5, vector
, (1, 1, 3, 3, 5));
41 iter
= bc::remove(vector
.begin(), vector
.begin() + 5, 1, queue
);
42 BOOST_VERIFY(iter
== vector
.begin() + 3);
43 CHECK_RANGE_EQUAL(int, 3, vector
, (3, 3, 5));
46 iter
= bc::remove(vector
.begin(), vector
.begin() + 3, 5, queue
);
47 BOOST_VERIFY(iter
== vector
.begin() + 2);
48 CHECK_RANGE_EQUAL(int, 2, vector
, (3, 3));
51 iter
= bc::remove(vector
.begin(), vector
.begin() + 2, 3, queue
);
52 BOOST_VERIFY(iter
== vector
.begin());
55 BOOST_AUTO_TEST_SUITE_END()