14 #define BOOST_TEST_MODULE ( enumerate_test ) 15 #include <boost/test/unit_test.hpp> 32 constexpr std::size_t
N = 7U;
34 std::array<int, N> twice;
35 std::vector<double> thrice(N + 1);
37 for (std::size_t i = 0; i <
N; ++i) {
46 unsigned int iLoop = 0;
49 BOOST_TEST(i == iLoop);
51 BOOST_TEST(
a == twice[iLoop]);
52 BOOST_TEST(&
a == &(twice[iLoop]));
54 BOOST_TEST(
b == thrice[iLoop]);
55 BOOST_TEST(&
b == &thrice[iLoop]);
59 BOOST_TEST(iLoop == twice.size());
68 assert(thrice.size() == N - 1);
71 for (
auto&& [i,
a,
b]: util::enumerate<1>(twice, thrice)) {
73 BOOST_TEST(i == iLoop);
75 BOOST_TEST(
a == twice[iLoop]);
76 BOOST_TEST(&
a == &(twice[iLoop]));
78 BOOST_TEST(
b == thrice[iLoop]);
79 BOOST_TEST(&
b == &thrice[iLoop]);
83 BOOST_TEST(iLoop == thrice.size());
Definition of util::enumerate().
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
BOOST_AUTO_TEST_CASE(enumerate_testcase)