diff --git a/tests/array.cpp b/tests/array.cpp index 0371aad..8881035 100644 --- a/tests/array.cpp +++ b/tests/array.cpp @@ -12,54 +12,54 @@ BOOST_AUTO_TEST_CASE(basics) { a = Array::id(5); b = {0, 1, 2, 3, 4}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a = Array::id(5, 1); b = {1, 2, 3, 4, 5}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a.reverse(); b = {5, 4, 3, 2, 1}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a = b.reversed(); b.reverse(); - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a = {4, 2, 3, 1, 5}; b = a.sorted(); - BOOST_CHECK(a != b); + BOOST_TEST(a != b); a.sort(); - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); auto comp = [](int x, int y) { return x > y; }; a = {4, 2, 3, 1, 5}; b = a.sorted(comp); - BOOST_CHECK(a != b); + BOOST_TEST(a != b); a.sort(comp); - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); b = {5, 4, 3, 2, 1}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a = {1, 3, 4, 0, 2}; b = {3, 0, 4, 1, 2}; - BOOST_CHECK_EQUAL(a.inverse(), b); - BOOST_CHECK_EQUAL(a, b.inverse()); + BOOST_TEST(a.inverse() == b); + BOOST_TEST(a == b.inverse()); a = {1, 2, 3, 3, 2, 1}; b = a.sorted().uniqued(); - BOOST_CHECK(a != b); + BOOST_TEST(a != b); a.sort().unique(); - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); b = {1, 2, 3}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); a = Array::id(10, 1); b = {3, 5, 7}; auto c = a.subseq({2, 4, 6}); - BOOST_CHECK_EQUAL(b, c); + BOOST_TEST(b == c); c = a.subseq(std::vector{2, 4, 6}); - BOOST_CHECK_EQUAL(b, c); + BOOST_TEST(b == c); } BOOST_AUTO_TEST_CASE(operators) { @@ -67,13 +67,13 @@ BOOST_AUTO_TEST_CASE(operators) { a += Array{2}; a = a + Array::id(3, 10); Array b{1, 2, 3, 2, 10, 11, 12}; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); b += b; b += b; a = a * 2; a *= 2; - BOOST_CHECK_EQUAL(a, b); + BOOST_TEST(a == b); } BOOST_AUTO_TEST_CASE(random_selection) { @@ -107,21 +107,21 @@ BOOST_AUTO_TEST_CASE(random_generation) { rnd.seed(456); auto a = Array::random(100, 10); - BOOST_CHECK_EQUAL(a.sorted().uniqued(), Array::id(10)); + BOOST_TEST(a.sorted().uniqued() == Array::id(10)); a = Array::random(100, 10, 20); - BOOST_CHECK_EQUAL(a.sorted().uniqued(), Array::id(11, 10)); + BOOST_TEST(a.sorted().uniqued() == Array::id(11, 10)); a = Array::randomUnique(11, 10, 20); - BOOST_CHECK_EQUAL(a.sorted().uniqued(), Array::id(11, 10)); + BOOST_TEST(a.sorted().uniqued() == Array::id(11, 10)); auto b = Arrayp::random(100, 10, opair); for (const auto& kv: b) { - BOOST_CHECK(kv.first <= kv.second); + BOOST_TEST(kv.first <= kv.second); } b = Arrayp::randomUnique(100, 10); - BOOST_CHECK_EQUAL(b.size(), 100); + BOOST_TEST(b.size() == 100); b = Arrayp::randomUnique(55, 1, 10, opair); @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(random_generation) { return std::make_pair(std::min(x, y), std::max(x, y)); }); - BOOST_CHECK_EQUAL(b.sorted(), c.sorted()); + BOOST_TEST(b.sorted() == c.sorted()); c = Arrayp::randomf(1000, []() { int x = rnd.next(1, 10); @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(random_generation) { return std::make_pair(std::min(x, y), std::max(x, y)); }); - BOOST_CHECK_EQUAL(b.sorted(), c.sorted().uniqued()); + BOOST_TEST(b.sorted() == c.sorted().uniqued()); } BOOST_AUTO_TEST_CASE(print_matrix) { diff --git a/tests/dsu.cpp b/tests/dsu.cpp index 699b1a8..5190377 100644 --- a/tests/dsu.cpp +++ b/tests/dsu.cpp @@ -9,19 +9,19 @@ BOOST_AUTO_TEST_SUITE(generic_graph) BOOST_AUTO_TEST_CASE(dsu) { Dsu d; - BOOST_CHECK(d.isConnected()); + BOOST_TEST(d.isConnected()); d.extend(5); - BOOST_CHECK(!d.isConnected()); + BOOST_TEST(!d.isConnected()); - BOOST_CHECK(d.unite(1, 2)); - BOOST_CHECK(d.unite(3, 4)); - BOOST_CHECK(d.unite(1, 4)); - BOOST_CHECK(!d.unite(2, 3)); - BOOST_CHECK(d.unite(0, 3)); - BOOST_CHECK(d.isConnected()); + BOOST_TEST(d.unite(1, 2)); + BOOST_TEST(d.unite(3, 4)); + BOOST_TEST(d.unite(1, 4)); + BOOST_TEST(!d.unite(2, 3)); + BOOST_TEST(d.unite(0, 3)); + BOOST_TEST(d.isConnected()); - BOOST_CHECK(!d.unite(0, 0)); + BOOST_TEST(!d.unite(0, 0)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/generic_graph.cpp b/tests/generic_graph.cpp index 9157720..6ba577e 100644 --- a/tests/generic_graph.cpp +++ b/tests/generic_graph.cpp @@ -11,24 +11,24 @@ BOOST_AUTO_TEST_SUITE(generic_graph) BOOST_AUTO_TEST_CASE(basics) { GenericGraph gg; - BOOST_CHECK(gg.n() == 0); - BOOST_CHECK(gg.m() == 0); - BOOST_CHECK(gg.isConnected()); - BOOST_CHECK(gg.edges().empty()); + BOOST_TEST(gg.n() == 0); + BOOST_TEST(gg.m() == 0); + BOOST_TEST(gg.isConnected()); + BOOST_TEST(gg.edges().empty()); gg.addEdge(0, 2); gg.addEdge(1, 3); - BOOST_CHECK(gg.edges().size() == 2); + BOOST_TEST(gg.edges().size() == 2); BOOST_CHECK(gg.edges()[0] == std::make_pair(0, 2)); BOOST_CHECK(gg.edges()[1] == std::make_pair(1, 3)); - BOOST_CHECK(gg.n() == 4); - BOOST_CHECK(gg.m() == 2); - BOOST_CHECK(!gg.isConnected()); + BOOST_TEST(gg.n() == 4); + BOOST_TEST(gg.m() == 2); + BOOST_TEST(!gg.isConnected()); gg.addEdge(0, 3); - BOOST_CHECK(gg.isConnected()); + BOOST_TEST(gg.isConnected()); gg.addEdge(0, 3); - BOOST_CHECK(gg.m() == 4); + BOOST_TEST(gg.m() == 4); auto g2 = gg; BOOST_CHECK(gg == g2); diff --git a/tests/geometry.cpp b/tests/geometry.cpp index cfbf5f3..617b925 100644 --- a/tests/geometry.cpp +++ b/tests/geometry.cpp @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(polygon) { rnd.seed(123); auto p = rndg.convexPolygon(10, 100); // TODO: check that it is convex - BOOST_CHECK_EQUAL(p.size(), 10); + BOOST_TEST(p.size() == 10); } BOOST_AUTO_TEST_CASE(points_in_general_position) { diff --git a/tests/options.cpp b/tests/options.cpp index b6be68d..6a9d976 100644 --- a/tests/options.cpp +++ b/tests/options.cpp @@ -52,12 +52,12 @@ void check( getNamed(a, b, c); - BOOST_CHECK_EQUAL(x0, v0); - BOOST_CHECK_EQUAL(x1, v1); - BOOST_CHECK_EQUAL(x2, v2); - BOOST_CHECK_EQUAL( a, va); - BOOST_CHECK_EQUAL( b, vb); - BOOST_CHECK_EQUAL( c, vc); + BOOST_TEST(x0 == v0); + BOOST_TEST(x1 == v1); + BOOST_TEST(x2 == v2); + BOOST_TEST( a == va); + BOOST_TEST( b == vb); + BOOST_TEST( c == vc); } BOOST_AUTO_TEST_CASE(variable_map) { diff --git a/tests/printers.cpp b/tests/printers.cpp index 1643d0f..9fded71 100644 --- a/tests/printers.cpp +++ b/tests/printers.cpp @@ -14,11 +14,12 @@ template void checkOutput(const T& t, const std::string& s) { std::ostringstream ss; ss << t; - BOOST_CHECK_EQUAL(ss.str(), s); + BOOST_TEST(ss.str() == s); } BOOST_AUTO_TEST_CASE(vector_depth) { using jngen::detail::VectorDepth; + // TODO: Strange 'undefined reference' if using BOOST_TEST here BOOST_CHECK(VectorDepth::value == 0); BOOST_CHECK(VectorDepth>::value == 1); BOOST_CHECK(VectorDepth< diff --git a/tests/random.cpp b/tests/random.cpp index e7b0567..542c28b 100644 --- a/tests/random.cpp +++ b/tests/random.cpp @@ -11,28 +11,28 @@ BOOST_AUTO_TEST_SUITE(random_suite) BOOST_AUTO_TEST_CASE(basic_methods) { rnd.seed(123); - BOOST_CHECK_EQUAL(rnd.next(), 2991312382); - BOOST_CHECK_EQUAL(rnd.next64(), 13151704351418379646ull); + BOOST_TEST(rnd.next() == 2991312382); + BOOST_TEST(rnd.next64() == 13151704351418379646ull); BOOST_CHECK_CLOSE(rnd.nextf(), 0.42847092506, 1e-5); - BOOST_CHECK_EQUAL(rnd.next(123), 92); - BOOST_CHECK_EQUAL(rnd.next(1000000000000000000ll), 62439489592817382ll); + BOOST_TEST(rnd.next(123) == 92); + BOOST_TEST(rnd.next(1000000000000000000ll) == 62439489592817382ll); BOOST_CHECK_CLOSE(rnd.next(123.0), 88.455487997, 1e-5); - BOOST_CHECK_EQUAL(rnd.next(100, 500), 183); - BOOST_CHECK_EQUAL(rnd.next(10000ll, 50000ll), 33766); + BOOST_TEST(rnd.next(100, 500) == 183); + BOOST_TEST(rnd.next(10000ll, 50000ll) == 33766); BOOST_CHECK_CLOSE(rnd.next(0.1, 0.2), 0.14109243679, 1e-5); auto p = rnd.nextp(100); - BOOST_CHECK_EQUAL(p.first, 96); - BOOST_CHECK_EQUAL(p.second, 47); + BOOST_TEST(p.first == 96); + BOOST_TEST(p.second == 47); - BOOST_CHECK_EQUAL(rnd.next("[a-z]{1,20}"), "aoapztoeaq"); + BOOST_TEST(rnd.next("[a-z]{1,20}") == "aoapztoeaq"); } template void checkEndpointsHit(const std::vector& a, T min, T max) { - BOOST_CHECK(!a.empty()); - BOOST_CHECK_EQUAL(*std::min_element(a.begin(), a.end()), min); - BOOST_CHECK_EQUAL(*std::max_element(a.begin(), a.end()), max); + BOOST_TEST(!a.empty()); + BOOST_TEST(*std::min_element(a.begin(), a.end()) == min); + BOOST_TEST(*std::max_element(a.begin(), a.end()) == max); } BOOST_AUTO_TEST_CASE(range_endpoints) { @@ -58,13 +58,13 @@ BOOST_AUTO_TEST_CASE(range_endpoints) { BOOST_AUTO_TEST_CASE(mask_for_bound) { using jngen::maskForBound; - BOOST_CHECK_EQUAL(maskForBound(1), 1); - BOOST_CHECK_EQUAL(maskForBound(2), 1); - BOOST_CHECK_EQUAL(maskForBound(10), 15); - BOOST_CHECK_EQUAL(maskForBound(900), 1023); - BOOST_CHECK_EQUAL(maskForBound(1023), 1023); - BOOST_CHECK_EQUAL(maskForBound(1024), 1023); - BOOST_CHECK_EQUAL(maskForBound(1025), 2047); + BOOST_TEST(maskForBound(1) == 1); + BOOST_TEST(maskForBound(2) == 1); + BOOST_TEST(maskForBound(10) == 15); + BOOST_TEST(maskForBound(900) == 1023); + BOOST_TEST(maskForBound(1023) == 1023); + BOOST_TEST(maskForBound(1024) == 1023); + BOOST_TEST(maskForBound(1025) == 2047); } // TODO: add tests for incorrect patterns @@ -101,10 +101,10 @@ BOOST_AUTO_TEST_CASE(several_engines) { Random r1; r1.seed(123); - BOOST_CHECK(etalon == generate(r1)); + BOOST_TEST(etalon == generate(r1)); r1.seed(123); - BOOST_CHECK(etalon == generate(r1)); + BOOST_TEST(etalon == generate(r1)); etalon = generate(rnd); @@ -112,8 +112,8 @@ BOOST_AUTO_TEST_CASE(several_engines) { r2.seed(123); generate(r2); - BOOST_CHECK(etalon == generate(r2)); - BOOST_CHECK(etalon == generate(r1)); + BOOST_TEST(etalon == generate(r2)); + BOOST_TEST(etalon == generate(r1)); } BOOST_AUTO_TEST_CASE(test_choice) { diff --git a/tests/repr.cpp b/tests/repr.cpp index 64c0c2a..7b8ff26 100644 --- a/tests/repr.cpp +++ b/tests/repr.cpp @@ -12,7 +12,7 @@ template void checkOutput(const T& t, const std::string& s) { std::ostringstream ss; ss << t; - BOOST_CHECK_EQUAL(ss.str(), s); + BOOST_TEST(ss.str() == s); } BOOST_AUTO_TEST_CASE(output_mod_array) { diff --git a/tests/rnds.cpp b/tests/rnds.cpp index ef1c33c..f86ceff 100644 --- a/tests/rnds.cpp +++ b/tests/rnds.cpp @@ -10,11 +10,11 @@ BOOST_AUTO_TEST_SUITE(rnds_suite) BOOST_AUTO_TEST_CASE(basics) { rnd.seed(123); - BOOST_CHECK_EQUAL(rnds.abacaba(10), "abacabadab"); - BOOST_CHECK_EQUAL(rnds.abacaba(10, 'A'), "ABACABADAB"); + BOOST_TEST(rnds.abacaba(10) == "abacabadab"); + BOOST_TEST(rnds.abacaba(10, 'A') == "ABACABADAB"); - BOOST_CHECK_EQUAL(rnds.thueMorse(10), "abbabaabba"); - BOOST_CHECK_EQUAL(rnds.thueMorse(10, 'q', 'w'), "qwwqwqqwwq"); + BOOST_TEST(rnds.thueMorse(10) == "abbabaabba"); + BOOST_TEST(rnds.thueMorse(10, 'q', 'w') == "qwwqwqqwwq"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tree.cpp b/tests/tree.cpp index 0b0a2c9..dec25db 100644 --- a/tests/tree.cpp +++ b/tests/tree.cpp @@ -10,9 +10,9 @@ BOOST_AUTO_TEST_SUITE(tree) void checkEquals(const jngen::Tree& t1, const jngen::Tree& t2) { - BOOST_CHECK_EQUAL(t1.n(), t2.n()); + BOOST_TEST(t1.n() == t2.n()); for (int i = 0; i < t1.n(); ++i) { - BOOST_CHECK_EQUAL(t1.edges(i).sorted(), t2.edges(i).sorted()); + BOOST_TEST(t1.edges(i).sorted() == t2.edges(i).sorted()); } } @@ -21,23 +21,23 @@ BOOST_AUTO_TEST_CASE(manual_construction) { Tree t; - BOOST_CHECK_EQUAL(t.n(), 1); - BOOST_CHECK_EQUAL(t.m(), 0); - BOOST_CHECK(t.isConnected()); + BOOST_TEST(t.n() == 1); + BOOST_TEST(t.m() == 0); + BOOST_TEST(t.isConnected()); t.addEdge(0, 1); t.addEdge(2, 3); - BOOST_CHECK(!t.isConnected()); + BOOST_TEST(!t.isConnected()); t.addEdge(1, 2); - BOOST_CHECK_EQUAL(t.n(), 4); - BOOST_CHECK_EQUAL(t.m(), 3); + BOOST_TEST(t.n() == 4); + BOOST_TEST(t.m() == 3); std::ostringstream ss; ss << t.printN().add1() << std::endl; - BOOST_CHECK_EQUAL(ss.str(), "4\n1 2\n3 4\n2 3\n"); + BOOST_TEST(ss.str() == "4\n1 2\n3 4\n2 3\n"); } void dfs(int v, int anc, const Tree& t, std::vector& dist) { @@ -110,9 +110,9 @@ BOOST_AUTO_TEST_CASE(generators) { std::vector centers, dist; auto b = Tree::bamboo(10); - BOOST_CHECK_EQUAL(findDiameter(b, centers, dist), 9); - BOOST_CHECK_EQUAL(centers[0], 4); - BOOST_CHECK_EQUAL(centers[1], 5); + BOOST_TEST(findDiameter(b, centers, dist) == 9); + BOOST_TEST(centers[0] == 4); + BOOST_TEST(centers[1] == 5); std::ostringstream ss; @@ -126,30 +126,35 @@ BOOST_AUTO_TEST_CASE(generators) { std::string second = ss.str(); ss.clear(); - BOOST_CHECK(first != second); + BOOST_TEST(first != second); auto s = Tree::star(10); - BOOST_CHECK_EQUAL(findDiameter(s, centers, dist), 2); - BOOST_CHECK_EQUAL(centers[0], 0); + BOOST_TEST(findDiameter(s, centers, dist) == 2); + BOOST_TEST(centers[0] == 0); // probability of failure < 1e-5 auto c = Tree::caterpillar(100, 10); - BOOST_CHECK_EQUAL(findDiameter(c, centers, dist), 11); + BOOST_TEST(findDiameter(c, centers, dist) == 11); // probability of failure < 1e-3 c = Tree::caterpillar(8004, 8000); - BOOST_CHECK_EQUAL(findDiameter(c, centers, dist), 7999); + BOOST_TEST(findDiameter(c, centers, dist) == 7999); // probability of failure unknown, but very low auto t = Tree::randomPrim(150, 15000); - BOOST_CHECK_EQUAL(t, Tree::bamboo(150)); + BOOST_TEST(t == Tree::bamboo(150)); } BOOST_AUTO_TEST_CASE(prufer_all_trees) { auto a = TArray::randomfUnique(120, []() { return Tree::random(5); }); - BOOST_CHECK_EQUAL(a.size(), 5*4*3*2*1); + BOOST_TEST(a.size() == 5*4*3*2*1); + + auto b = TArray::randomfAll([]() { + return Tree::random(5); + }); + BOOST_TEST(b.size() == 5*5*5); } BOOST_AUTO_TEST_CASE(check_link) { @@ -186,8 +191,8 @@ BOOST_AUTO_TEST_CASE(check_link) { Tree linked = t1.link(4, t2, 2); - BOOST_CHECK_EQUAL(t1.n() + t2.n(), linked.n()); - BOOST_CHECK_EQUAL(t1.m() + t2.m() + 1, linked.m()); + BOOST_TEST(t1.n() + t2.n() == linked.n()); + BOOST_TEST(t1.m() + t2.m() + 1 == linked.m()); checkEquals(linked, t); } @@ -224,8 +229,8 @@ BOOST_AUTO_TEST_CASE(check_glue) { Tree glued = t1.glue(4, t2, 2); - BOOST_CHECK_EQUAL(t1.n() + t2.n() - 1, glued.n()); - BOOST_CHECK_EQUAL(t1.m() + t2.m(), glued.m()); + BOOST_TEST(t1.n() + t2.n() - 1 == glued.n()); + BOOST_TEST(t1.m() + t2.m() == glued.m()); checkEquals(glued, t); }