diff options
author | Joshua Kahn <jkahn@barracuda.com> | 2015-09-21 21:14:55 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2015-11-09 23:56:24 (GMT) |
commit | 710ca112e31e8621177d08162f60158c27dd2974 (patch) | |
tree | 5ab1d03e15abe401d42025bc6cce819d2b1b1a0f /test/unit/rb.c | |
parent | e8ab0ab9c0e395d3c09398fa981704a9be968838 (diff) | |
download | jemalloc-710ca112e31e8621177d08162f60158c27dd2974.zip jemalloc-710ca112e31e8621177d08162f60158c27dd2974.tar.gz jemalloc-710ca112e31e8621177d08162f60158c27dd2974.tar.bz2 |
Add test for tree destruction
Diffstat (limited to 'test/unit/rb.c')
-rw-r--r-- | test/unit/rb.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/unit/rb.c b/test/unit/rb.c index 0262037..14132c1 100644 --- a/test/unit/rb.c +++ b/test/unit/rb.c @@ -212,6 +212,15 @@ remove_reverse_iterate_cb(tree_t *tree, node_t *node, void *data) return (ret); } +static void +destroy_cb(node_t *node, void *data) +{ + unsigned *nnodes = (unsigned *)data; + + assert_u_gt(*nnodes, 0, "Destruction removed too many nodes"); + (*nnodes)--; +} + TEST_BEGIN(test_rb_random) { #define NNODES 25 @@ -278,7 +287,7 @@ TEST_BEGIN(test_rb_random) } /* Remove nodes. */ - switch (i % 4) { + switch (i % 5) { case 0: for (k = 0; k < j; k++) node_remove(&tree, &nodes[k], j - k); @@ -314,6 +323,12 @@ TEST_BEGIN(test_rb_random) assert_u_eq(nnodes, 0, "Removal terminated early"); break; + } case 4: { + unsigned nnodes = j; + tree_destroy(&tree, destroy_cb, &nnodes); + assert_u_eq(nnodes, 0, + "Destruction terminated early"); + break; } default: not_reached(); } |