Add session table & session

This commit is contained in:
luwenpeng
2023-12-11 16:35:26 +08:00
parent 015b4e7695
commit 006315fb7c
12 changed files with 1024 additions and 20 deletions

View File

@@ -12,32 +12,45 @@ TEST(SESSION_POOL, POP_PUSH)
sess_pool = session_pool_create(3);
EXPECT_TRUE(sess_pool != NULL);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
sess1 = session_pool_pop(sess_pool);
sess1 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess1 != NULL);
sess2 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
sess2 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess2 != NULL);
sess3 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
sess3 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess3 != NULL);
sess4 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 0);
sess4 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess4 == NULL);
session_pool_push(sess_pool, sess1);
session_pool_push(sess_pool, sess2);
session_pool_push(sess_pool, sess3);
session_pool_free(sess_pool, sess1);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
session_pool_free(sess_pool, sess2);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
session_pool_free(sess_pool, sess3);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
sess1 = session_pool_pop(sess_pool);
sess1 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess1 != NULL);
sess2 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
sess2 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess2 != NULL);
sess3 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
sess3 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess3 != NULL);
sess4 = session_pool_pop(sess_pool);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 0);
sess4 = session_pool_alloc(sess_pool);
EXPECT_TRUE(sess4 == NULL);
session_pool_push(sess_pool, sess1);
session_pool_push(sess_pool, sess2);
session_pool_push(sess_pool, sess3);
session_pool_free(sess_pool, sess1);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
session_pool_free(sess_pool, sess2);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
session_pool_free(sess_pool, sess3);
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
session_pool_destroy(sess_pool);
}