Add session pool
This commit is contained in:
49
src/session/gtest_session_pool.cpp
Normal file
49
src/session/gtest_session_pool.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "session_pool.h"
|
||||
|
||||
TEST(SESSION_POOL, POP_PUSH)
|
||||
{
|
||||
struct session *sess1 = NULL;
|
||||
struct session *sess2 = NULL;
|
||||
struct session *sess3 = NULL;
|
||||
struct session *sess4 = NULL;
|
||||
struct session_pool *sess_pool = NULL;
|
||||
|
||||
sess_pool = session_pool_create(3);
|
||||
EXPECT_TRUE(sess_pool != NULL);
|
||||
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
sess4 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess4 == NULL);
|
||||
|
||||
session_pool_push(sess_pool, sess1);
|
||||
session_pool_push(sess_pool, sess2);
|
||||
session_pool_push(sess_pool, sess3);
|
||||
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
sess4 = session_pool_pop(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_destroy(sess_pool);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user