Skip to content
Snippets Groups Projects
Commit 172741e8 authored by Florian Burgener's avatar Florian Burgener
Browse files

Add a new test case

parent d24026fa
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,20 @@ static bool check_if_the_leaf_nodes_are_correctly_chained(BPTreeNode *root) { ...@@ -46,6 +46,20 @@ static bool check_if_the_leaf_nodes_are_correctly_chained(BPTreeNode *root) {
return true; 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) { static bool check_if_all_leaf_nodes_have_as_many_keys_as_data(BPTreeNode *root) {
if (root->is_leaf) { if (root->is_leaf) {
return root->keys->size == root->data->size; return root->keys->size == root->data->size;
...@@ -204,6 +218,7 @@ static bool check_BPTree_compliance(BPTreeNode *root) { ...@@ -204,6 +218,7 @@ static bool check_BPTree_compliance(BPTreeNode *root) {
bool is_compliant = true; bool is_compliant = true;
is_compliant &= check_if_the_leaf_nodes_are_correctly_chained(root); 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_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); is_compliant &= check_if_all_leaf_nodes_are_at_the_same_depth(root, compute_first_leaf_depth(root), 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment