diff options
author | Dmitri Pal <dpal@redhat.com> | 2009-09-27 22:18:41 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-10-05 10:32:07 -0400 |
commit | ea7d823fa584b36e9a34a43c32dc476beede5ea2 (patch) | |
tree | bf3080e4b0b14c26cf4080d6c6d11d6781a0b471 /common/collection/collection_ut.c | |
parent | 26a9c1f22f31a87a83fbb59caea7c7565563f479 (diff) | |
download | sssd-ea7d823fa584b36e9a34a43c32dc476beede5ea2.tar.gz sssd-ea7d823fa584b36e9a34a43c32dc476beede5ea2.tar.xz sssd-ea7d823fa584b36e9a34a43c32dc476beede5ea2.zip |
COLLECTION Enhancing hashing and iteration functions
Diffstat (limited to 'common/collection/collection_ut.c')
-rw-r--r-- | common/collection/collection_ut.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/common/collection/collection_ut.c b/common/collection/collection_ut.c index 5d0c58463..1e91c2326 100644 --- a/common/collection/collection_ut.c +++ b/common/collection/collection_ut.c @@ -594,6 +594,8 @@ int iterator_test(void) int idepth = 0; int len = 0; int i; + uint64_t hash1, hash2; + int rwnd = 0; printf("\n\n==== ITERATOR TEST ====\n\n"); @@ -785,10 +787,34 @@ int iterator_test(void) printf("Item length: %d\n", len); len = 0; + hash1 = col_make_hash("new_name", 0, &len); printf("String name: %s\n", "new_name"); - printf("String hash: %lu\n", (unsigned long int)col_make_hash("new_name", &len)); + printf("String hash: %lu\n", (unsigned long int)hash1); printf("String length: %d\n", len); + len = 0; + hash2 = col_make_hash("new_name_suffix", 8, &len); + printf("String name: %.*s\n", len, "new_name_suffix"); + printf("String hash: %lu\n", (unsigned long int)hash2); + printf("String length: %d\n", len); + if (hash1 != hash2) { + printf("Hash calculation failed\n"); + col_unbind_iterator(iterator); + col_destroy_collection(peer); + return EINVAL; + } + + hash2 = col_make_hash("new_name", 8, &len); + printf("String name: %.*s\n", len, "new_name"); + printf("String hash: %lu\n", (unsigned long int)hash2); + printf("String length: %d\n", len); + if (hash1 != hash2) { + printf("Hash calculation failed\n"); + col_unbind_iterator(iterator); + col_destroy_collection(peer); + return EINVAL; + } + } } while(1); @@ -824,6 +850,13 @@ int iterator_test(void) printf("%*s", depth * 4, ""); col_debug_item(item); + if ((strcmp(col_get_item_property(item, NULL), "queue") == 0) && + (rwnd == 0)) { + printf("Rewinding iterator...\n"); + col_rewind_iterator(iterator); + rwnd++; + } + } while(1); |