@@ -25,6 +25,67 @@ BOOST_AUTO_TEST_SUITE(utreexo_tests)
2525
2626// inferred from rustreexo implementation (no test provided)
2727
28+ BOOST_AUTO_TEST_CASE(utreexo__parent__various__expected)
29+ {
30+ static_assert (parent (0 , 0 ) == 1 );
31+ static_assert (parent (0 , 1 ) == 2 );
32+ static_assert (parent (0 , 2 ) == 4 );
33+ static_assert (parent (0 , 3 ) == 8 );
34+ static_assert (parent (0 , 4 ) == 16 );
35+ static_assert (parent (0 , 5 ) == 32 );
36+ static_assert (parent (0 , 6 ) == 64 );
37+
38+ static_assert (parent (1 , 0 ) == 1 );
39+ static_assert (parent (1 , 1 ) == 2 );
40+ static_assert (parent (1 , 2 ) == 4 );
41+ static_assert (parent (1 , 3 ) == 8 );
42+ static_assert (parent (1 , 4 ) == 16 );
43+ static_assert (parent (1 , 5 ) == 32 );
44+ static_assert (parent (1 , 6 ) == 64 );
45+
46+ static_assert (parent (128 , 0 ) == 64 + 1 );
47+ static_assert (parent (128 , 1 ) == 64 + 2 );
48+ static_assert (parent (128 , 2 ) == 64 + 4 );
49+ static_assert (parent (128 , 3 ) == 64 + 8 );
50+ static_assert (parent (128 , 4 ) == 64 + 16 );
51+ static_assert (parent (128 , 5 ) == 64 + 32 );
52+ static_assert (parent (128 , 6 ) == 64 );
53+
54+ BOOST_REQUIRE_EQUAL (parent (128 , 0 ), 65_u64);
55+ BOOST_REQUIRE_EQUAL (parent (128 , 1 ), 66_u64);
56+ BOOST_REQUIRE_EQUAL (parent (128 , 2 ), 68_u64);
57+ BOOST_REQUIRE_EQUAL (parent (128 , 3 ), 72_u64);
58+ BOOST_REQUIRE_EQUAL (parent (128 , 4 ), 80_u64);
59+ BOOST_REQUIRE_EQUAL (parent (128 , 5 ), 96_u64);
60+ BOOST_REQUIRE_EQUAL (parent (128 , 6 ), 64_u64);
61+ }
62+
63+ BOOST_AUTO_TEST_CASE (utreexo__left_child__various__expected)
64+ {
65+ // same as children()
66+ static_assert (left_child (4 , 2 ) == 0 );
67+ static_assert (left_child (49 , 5 ) == 34 );
68+ static_assert (left_child (50 , 5 ) == 36 );
69+ static_assert (left_child (44 , 5 ) == 24 );
70+ BOOST_REQUIRE_EQUAL (left_child (4 , 2 ), 0_u64);
71+ BOOST_REQUIRE_EQUAL (left_child (49 , 5 ), 34_u64);
72+ BOOST_REQUIRE_EQUAL (left_child (50 , 5 ), 36_u64);
73+ BOOST_REQUIRE_EQUAL (left_child (44 , 5 ), 24_u64);
74+ }
75+
76+ BOOST_AUTO_TEST_CASE (utreexo__right_child__various__expected)
77+ {
78+ // same as add1(children())
79+ static_assert (right_child (4 , 2 ) == 0 + 1 );
80+ static_assert (right_child (49 , 5 ) == 34 + 1 );
81+ static_assert (right_child (50 , 5 ) == 36 + 1 );
82+ static_assert (right_child (44 , 5 ) == 24 + 1 );
83+ BOOST_REQUIRE_EQUAL (right_child (4 , 2 ), 1_u64);
84+ BOOST_REQUIRE_EQUAL (right_child (49 , 5 ), 35_u64);
85+ BOOST_REQUIRE_EQUAL (right_child (50 , 5 ), 37_u64);
86+ BOOST_REQUIRE_EQUAL (right_child (44 , 5 ), 25_u64);
87+ }
88+
2889BOOST_AUTO_TEST_CASE (utreexo__is_root_populated__various__expected)
2990{
3091 static_assert (!is_root_populated (0b00000000 , 0 ));
@@ -66,14 +127,14 @@ BOOST_AUTO_TEST_CASE(utreexo__left_sibling__various__expected)
66127BOOST_AUTO_TEST_CASE (utreexo__start_position_at_row__various__expected)
67128{
68129 // forest_rows must be >= row.
69- static_assert (start_position_at_row (0 , 0 ) == 0_u64 );
70- static_assert (start_position_at_row (0 , 1 ) == 0_u64 );
71- static_assert (start_position_at_row (1 , 1 ) == 2_u64 );
72- static_assert (start_position_at_row (1 , 2 ) == 4_u64 );
73- static_assert (start_position_at_row (1 , 3 ) == 8_u64 );
74- static_assert (start_position_at_row (2 , 2 ) == 6_u64 );
75- static_assert (start_position_at_row (2 , 3 ) == 12_u64 );
76- static_assert (start_position_at_row (3 , 3 ) == 14_u64 );
130+ static_assert (start_position_at_row (0 , 0 ) == 0 );
131+ static_assert (start_position_at_row (0 , 1 ) == 0 );
132+ static_assert (start_position_at_row (1 , 1 ) == 2 );
133+ static_assert (start_position_at_row (1 , 2 ) == 4 );
134+ static_assert (start_position_at_row (1 , 3 ) == 8 );
135+ static_assert (start_position_at_row (2 , 2 ) == 6 );
136+ static_assert (start_position_at_row (2 , 3 ) == 12 );
137+ static_assert (start_position_at_row (3 , 3 ) == 14 );
77138 BOOST_REQUIRE_EQUAL (start_position_at_row (0 , 0 ), 0_u64);
78139 BOOST_REQUIRE_EQUAL (start_position_at_row (0 , 1 ), 0_u64);
79140 BOOST_REQUIRE_EQUAL (start_position_at_row (1 , 1 ), 2_u64);
@@ -86,11 +147,11 @@ BOOST_AUTO_TEST_CASE(utreexo__start_position_at_row__various__expected)
86147
87148BOOST_AUTO_TEST_CASE (utreexo__number_of_roots__various__expected)
88149{
89- static_assert (number_of_roots (0 ) == 0_size );
90- static_assert (number_of_roots (1 ) == 1_size );
91- static_assert (number_of_roots (2 ) == 1_size );
92- static_assert (number_of_roots (3 ) == 2_size );
93- static_assert (number_of_roots (0xfefefefefefefefe ) == (64_size - 8_size ));
150+ static_assert (number_of_roots (0 ) == 0 );
151+ static_assert (number_of_roots (1 ) == 1 );
152+ static_assert (number_of_roots (2 ) == 1 );
153+ static_assert (number_of_roots (3 ) == 2 );
154+ static_assert (number_of_roots (0xfefefefefefefefe ) == (64 - 8 ));
94155 BOOST_REQUIRE_EQUAL (number_of_roots (0 ), 0_size);
95156 BOOST_REQUIRE_EQUAL (number_of_roots (1 ), 1_size);
96157 BOOST_REQUIRE_EQUAL (number_of_roots (2 ), 1_size);
@@ -131,10 +192,10 @@ BOOST_AUTO_TEST_CASE(utreexo__is_sibling__various__expected)
131192// github.com/mit-dci/rustreexo/blob/main/src/accumulator/util.rs#L474
132193BOOST_AUTO_TEST_CASE (utreexo__children__various__expected)
133194{
134- static_assert (children (4 , 2 ) == 0_u64 );
135- static_assert (children (49 , 5 ) == 34_u64 );
136- static_assert (children (50 , 5 ) == 36_u64 );
137- static_assert (children (44 , 5 ) == 24_u64 );
195+ static_assert (children (4 , 2 ) == 0 );
196+ static_assert (children (49 , 5 ) == 34 );
197+ static_assert (children (50 , 5 ) == 36 );
198+ static_assert (children (44 , 5 ) == 24 );
138199 BOOST_REQUIRE_EQUAL (children (4 , 2 ), 0_u64);
139200 BOOST_REQUIRE_EQUAL (children (49 , 5 ), 34_u64);
140201 BOOST_REQUIRE_EQUAL (children (50 , 5 ), 36_u64);
@@ -151,10 +212,10 @@ BOOST_AUTO_TEST_CASE(utreexo__is_root_position__various__expected)
151212// github.com/mit-dci/rustreexo/blob/main/src/accumulator/util.rs#L424
152213BOOST_AUTO_TEST_CASE (utreexo__tree_rows__various__expected)
153214{
154- static_assert (tree_rows (8 ) == 3_u8 );
155- static_assert (tree_rows (9 ) == 4_u8 );
156- static_assert (tree_rows (12 ) == 4_u8 );
157- static_assert (tree_rows (255 ) == 8_u8 );
215+ static_assert (tree_rows (8 ) == 3 );
216+ static_assert (tree_rows (9 ) == 4 );
217+ static_assert (tree_rows (12 ) == 4 );
218+ static_assert (tree_rows (255 ) == 8 );
158219 BOOST_REQUIRE_EQUAL (tree_rows (8 ), 3_u8);
159220 BOOST_REQUIRE_EQUAL (tree_rows (9 ), 4_u8);
160221 BOOST_REQUIRE_EQUAL (tree_rows (12 ), 4_u8);
@@ -199,8 +260,8 @@ BOOST_AUTO_TEST_CASE(utreexo__detect_row__scenario__expected)
199260// github.com/mit-dci/rustreexo/blob/main/src/accumulator/util.rs#L359
200261BOOST_AUTO_TEST_CASE (utreexo__root_position__various__expected)
201262{
202- static_assert (root_position (5 , 2 , 3 ) == 12_u64 );
203- static_assert (root_position (5 , 0 , 3 ) == 4_u64 );
263+ static_assert (root_position (5 , 2 , 3 ) == 12 );
264+ static_assert (root_position (5 , 0 , 3 ) == 4 );
204265 BOOST_REQUIRE_EQUAL (root_position (5 , 2 , 3 ), 12_u64);
205266 BOOST_REQUIRE_EQUAL (root_position (5 , 0 , 3 ), 4_u64);
206267}
0 commit comments