Add more tests for tree
This commit is contained in:
1 parent
de00fdc5f7
commit
eb1a7a0435
1 file changed
+30
@@ -293,6 +293,36 @@ static void test_basic(void)
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{2,[{1,[{5}]}]}]}]"));
|
||||
|
||||
int data = 10;
|
||||
tree_move_up(it2, &data);
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{10,[{2,[{1,[{5}]}]}]}]}]"));
|
||||
assert(data == 0);
|
||||
|
||||
data = 11;
|
||||
tree_move_left(it2, &data);
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{10,[{11},{2,[{1,[{5}]}]}]}]}]"));
|
||||
assert(data == 0);
|
||||
|
||||
data = 12;
|
||||
tree_move_right(it2, &data);
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{10,[{11},{2,[{1,[{5}]}]},{12}]}]}]"));
|
||||
assert(data == 0);
|
||||
|
||||
data = 13;
|
||||
tree_move_child(it2, &data);
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{10,[{11},{2,[{13},{1,[{5}]}]},{12}]}]}]"));
|
||||
assert(data == 0);
|
||||
|
||||
data = 14;
|
||||
tree_move_down(it2, &data);
|
||||
tree_get_str(s, t, false);
|
||||
assert(string_equal_str_p(s, "[{0,[{-1,[{3}]},{10,[{11},{2,[{14,[{13},{1,[{5}]}]}]},{12}]}]}]"));
|
||||
assert(data == 0);
|
||||
|
||||
tree_it_set(&it, root);
|
||||
assert(tree_it_equal_p(it, root));
|
||||
|
||||
|
||||
Reference in new issue
Block a user