From ef1f27f3a3eaa43b4dbd24cab361b9fe43cdce44 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 2 Jul 2009 10:24:52 -0400 Subject: New deletion unit test. Adds a unit test for deletion and re-adding of the elements to collection. Small syntactical fix in "stack". --- common/collection/collection_stack.c | 2 +- common/collection/collection_ut.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/collection/collection_stack.c b/common/collection/collection_stack.c index 347d9b6c1..70211220c 100644 --- a/common/collection/collection_stack.c +++ b/common/collection/collection_stack.c @@ -94,7 +94,7 @@ int push_binary_property(struct collection_item *stack, return EINVAL; } - error = add_binary_property(stack, NULL, property, binary_data, length) + error = add_binary_property(stack, NULL, property, binary_data, length); TRACE_FLOW_STRING("push_binary_property", "Exit."); return error; diff --git a/common/collection/collection_ut.c b/common/collection/collection_ut.c index 15cebdbf7..c1a4fcf8c 100644 --- a/common/collection/collection_ut.c +++ b/common/collection/collection_ut.c @@ -874,6 +874,39 @@ int insert_extract_test() return EOK; } +int delete_test() +{ + + struct collection_item *col; + int error = EOK; + + printf("\n\n==== DELETION TEST ====\n\n"); + + if ((error = create_collection(&col, "test", 0)) || + (error = add_int_property(col, NULL, "tt", 1)) || + (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = add_int_property(col, NULL, "test", 1)) || + (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) || + (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = add_int_property(col, NULL, "test", 1)) || + (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) || + (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = add_int_property(col, NULL, "test", 1))) { + printf("Error in delete test %d\n", error); + destroy_collection(col); + return error; + } + + debug_collection(col, COL_TRAVERSE_DEFAULT); + + printf("\n\n==== DELETION TEST END ====\n\n"); + + + destroy_collection(col); + return error; +} /* Main function of the unit test */ @@ -887,7 +920,8 @@ int main() (error = add_collection_test()) || (error = mixed_collection_test()) || (error = iterator_test()) || - (error = insert_extract_test())) { + (error = insert_extract_test()) || + (error = delete_test())) { printf("Failed!\n"); } else printf("Success!\n"); -- cgit