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.c | |
| parent | e1466ec3d4b2e641329d62e382f036e8d6ad8395 (diff) | |
test: ensure rb node parents are equal
Diffstat (limited to 'src/03/rb_tree.c')
| -rw-r--r-- | src/03/rb_tree.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/03/rb_tree.c b/src/03/rb_tree.c index d1861f5..802791e 100644 --- a/src/03/rb_tree.c +++ b/src/03/rb_tree.c @@ -231,6 +231,15 @@ bool rb_equals(RBTree *tree, RBTree *other_tree) { if (!tree || !other_tree) return tree == other_tree; + if (tree->parent && !other_tree->parent) + return false; + + if (!tree->parent && other_tree->parent) + return false; + + if (tree->parent && tree->parent->value != other_tree->parent->value) + return false; + return tree->value == other_tree->value && tree->colour == other_tree->colour && rb_equals(tree->left, other_tree->left) |
