]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_functional_popcount.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_functional_popcount.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 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 TestFunctionalPopcount
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/algorithm/transform.hpp>
15 #include <boost/compute/container/vector.hpp>
16 #include <boost/compute/functional/popcount.hpp>
17
18 #include "check_macros.hpp"
19 #include "context_setup.hpp"
20
21 namespace compute = boost::compute;
22
23 typedef boost::mpl::list<
24 compute::uchar_, compute::ushort_, compute::uint_, compute::ulong_
25 > popcount_test_types;
26
27 BOOST_AUTO_TEST_CASE_TEMPLATE(popcount, T, popcount_test_types)
28 {
29 compute::vector<T> vec(context);
30 vec.push_back(0x00, queue);
31 vec.push_back(0x01, queue);
32 vec.push_back(0x03, queue);
33 vec.push_back(0xff, queue);
34
35 compute::vector<int> popcounts(vec.size(), context);
36 compute::transform(
37 vec.begin(), vec.end(), popcounts.begin(), compute::popcount<T>(), queue
38 );
39 CHECK_RANGE_EQUAL(int, 4, popcounts, (0, 1, 2, 8));
40 }
41
42 BOOST_AUTO_TEST_SUITE_END()