diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-20 17:06:55 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-20 17:06:55 -0600 |
| commit | 2a9f5f30b3a0bd62cc9889d291a7dd18dc258e51 (patch) | |
| tree | 1d5aaa578f89ac51d096ca2fa742f3797727640b /src/03/rb_tree_test.c | |
| parent | e1466ec3d4b2e641329d62e382f036e8d6ad8395 (diff) | |
test: ensure rb node parents are equal
Diffstat (limited to 'src/03/rb_tree_test.c')
| -rw-r--r-- | src/03/rb_tree_test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/03/rb_tree_test.c b/src/03/rb_tree_test.c index 1bf4e5a..3fca748 100644 --- a/src/03/rb_tree_test.c +++ b/src/03/rb_tree_test.c @@ -226,6 +226,19 @@ Ensure(equals_returns_false_when_root_and_right_subtree_are_not_equal) { assert_that(rb_equals(tree, other_tree), is_equal_to(false)); } +Ensure(equals_returns_false_when_parent_is_not_equal) { + RBTree *tree = rb_tree_initialize(20); + tree = rb_tree_insert(tree, 30); + + RBTree *other_tree = rb_tree_initialize(20); + other_tree = rb_tree_insert(other_tree, 30); + + other_tree->right->parent = NULL; + + assert_that(rb_equals(tree, other_tree), is_equal_to(false)); + assert_that(rb_equals(other_tree, tree), is_equal_to(false)); +} + Ensure(is_valid_returns_false_when_root_is_red) { RBTree *tree = rb_tree_initialize(20); tree->colour = red; @@ -286,6 +299,7 @@ TestSuite *rb_tree_tests() { add_test(x, equals_returns_true_when_root_and_left_subtree_are_equal); add_test(x, equals_returns_false_when_root_and_left_subtree_are_not_equal); add_test(x, equals_returns_false_when_root_and_right_subtree_are_not_equal); + add_test(x, equals_returns_false_when_parent_is_not_equal); add_test(x, is_valid_returns_false_when_root_is_red); add_test(x, is_valid_returns_false_when_red_node_has_red_child); |
