summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Ellur <vivek.ellur@samsung.com>2015-10-30 04:06:25 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-10-31 02:12:06 +0100
commit85f8daac6d3554f980d8737ee7b904d6a5be203d (patch)
treefae5fca92d95907199699338798fd8289c89ff4e
parentdc391da42430624e1ee91bfba8fc326a9c77ed83 (diff)
eina_hash: add test cases for eina_hash_add/del by hash functions
Summary: Added test cases for eina_hash_add_by_hash/del_by_hash functions Signed-off-by: Vivek Ellur <vivek.ellur@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3245 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/tests/eina/eina_test_hash.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tests/eina/eina_test_hash.c b/src/tests/eina/eina_test_hash.c
index b2f970468b..cc44bffd0a 100644
--- a/src/tests/eina/eina_test_hash.c
+++ b/src/tests/eina/eina_test_hash.c
@@ -418,6 +418,40 @@ START_TEST(eina_hash_seed)
418} 418}
419END_TEST 419END_TEST
420 420
421START_TEST(eina_hash_add_del_by_hash)
422{
423 Eina_Hash *hash = NULL;
424 int array[] = { 1, 42, 4, 5, 6 };
425 int key_len, key_hash;
426
427 fail_if(eina_init() != 2);
428
429 hash = eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
430 EINA_KEY_CMP(_eina_string_key_cmp),
431 EINA_KEY_HASH(eina_hash_crc),
432 NULL,
433 EINA_HASH_BUCKET_SIZE);
434 fail_if(hash == NULL);
435 fail_if(eina_hash_add(hash, "1", &array[0]) != EINA_TRUE);
436 fail_if(eina_hash_add(hash, "42", &array[1]) != EINA_TRUE);
437 fail_if(eina_hash_add(hash, "5", &array[3]) != EINA_TRUE);
438 fail_if(eina_hash_add(hash, "6", &array[4]) != EINA_TRUE);
439
440 key_len = _eina_string_key_length("4");
441 key_hash = eina_hash_crc("4", key_len);
442
443 fail_if(eina_hash_add_by_hash(hash, "4", key_len, key_hash, &array[2]) != EINA_TRUE);
444 fail_if(eina_hash_del_by_hash(hash, "4", key_len, key_hash, &array[2]) != EINA_TRUE);
445 fail_if(eina_hash_del_by_hash(hash, "4", key_len, key_hash, &array[2]) != EINA_FALSE);
446
447 key_len = _eina_string_key_length("42");
448 key_hash = eina_hash_crc("42", key_len);
449 fail_if(eina_hash_del_by_hash(hash, "42", key_len, key_hash, &array[1]) != EINA_TRUE);
450
451 fail_if(eina_hash_population(hash) != 3);
452}
453END_TEST
454
421void eina_test_hash(TCase *tc) 455void eina_test_hash(TCase *tc)
422{ 456{
423 tcase_add_test(tc, eina_hash_simple); 457 tcase_add_test(tc, eina_hash_simple);
@@ -428,4 +462,5 @@ void eina_test_hash(TCase *tc)
428 tcase_add_test(tc, eina_hash_seed); 462 tcase_add_test(tc, eina_hash_seed);
429 tcase_add_test(tc, eina_hash_int32_fuzze); 463 tcase_add_test(tc, eina_hash_int32_fuzze);
430 tcase_add_test(tc, eina_hash_string_fuzze); 464 tcase_add_test(tc, eina_hash_string_fuzze);
465 tcase_add_test(tc, eina_hash_add_del_by_hash);
431} 466}