Skip to content

Commit

Permalink
Replace BOOST_CHECK with BOOST_TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
ifsmirnov committed Feb 5, 2018
1 parent 2e2d0cf commit 2616a99
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 103 deletions.
50 changes: 25 additions & 25 deletions tests/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ 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<int>{2, 4, 6});
BOOST_CHECK_EQUAL(b, c);
BOOST_TEST(b == c);
}

BOOST_AUTO_TEST_CASE(operators) {
auto a = Array::id(3, 1);
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) {
Expand Down Expand Up @@ -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);

Expand All @@ -131,15 +131,15 @@ 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);
int y = rnd.next(1, 10);
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) {
Expand Down
18 changes: 9 additions & 9 deletions tests/dsu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
20 changes: 10 additions & 10 deletions tests/generic_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions tests/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion tests/printers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ template<typename T>
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<int>::value == 0);
BOOST_CHECK(VectorDepth<std::vector<int>>::value == 1);
BOOST_CHECK(VectorDepth<
Expand Down
46 changes: 23 additions & 23 deletions tests/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
void checkEndpointsHit(const std::vector<T>& 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) {
Expand All @@ -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
Expand Down Expand Up @@ -101,19 +101,19 @@ 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);

Random r2;
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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/repr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ template<typename T>
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) {
Expand Down
8 changes: 4 additions & 4 deletions tests/rnds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading

0 comments on commit 2616a99

Please sign in to comment.