Branch Coverage

rbtree.c
Criterion Covered Total %
branch 224 316 70.8


line true false branch
59 3 272 if (IS_SENTINEL(node)) return NULL;
60 554 272 while (NOT_SENTINEL(node->left))
66 1 139 if (IS_SENTINEL(node)) return NULL;
67 448 139 while (NOT_SENTINEL(node->right))
74 0 0 while (NOT_SENTINEL(node->right))
76 0 0 return IS_SENTINEL(node)? NULL : node;
81 0 0 while (NOT_SENTINEL(node->left))
83 0 0 return IS_SENTINEL(node)? NULL : node;
87 596 0 while (node && node->parent)
419 177 while (node && node->parent)
91 177 0 return node && node->right && node->right->right == node->right? node : NULL;
151 26 return node && node->right && node->right->right == node->right? node : NULL;
151 0 return node && node->right && node->right->right == node->right? node : NULL;
95 5 513 if (IS_SENTINEL(node)) return NULL;
98 184 329 if (NOT_SENTINEL(node->left)) {
100 41 184 while (NOT_SENTINEL(node->right))
107 279 268 while (parent->left == node) {
111 61 218 if (!parent) return NULL;
118 4 1001850 if (IS_SENTINEL(node)) return NULL;
121 287974 713876 if (NOT_SENTINEL(node->right)) {
123 250092 287974 while (NOT_SENTINEL(node->left))
130 0 713876 assert(parent);
131 9520210 713876 while (parent->right == node) {
132 0 9520210 assert(parent != parent->parent);
137 350987 362889 if (!parent->parent) return NULL;
154 15743 0 if (IS_ROOTSENTINEL(node))
157 320265 15362 while (NOT_SENTINEL(node)) {
160 81004 239261 if (cmp<0) node= node->left;
161 238880 381 else if (cmp>0) node= node->right;
164 15642 101 if (nearest && last_cmp_out)
15642 0 if (nearest && last_cmp_out)
181 76 3 if (IS_ROOTSENTINEL(node))
184 185 13 while (NOT_SENTINEL(node)) {
187 56 129 if (cmp<0) node= node->left;
188 63 66 else if (cmp>0) node= node->right;
191 13 66 if (IS_SENTINEL(node)) {
193 13 0 if (result_first)
194 13 0 *result_first= nearest && cmp < 0? rbtree_node_prev(nearest) : nearest;
4 9 *result_first= nearest && cmp < 0? rbtree_node_prev(nearest) : nearest;
195 13 0 if (result_last)
196 13 0 *result_last= nearest && cmp > 0? rbtree_node_next(nearest) : nearest;
9 4 *result_last= nearest && cmp > 0? rbtree_node_next(nearest) : nearest;
197 3 10 if (result_count) *result_count= 0;
202 1 65 if (result_first || result_count) {
1 0 if (result_first || result_count) {
206 45 66 while (NOT_SENTINEL(test)) {
208 4 41 if (cmp == 0) {
216 65 1 if (result_first) *result_first= first;
218 2 64 if (result_last || result_count) {
2 0 if (result_last || result_count) {
222 51 66 while (NOT_SENTINEL(test)) {
224 6 45 if (cmp == 0) {
232 64 2 if (result_last) *result_last= last;
233 23 43 if (result_count) *result_count= count;
241 2 2 while (NOT_SENTINEL(test)) {
242 2 0 if (0 == compare(ctx, PTR_OFS(test,cmp_ptr_ofs), PTR_OFS(node,cmp_ptr_ofs) )) {
255 16 22 while (NOT_SENTINEL(test)) {
256 7 9 if (0 == compare(ctx, PTR_OFS(test,cmp_ptr_ofs), PTR_OFS(node,cmp_ptr_ofs) )) {
271 0 0 if (NODE_IS_IN_TREE(node))
274 0 0 if (IS_ROOTSENTINEL(hint)) {
275 0 0 if (IS_SENTINEL(hint->left)) {
293 0 0 if (cmp < 0) {
300 0 0 if (IS_SENTINEL(next))
306 0 0 if (NOT_ROOTSENTINEL(hint->parent) && (cmp < 0? leftmost : rightmost)) {
0 0 if (NOT_ROOTSENTINEL(hint->parent) && (cmp < 0? leftmost : rightmost)) {
0 0 if (NOT_ROOTSENTINEL(hint->parent) && (cmp < 0? leftmost : rightmost)) {
311 0 0 if ((cmp < 0? parent->right : parent->left) == hint) {
0 0 if ((cmp < 0? parent->right : parent->left) == hint) {
312 0 0 if ((cmp < 0) == (compare(ctx, PTR_OFS(node,cmp_ptr_ofs), PTR_OFS(parent,cmp_ptr_ofs)) < 0)) {
314 0 0 while (NOT_ROOTSENTINEL(parent->parent))
320 0 0 else if (IS_ROOTSENTINEL(parent->parent))
325 0 0 if (cmp < 0)
335 0 0 for (parent= pos; NOT_ROOTSENTINEL(parent); parent= parent->parent)
349 7667 3 if (IS_SENTINEL(parent->left)) {
355 0 3 while (!IS_SENTINEL(parent->right))
365 151635 7670 for (tmp= parent; NOT_ROOTSENTINEL(tmp); tmp= tmp->parent)
378 463378 29980 if (IS_SENTINEL(parent->right)) {
384 2 29980 while (!IS_SENTINEL(parent->left))
394 12529852 493358 for (tmp= parent; NOT_ROOTSENTINEL(tmp); tmp= tmp->parent)
406 47488 19198 if (parent->right == node) parent->right= new_head;
423 398600 81954 if (parent->right == node) parent->right= new_head;
443 955598 20071 while (IS_RED(current)) {
449 887325 68273 if (parent->right == current) {
451 472612 414713 if (IS_RED(parent->left)) {
461 439 414274 if (IS_RED(current->left))
473 2029 66244 if (IS_RED(parent->right)) {
483 65815 429 if (IS_RED(current->right))
503 1868745 100916 while (NOT_SENTINEL(node)) {
504 1663758 204987 if (node->right == prev)
516 150 644 if (index >= GET_COUNT(node))
518 1448 644 while (index != GET_COUNT(node->left)) {
519 450 998 if (index < GET_COUNT(node->left))
537 0 141 if (GET_COUNT(current) == 0)
541 47 94 if (IS_SENTINEL(current->left) || IS_SENTINEL(current->right))
22 25 if (IS_SENTINEL(current->left) || IS_SENTINEL(current->right))
550 3 22 : rbtree_node_next( current );
564 22 3 if (temp->left == current) temp->left= successor; else temp->right= successor;
580 119 22 sentinel= IS_SENTINEL(node->left)? node->left : node->right;
583 382 141 for (current= node; NOT_ROOTSENTINEL(current); current= current->parent)
588 48 93 if (IS_RED(node)) {
589 20 28 if (leftside) parent->left= sentinel;
595 22 71 if (node->left != sentinel) {
599 22 0 if (leftside) parent->left= node->left;
603 24 47 if (node->right != sentinel) {
607 16 8 if (leftside) parent->left= node->right;
623 40 7 if (leftside) parent->left= sentinel; else parent->right= sentinel;
625 40 7 sibling= (leftside)? parent->right : parent->left;
630 82 23 while (IS_BLACK(current) && NOT_ROOTSENTINEL(parent)) {
68 14 while (IS_BLACK(current) && NOT_ROOTSENTINEL(parent)) {
636 16 52 if (IS_RED(sibling)) {
639 16 0 if (leftside) {
654 45 7 if (IS_BLACK(sibling->right) && IS_BLACK(sibling->left)) {
42 3 if (IS_BLACK(sibling->right) && IS_BLACK(sibling->left)) {
655 0 42 assert(NOT_SENTINEL(sibling));
662 35 7 sibling= (leftside)? parent->right : parent->left;
679 10 0 if (leftside) {
680 3 7 if (IS_BLACK(sibling->right)) { // Case 3 from the text
686 0 10 assert(NOT_SENTINEL(sibling));
696 0 0 if (IS_BLACK(sibling->left)) { // Case 3 from the text
702 0 0 assert(NOT_SENTINEL(sibling));
730 0 114 if (!IS_ROOTSENTINEL(root_sentinel))
732 19 95 if (IS_SENTINEL(root_sentinel->left))
737 250499 250388 if (NOT_SENTINEL(current->left)) {
742 250483 250404 if (NOT_SENTINEL(current->right)) {
751 500887 0 if (destructor) destructor(PTR_OFS(current,obj_ofs), ctx);
753 95 500792 if (current == root_sentinel)
755 250388 250404 else if (from_left)
770 19 0 if (node && !node->parent) {
19 0 if (node && !node->parent) {
771 19 0 if (IS_RED(node) || IS_RED(node->left) || GET_COUNT(node) || GET_COUNT(node->right))
19 0 if (IS_RED(node) || IS_RED(node->left) || GET_COUNT(node) || GET_COUNT(node->right))
19 0 if (IS_RED(node) || IS_RED(node->left) || GET_COUNT(node) || GET_COUNT(node->right))
0 19 if (IS_RED(node) || IS_RED(node->left) || GET_COUNT(node) || GET_COUNT(node->right))
773 19 0 if (GET_COUNT(node->right) || IS_RED(node->right) || node->right->left != node->right
19 0 if (GET_COUNT(node->right) || IS_RED(node->right) || node->right->left != node->right
19 0 if (GET_COUNT(node->right) || IS_RED(node->right) || node->right->left != node->right
774 0 19 || node->right->right != node->right)
776 0 19 if (node->left == node->right) return 0; /* empty tree, nothing more to check */
777 0 19 if (node->left->parent != node)
787 500010 0 if (!node || !node->parent || !node->left || !node->right || !GET_COUNT(node))
500010 0 if (!node || !node->parent || !node->left || !node->right || !GET_COUNT(node))
500010 0 if (!node || !node->parent || !node->left || !node->right || !GET_COUNT(node))
500010 0 if (!node || !node->parent || !node->left || !node->right || !GET_COUNT(node))
0 500010 if (!node || !node->parent || !node->left || !node->right || !GET_COUNT(node))
790 0 500010 if (GET_COUNT(node) != GET_COUNT(node->left) + GET_COUNT(node->right) + 1)
794 249992 250018 if (NOT_SENTINEL(node->left)) {
795 0 249992 if (node->left->parent != node)
797 10967 239025 if (IS_RED(node) && IS_RED(node->left))
0 10967 if (IS_RED(node) && IS_RED(node->left))
799 0 249992 if (compare(ctx, PTR_OFS(node->left, cmp_pointer_ofs), PTR_OFS(node, cmp_pointer_ofs)) > 0)
802 0 249992 if (err) return err;
804 249999 250011 if (NOT_SENTINEL(node->right)) {
805 0 249999 if (node->right->parent != node)
807 10967 239032 if (IS_RED(node) && IS_RED(node->right))
0 10967 if (IS_RED(node) && IS_RED(node->right))
809 0 249999 if (compare(ctx, PTR_OFS(node->right, cmp_pointer_ofs), PTR_OFS(node, cmp_pointer_ofs)) < 0)
812 0 249999 if (err) return err;
814 0 500010 if (left_black_count != right_black_count)