diff options
| author | luwenpeng <[email protected]> | 2024-03-14 10:56:09 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-03-14 18:03:34 +0800 |
| commit | ce0012255735ca2d680d23acf9f954dbf5bc7d39 (patch) | |
| tree | a9b24e1b5542391757676f07d6d1bba49b3eb854 /deps | |
| parent | 639614622b2cbe937740af078b76b4956f9ce7ce (diff) | |
Refactor the session manager using session transformation 2D array & Update test case
Diffstat (limited to 'deps')
| -rw-r--r-- | deps/dablooms/test/gtest_dablooms.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/deps/dablooms/test/gtest_dablooms.cpp b/deps/dablooms/test/gtest_dablooms.cpp index 5292873..7dc9468 100644 --- a/deps/dablooms/test/gtest_dablooms.cpp +++ b/deps/dablooms/test/gtest_dablooms.cpp @@ -41,25 +41,16 @@ struct packet_idetify idetify = { TEST(DABLOOMS, TEST) { - struct expiry_dablooms_handle *handle = expiry_dablooms_new(config.capacity, config.error_rate, time(NULL), config.expiry_time); + struct expiry_dablooms_handle *handle = expiry_dablooms_new(config.capacity, config.error_rate, 1, config.expiry_time); EXPECT_TRUE(handle != nullptr); - EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), time(NULL)) != 1); // no exist - EXPECT_TRUE(expiry_dablooms_add(handle, (const char *)&idetify, sizeof(idetify), time(NULL)) == 0); // add - - for (int i = 0; i < 5; i++) - { - if (i < config.expiry_time) - { - EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), time(NULL)) == 1); // exist - } - else - { - EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), time(NULL)) != 1); // no exist - } - sleep(1); - printf("sleep[%02d] 1s\n", i); - } + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 1) != 1); // no exist + EXPECT_TRUE(expiry_dablooms_add(handle, (const char *)&idetify, sizeof(idetify), 1) == 0); // add + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 1) == 1); // exist + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 2) == 1); // exist + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 3) == 1); // exist + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 4) == 0); // not exist + EXPECT_TRUE(expiry_dablooms_search(handle, (const char *)&idetify, sizeof(idetify), 5) == 0); // not exist expiry_dablooms_free(handle); } |
