perf: 删除无效代码;修改变量命名;减少内存分配
This commit is contained in:
@@ -14,6 +14,14 @@ add_executable(gtest_control_packet gtest_control_packet.cpp)
|
||||
target_include_directories(gtest_control_packet PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_link_libraries(gtest_control_packet common gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_packet
|
||||
###############################################################################
|
||||
|
||||
add_executable(gtest_packet gtest_packet.cpp)
|
||||
target_include_directories(gtest_packet PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||
target_link_libraries(gtest_packet common gtest)
|
||||
|
||||
###############################################################################
|
||||
# gtest_utils
|
||||
###############################################################################
|
||||
@@ -37,5 +45,6 @@ target_link_libraries(gtest_health_check_table common gtest platform)
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(gtest_session_table)
|
||||
gtest_discover_tests(gtest_control_packet)
|
||||
gtest_discover_tests(gtest_packet)
|
||||
gtest_discover_tests(gtest_utils)
|
||||
gtest_discover_tests(gtest_health_check_table)
|
||||
|
||||
@@ -146,6 +146,7 @@ TEST(HEALTH_CHECK_TABLE, SET_STATUS)
|
||||
EXPECT_TRUE(health_check_session_del(session_id3, 3) == 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(HEALTH_CHECK_TABLE, DELETE)
|
||||
{
|
||||
uint64_t session_id1 = 0;
|
||||
@@ -194,6 +195,7 @@ TEST(HEALTH_CHECK_TABLE, DELETE)
|
||||
EXPECT_TRUE(health_check_session_del(session_id6, 6) == 0);
|
||||
EXPECT_TRUE(health_check_session_del(session_id6, 6) == -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
2545
common/test/gtest_packet.cpp
Normal file
2545
common/test/gtest_packet.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -41,34 +41,14 @@ TEST(UTILS, SIDS)
|
||||
struct sids src;
|
||||
struct sids dst;
|
||||
|
||||
// set src
|
||||
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
|
||||
{
|
||||
src.elems[i] = i;
|
||||
}
|
||||
src.num = MR_SID_LIST_MAXLEN;
|
||||
|
||||
// copy src to dst
|
||||
memset(&dst, 0, sizeof(struct sids));
|
||||
sids_write_once(&dst, &src);
|
||||
sids_copy(&dst, &src);
|
||||
|
||||
// check dst
|
||||
EXPECT_TRUE(dst.num == src.num);
|
||||
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
|
||||
{
|
||||
EXPECT_TRUE(dst.elems[i] == i);
|
||||
}
|
||||
|
||||
// update src
|
||||
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
|
||||
{
|
||||
src.elems[i] = i * 2;
|
||||
}
|
||||
|
||||
// copy src to dst
|
||||
sids_write_once(&dst, &src);
|
||||
|
||||
// check dst
|
||||
EXPECT_TRUE(dst.num == src.num);
|
||||
for (int i = 0; i < MR_SID_LIST_MAXLEN; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user