]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_replace.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 TestReplace
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/copy.hpp>
17 #include <boost/compute/algorithm/iota.hpp>
18 #include <boost/compute/algorithm/replace.hpp>
19 #include <boost/compute/algorithm/replace_copy.hpp>
20 #include <boost/compute/container/vector.hpp>
22 #include "check_macros.hpp"
23 #include "context_setup.hpp"
25 namespace bc
= boost::compute
;
27 BOOST_AUTO_TEST_CASE(replace_int
)
29 bc::vector
<int> vector(5, context
);
30 bc::iota(vector
.begin(), vector
.end(), 0, queue
);
31 CHECK_RANGE_EQUAL(int, 5, vector
, (0, 1, 2, 3, 4));
33 bc::replace(vector
.begin(), vector
.end(), 2, 6, queue
);
34 CHECK_RANGE_EQUAL(int, 5, vector
, (0, 1, 6, 3, 4));
37 BOOST_AUTO_TEST_CASE(replace_copy_int
)
39 bc::vector
<int> a(5, context
);
40 bc::iota(a
.begin(), a
.end(), 0, queue
);
41 CHECK_RANGE_EQUAL(int, 5, a
, (0, 1, 2, 3, 4));
43 bc::vector
<int> b(5, context
);
44 bc::vector
<int>::iterator iter
=
45 bc::replace_copy(a
.begin(), a
.end(), b
.begin(), 3, 9, queue
);
46 BOOST_CHECK(iter
== b
.end());
47 CHECK_RANGE_EQUAL(int, 5, b
, (0, 1, 2, 9, 4));
49 // ensure 'a' was not modified
50 CHECK_RANGE_EQUAL(int, 5, a
, (0, 1, 2, 3, 4));
53 BOOST_AUTO_TEST_SUITE_END()