OCT 1. 增加Doctest单元测试框架
This commit is contained in:
parent
c13bb5d3cd
commit
ec81857489
|
@ -9,6 +9,7 @@ OPTION(USED_LWIP "PPPoE of LWIP support for vCPE" OFF)
|
||||||
OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
||||||
OPTION(USED_OPENDHCPDDNS "DHCP And DNS server for vCPE" OFF)
|
OPTION(USED_OPENDHCPDDNS "DHCP And DNS server for vCPE" OFF)
|
||||||
OPTION(USED_USER_VNI "Support pass user vni id from console command line" OFF)
|
OPTION(USED_USER_VNI "Support pass user vni id from console command line" OFF)
|
||||||
|
option(BUILD_TESTING "Enable tests" OFF)
|
||||||
|
|
||||||
# 数据库开关
|
# 数据库开关
|
||||||
OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
||||||
|
|
|
@ -58,6 +58,10 @@ TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} ${COMMON_LIBS} haywire)
|
||||||
|
|
||||||
IF (USED_OPENDHCPD)
|
IF (USED_OPENDHCPD)
|
||||||
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} opendhcpd)
|
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} opendhcpd)
|
||||||
ENDIF()
|
ENDIF ()
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(${LIB_PROJECT_TARGET} PUBLIC ${PROJECT_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/)
|
TARGET_INCLUDE_DIRECTORIES(${LIB_PROJECT_TARGET} PUBLIC ${PROJECT_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/)
|
||||||
|
|
||||||
|
IF (BUILD_TESTING)
|
||||||
|
ADD_SUBDIRECTORY(unit_test)
|
||||||
|
ENDIF ()
|
|
@ -0,0 +1,8 @@
|
||||||
|
PROJECT(libcommon_utest)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(./ ../include ../../include)
|
||||||
|
|
||||||
|
AUX_SOURCE_DIRECTORY(misc UTEST_SRC)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(${PROJECT_NAME} ${UTEST_SRC})
|
||||||
|
TARGET_LINK_LIBRARIES(${PROJECT_NAME} common)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// Created by xajhuang on 2023/1/31.
|
||||||
|
//
|
||||||
|
// provides main(); this line is required in only one .cpp file
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include "../doctest.h"
|
||||||
|
|
||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
|
TEST_SUITE("Miscellaneous functions") {
|
||||||
|
TEST_CASE("UUID test") {
|
||||||
|
uuid_t msgId;
|
||||||
|
char strMsgId[64];
|
||||||
|
|
||||||
|
memset(msgId, 0, sizeof(msgId));
|
||||||
|
memset(strMsgId, 0, 64);
|
||||||
|
|
||||||
|
uuid_generate_random(msgId);
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(msgId); i++) {
|
||||||
|
CHECK_NE(msgId[0], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid_unparse(msgId, strMsgId);
|
||||||
|
CHECK_EQ(strlen(strMsgId), 36);
|
||||||
|
|
||||||
|
INFO("Random UUID: ", strMsgId);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue