diff options
author | Igor Sysoev <igor@sysoev.ru> | 2018-03-29 16:35:32 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2018-03-29 16:35:32 +0300 |
commit | aad7752527faf674bcb01408e997769ba48756d7 (patch) | |
tree | 007a63d8b391ea39a1ccceb1a46b14f822e4fd29 /src/test | |
parent | 8a4c8d64b264f5f8eb9951f26ee1af3ddd1c01f6 (diff) | |
download | unit-aad7752527faf674bcb01408e997769ba48756d7.tar.gz unit-aad7752527faf674bcb01408e997769ba48756d7.tar.bz2 |
nxt_lvlhsh_retrieve().
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/nxt_lvlhsh_test.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/nxt_lvlhsh_test.c b/src/test/nxt_lvlhsh_test.c index c808192c..fca6ed30 100644 --- a/src/test/nxt_lvlhsh_test.c +++ b/src/test/nxt_lvlhsh_test.c @@ -222,6 +222,43 @@ nxt_lvlhsh_test(nxt_thread_t *thr, nxt_uint_t n, nxt_bool_t use_pool) return NXT_ERROR; } + if (!nxt_lvlhsh_is_empty(&lh)) { + nxt_log_error(NXT_LOG_NOTICE, thr->log, + "lvlhsh is not empty after deletion"); + return NXT_ERROR; + } + + key = 0; + for (i = 0; i < n; i++) { + key = nxt_murmur_hash2(&key, sizeof(uint32_t)); + + if (nxt_lvlhsh_test_add(&lh, proto, mp, key) != NXT_OK) { + nxt_log_error(NXT_LOG_NOTICE, thr->log, + "lvlhsh add test failed at %ui", i); + return NXT_ERROR; + } + } + + for (i = 0; i < n; i++) { + value = nxt_lvlhsh_retrieve(&lh, proto, mp); + + if (value == NULL) { + break; + } + } + + if (i != n) { + nxt_log_error(NXT_LOG_NOTICE, thr->log, + "lvlhsh retrieve test failed at %ui of %ui", i, n); + return NXT_ERROR; + } + + if (!nxt_lvlhsh_is_empty(&lh)) { + nxt_log_error(NXT_LOG_NOTICE, thr->log, + "lvlhsh is not empty after retrieving"); + return NXT_ERROR; + } + if (mp != NULL) { if (!nxt_mp_is_empty(mp)) { nxt_log_error(NXT_LOG_NOTICE, thr->log, "mem pool is not empty"); |