test/rbtree/test_rbtree_delete_fixup.cpp
/**
 * Create an empty rbtree, and verify that rbtree_delete_fixup works correctly.
 */
Create an empty rbtree, and verify that rbtree_delete_fixup works correctly.
Create an empty rbtree and verify that rbtree_delete_fixup works correctly .
TEST(fixup_empty_tree)
{
    allocator* alloc = nullptr;
    rbtree* tree = nullptr;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            rbtree_create(&tree, alloc, &dummy_compare, &dummy_key, nullptr));
    rbtree_delete_fixup(tree, tree->nil);
    TEST_EXPECT(tree->nil == tree->root);
    TEST_EXPECT(RBTREE_BLACK == tree->nil->color);
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(rbtree_resource_handle(tree)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( fixup_empty_tree ) { allocator * alloc = nullptr ; rbtree * tree = nullptr ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == rbtree_create ( & tree , alloc , & dummy_compare , & dummy_key , nullptr ) ) ; rbtree_delete_fixup ( tree , tree -> nil ) ; TEST_EXPECT ( tree -> nil == tree -> root ) ; TEST_EXPECT ( RBTREE_BLACK == tree -> nil -> color ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( rbtree_resource_handle ( tree ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Create an empty rbtree, and verify that rbtree_delete_fixup works correctly.
Create an empty rbtree and verify that rbtree_delete_fixup works correctly .
/* we should be able to create a malloc allocator. */ /* we should be able to create an rbtree instance. */ /* perform the delete fixup. */ /* POSTCONDITIONS. */ /* clean up. */