diff --git a/src/tests/BPTreeTests.c b/src/tests/BPTreeTests.c index 4e05be02e4b96951b07338e1f29f734314f4907e..511a8dc9e167f97b0d8ff85dd5e228b116e9601b 100644 --- a/src/tests/BPTreeTests.c +++ b/src/tests/BPTreeTests.c @@ -46,6 +46,20 @@ static bool check_if_the_leaf_nodes_are_correctly_chained(BPTreeNode *root) { return true; } +static bool check_if_all_leaf_nodes_nodes_have_no_children(BPTreeNode *root) { + if (root->is_leaf) { + return root->children->size == 0; + } + + for (int i = 0; i < root->children->size; i++) { + if (!check_if_all_leaf_nodes_nodes_have_no_children(root->children->items[i])) { + return false; + } + } + + return true; +} + static bool check_if_all_leaf_nodes_have_as_many_keys_as_data(BPTreeNode *root) { if (root->is_leaf) { return root->keys->size == root->data->size; @@ -204,6 +218,7 @@ static bool check_BPTree_compliance(BPTreeNode *root) { bool is_compliant = true; is_compliant &= check_if_the_leaf_nodes_are_correctly_chained(root); + is_compliant &= check_if_all_leaf_nodes_nodes_have_no_children(root); is_compliant &= check_if_all_leaf_nodes_have_as_many_keys_as_data(root); is_compliant &= check_if_all_leaf_nodes_are_at_the_same_depth(root, compute_first_leaf_depth(root), 0);