#define BOOST_TEST_MODULE ConcatTest #include #include #include #include "concat.h" template bool TestConcat(Range1 &r1, Range2 &r2, Range3 &r3) { std::vector v1, v2; v1.insert(v1.end(), r1.begin(), r1.end()); v1.insert(v1.end(), r2.begin(), r2.end()); v2.insert(v2.end(), r3.begin(), r3.end()); return v1 == v2; } template bool TestConcat(Range1 &r1, Range2 &r2) { return TestConcat(r1, r2, Concatenate(r1, r2)); } BOOST_AUTO_TEST_CASE(Concat) { int a1[] = { 1, 2, 3, 4, 5 }; int a2[] = { 10, 11, 12 }; std::vector v(boost::begin(a1), boost::end(a1)); std::list l(boost::begin(a2), boost::end(a2)); int value = 0; boost::iterator_range i(&value, &value+1), n((int*)NULL, (int*)NULL); BOOST_CHECK(TestConcat(l, v)); BOOST_CHECK(TestConcat(v, l)); BOOST_CHECK(TestConcat(v, v)); BOOST_CHECK(TestConcat(n, v)); BOOST_CHECK(TestConcat(v, n)); BOOST_CHECK(TestConcat(n, n)); BOOST_CHECK(TestConcat(n, i)); BOOST_CHECK(TestConcat(i, n)); BOOST_CHECK(TestConcat(i, v)); BOOST_CHECK(TestConcat(i, i)); }