1 #include <catch.hpp>
2 
3 #include <iostream>
4 
5 #include "../lib/supertree_enumerator.hpp"
6 #include "../lib/supertree_variants.hpp"
7 
8 namespace terraces {
9 namespace tests {
10 
count_supertree(index num_leaves,const constraints & constraints)11 uint64_t count_supertree(index num_leaves, const constraints& constraints) {
12 	tree_enumerator<variants::count_callback<uint64_t>> e{{}};
13 	return e.run(num_leaves, constraints);
14 }
15 
check_supertree(index num_leaves,const constraints & constraints)16 bool check_supertree(index num_leaves, const constraints& constraints) {
17 	tree_enumerator<variants::check_callback> e{{}};
18 	return e.run(num_leaves, constraints) > 1;
19 }
20 
21 TEST_CASE("count_supertree1", "[supertree]") {
22 	constraints c = {};
23 	CHECK(count_supertree(2, c) == 1);
24 	CHECK(!check_supertree(2, c));
25 }
26 
27 TEST_CASE("count_supertree2", "[supertree]") {
28 	constraints c = {};
29 	CHECK(count_supertree(3, c) == 3);
30 	CHECK(check_supertree(3, c));
31 }
32 
33 TEST_CASE("count_supertree3", "[supertree]") {
34 	constraints c = {};
35 	CHECK(count_supertree(7, c) == 10395);
36 	CHECK(check_supertree(7, c));
37 }
38 
39 TEST_CASE("count_supertree4", "[supertree]") {
40 	constraints c = {{0, 1, 2}};
41 	CHECK(count_supertree(3, c) == 1);
42 	CHECK(!check_supertree(3, c));
43 }
44 
45 TEST_CASE("count_supertree5", "[supertree]") {
46 	constraints c = {{0, 1, 2}, {2, 3, 4}};
47 	CHECK(count_supertree(5, c) == 9);
48 	CHECK(check_supertree(5, c));
49 }
50 
51 TEST_CASE("count_supertree6", "[supertree]") {
52 	constraints c = {{1, 0, 2}, {3, 4, 1}};
53 	CHECK(count_supertree(5, c) == 9);
54 	CHECK(check_supertree(5, c));
55 }
56 
57 TEST_CASE("count_supertree7", "[supertree]") {
58 	constraints c = {{0, 1, 3}, {3, 2, 0}, {4, 5, 6}, {6, 3, 4}, {2, 3, 6}, {2, 6, 7}};
59 	CHECK(count_supertree(8, c) == 173);
60 	CHECK(check_supertree(8, c));
61 }
62 
63 TEST_CASE("count_supertree_none", "[supertree]") {
64 	constraints c = {{0, 1, 2}, {2, 1, 0}};
65 	CHECK(count_supertree(3, c) == 0);
66 	CHECK(!check_supertree(3, c));
67 }
68 
69 } // namespace tests
70 } // namespace terraces
71