/* 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 #include #include #include #include #include #include #include "iterator_test.hpp" #define BOOST_TEST_MAIN #include namespace ba = boost::algorithm; int triangle(int n) { return n*(n+1)/2; } void basic_tests_init() { { std::vector 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 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 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(); }