123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /*
- Copyright (c) Marshall Clow 2017.
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- For more information, see http://www.boost.org
- */
- #include <vector>
- #include <functional>
- #include <numeric>
- #include <algorithm>
- #include <boost/config.hpp>
- #include <boost/algorithm/cxx11/iota.hpp>
- #include <boost/algorithm/cxx17/exclusive_scan.hpp>
- #include "iterator_test.hpp"
- #define BOOST_TEST_MAIN
- #include <boost/test/unit_test.hpp>
- namespace ba = boost::algorithm;
- int triangle(int n) { return n*(n+1)/2; }
- void basic_tests_init()
- {
- {
- std::vector<int> v(10);
- std::fill(v.begin(), v.end(), 3);
- ba::exclusive_scan(v.begin(), v.end(), v.begin(), 50);
- for (size_t i = 0; i < v.size(); ++i)
- BOOST_CHECK(v[i] == 50 + (int) i * 3);
- }
- {
- std::vector<int> v(10);
- ba::iota(v.begin(), v.end(), 0);
- ba::exclusive_scan(v.begin(), v.end(), v.begin(), 30);
- for (size_t i = 0; i < v.size(); ++i)
- BOOST_CHECK(v[i] == 30 + triangle(i-1));
- }
- {
- std::vector<int> v(10);
- ba::iota(v.begin(), v.end(), 1);
- ba::exclusive_scan(v.begin(), v.end(), v.begin(), 40);
- for (size_t i = 0; i < v.size(); ++i)
- BOOST_CHECK(v[i] == 40 + triangle(i));
- }
- }
- void test_exclusive_scan_init()
- {
- basic_tests_init();
- }
- void test_exclusive_scan_init_op()
- {
- BOOST_CHECK(true);
- }
- BOOST_AUTO_TEST_CASE( test_main )
- {
- test_exclusive_scan_init();
- test_exclusive_scan_init_op();
- }
|