Refactor the session manager using session transformation 2D array & Update test case
This commit is contained in:
25
deps/dablooms/test/gtest_dablooms.cpp
vendored
25
deps/dablooms/test/gtest_dablooms.cpp
vendored
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user