From 08edf9d6445f3962bf31d5f3c9fa5c9cb363c30d Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Wed, 15 Jul 2009 15:17:53 -0400 Subject: COLLECTION Add remove item functions The remove functions extract and remove items, they act differently from the way the delete_property function works. The new functions allow deletion with the disposition while the delete_property only deletes specified property. The delete_property function is left as is since there are some use cases when it is more efficient to use it rather than new remove_item_xxx ones. --- common/collection/collection_ut.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'common/collection/collection_ut.c') diff --git a/common/collection/collection_ut.c b/common/collection/collection_ut.c index c50a83847..af7746c40 100644 --- a/common/collection/collection_ut.c +++ b/common/collection/collection_ut.c @@ -1194,7 +1194,7 @@ int delete_test(void) struct collection_item *col; int error = EOK; - printf("\n\n==== DELETION TEST ====\n\n"); + printf("\n\n==== DELETION TEST 1====\n\n"); if ((error = col_create_collection(&col, "test", 0)) || (error = col_add_int_property(col, NULL, "tt", 1)) || @@ -1214,11 +1214,35 @@ int delete_test(void) } col_debug_collection(col, COL_TRAVERSE_DEFAULT); + col_destroy_collection(col); - printf("\n\n==== DELETION TEST END ====\n\n"); + printf("\n\n==== DELETION TEST 1 END ====\n\n"); + printf("\n\n==== DELETION TEST 2====\n\n"); + + if ((error = col_create_collection(&col, "test2", 0)) || + (error = col_add_int_property(col, NULL, "tt", 1)) || + (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = col_add_int_property(col, NULL, "test", 1)) || + (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = col_remove_item(col, NULL, COL_DSP_END, NULL, 0, COL_TYPE_ANY)) || + (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = col_add_int_property(col, NULL, "test", 1)) || + (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = col_remove_item_from_current(col, COL_DSP_AFTER, "tt", 0, COL_TYPE_ANY)) || + (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) || + (error = col_add_int_property(col, NULL, "test", 1))) { + printf("Error in delete test %d\n", error); + col_destroy_collection(col); + return error; + } + + col_debug_collection(col, COL_TRAVERSE_DEFAULT); + + printf("\n\n==== DELETION TEST 2 END ====\n\n"); col_destroy_collection(col); + return error; } -- cgit