Add no-OOM assertions to test.

This commit is contained in:
Jason Evans 2015-08-07 00:51:11 -07:00
parent 8fadb1a8c2
commit 4be0c3ca42

View File

@ -39,11 +39,13 @@ TEST_BEGIN(test_rtree_extrema)
assert_false(rtree_new(&rtree, i, node_alloc, node_dalloc),
"Unexpected rtree_new() failure");
rtree_set(&rtree, 0, &node_a);
assert_false(rtree_set(&rtree, 0, &node_a),
"Unexpected rtree_set() failure");
assert_ptr_eq(rtree_get(&rtree, 0, true), &node_a,
"rtree_get() should return previously set value");
rtree_set(&rtree, ~((uintptr_t)0), &node_b);
assert_false(rtree_set(&rtree, ~((uintptr_t)0), &node_b),
"Unexpected rtree_set() failure");
assert_ptr_eq(rtree_get(&rtree, ~((uintptr_t)0), true), &node_b,
"rtree_get() should return previously set value");
@ -66,7 +68,8 @@ TEST_BEGIN(test_rtree_bits)
"Unexpected rtree_new() failure");
for (j = 0; j < sizeof(keys)/sizeof(uintptr_t); j++) {
rtree_set(&rtree, keys[j], &node);
assert_false(rtree_set(&rtree, keys[j], &node),
"Unexpected rtree_set() failure");
for (k = 0; k < sizeof(keys)/sizeof(uintptr_t); k++) {
assert_ptr_eq(rtree_get(&rtree, keys[k], true),
&node, "rtree_get() should return "
@ -79,7 +82,8 @@ TEST_BEGIN(test_rtree_bits)
(((uintptr_t)1) << (sizeof(uintptr_t)*8-i)), false),
"Only leftmost rtree leaf should be set; "
"i=%u, j=%u", i, j);
rtree_set(&rtree, keys[j], NULL);
assert_false(rtree_set(&rtree, keys[j], NULL),
"Unexpected rtree_set() failure");
}
rtree_delete(&rtree);
@ -106,7 +110,8 @@ TEST_BEGIN(test_rtree_random)
for (j = 0; j < NSET; j++) {
keys[j] = (uintptr_t)gen_rand64(sfmt);
rtree_set(&rtree, keys[j], &node);
assert_false(rtree_set(&rtree, keys[j], &node),
"Unexpected rtree_set() failure");
assert_ptr_eq(rtree_get(&rtree, keys[j], true), &node,
"rtree_get() should return previously set value");
}
@ -116,7 +121,8 @@ TEST_BEGIN(test_rtree_random)
}
for (j = 0; j < NSET; j++) {
rtree_set(&rtree, keys[j], NULL);
assert_false(rtree_set(&rtree, keys[j], NULL),
"Unexpected rtree_set() failure");
assert_ptr_null(rtree_get(&rtree, keys[j], true),
"rtree_get() should return previously set value");
}