]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //---------------------------------------------------------------------------// |
2 | // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | // | |
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 | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | #define BOOST_TEST_MODULE TestRemove | |
12 | #include <boost/test/unit_test.hpp> | |
13 | ||
14 | #include <boost/compute/algorithm/remove.hpp> | |
15 | #include <boost/compute/algorithm/remove_if.hpp> | |
16 | #include <boost/compute/container/vector.hpp> | |
17 | ||
18 | #include "check_macros.hpp" | |
19 | #include "context_setup.hpp" | |
20 | ||
21 | namespace bc = boost::compute; | |
22 | ||
23 | BOOST_AUTO_TEST_CASE(remove_int) | |
24 | { | |
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)); | |
28 | ||
29 | // remove 2's | |
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)); | |
34 | ||
35 | // remove 4's | |
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)); | |
39 | ||
40 | // remove 1's | |
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)); | |
44 | ||
45 | // remove 5's | |
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)); | |
49 | ||
50 | // remove 3's | |
51 | iter = bc::remove(vector.begin(), vector.begin() + 2, 3, queue); | |
52 | BOOST_VERIFY(iter == vector.begin()); | |
53 | } | |
54 | ||
55 | BOOST_AUTO_TEST_SUITE_END() |