16 #define BOOST_TEST_MODULE ( filterRangeFor_test ) 17 #include "boost/test/unit_test.hpp" 25 template <
typename Cont,
typename Pred>
28 auto const nPass = std::count_if(data.begin(), data.end(),
pred);
33 BOOST_TEST_CHECKPOINT(
" testing value: " << v);
37 BOOST_TEST(n == nPass);
44 std::vector<int>
data(20);
45 std::iota(data.begin(), data.end(), 0);
47 BOOST_TEST_MESSAGE(
"Selecting multiples of 3");
48 testPredicate<std::vector<int>
const>
49 (
data, [](
int v){
return (v % 3) == 0; });
52 BOOST_TEST_MESSAGE(
"Selecting values that are not 9");
53 testPredicate<std::vector<int>
const>(
data, [](
int v){
return v != 9; });
56 BOOST_TEST_MESSAGE(
"Selecting values that are 50");
57 testPredicate<std::vector<int>
const>(
data, [](
int v){
return v == 50; });
void testPredicate(Cont &data, Pred pred)
BOOST_AUTO_TEST_CASE(filterRangeFor_testCase)
auto filterRangeFor(Range &&range, Pred &&pred) -> decltype(auto)
Provides iteration only through elements passing a condition.
Utilities to manipulate range for loops.