Refactor the session manager using session transformation 2D array & Update test case

This commit is contained in:
luwenpeng
2024-03-14 10:56:09 +08:00
parent 639614622b
commit ce00122557
47 changed files with 3403 additions and 3563 deletions

View File

@@ -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);
}