Add more tests
This commit is contained in:
1 parent
930a3c8637
commit
44209ed93e
2 files changed
+16
-1
No files matched your search
@@ -143,6 +143,7 @@
|
|||||||
\
|
\
|
||||||
static inline bool M_C(name, _is_leaf)(node_t n) \
|
static inline bool M_C(name, _is_leaf)(node_t n) \
|
||||||
{ \
|
{ \
|
||||||
|
/* We consider the empty node as a leaf */ \
|
||||||
return n->num <= 0; \
|
return n->num <= 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
|||||||
+15
-1
@@ -136,9 +136,23 @@ static void test1(void)
|
|||||||
btree_clear(b);
|
btree_clear(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test2(void)
|
||||||
|
{
|
||||||
|
btree_t b;
|
||||||
|
btree_init(b);
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
btree_set_at(b, i, 100*i);
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
assert (*btree_cget(b, i) == 100*i);
|
||||||
|
btree_clean(b);
|
||||||
|
assert (btree_size(b) == 0);
|
||||||
|
assert (btree_empty_p(b));
|
||||||
|
btree_clear(b);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
test1();
|
test1();
|
||||||
|
test2();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user