增加了udp的测试代码,增加了时间获取函数,完善了ccu发送指令的函数

This commit is contained in:
zjk
2025-02-18 16:57:11 +08:00
parent 2599050c1f
commit a179789b3f
12 changed files with 247 additions and 99 deletions
+18
View File
@@ -17,6 +17,24 @@ find_package(Catch2 REQUIRED)
# 添加测试可执行文件
add_executable(SQLiteDBTest SQLiteDBTest.cpp)
# 查找 udpComm 项目库
find_library(UDPCOMM_LIB NAMES UDPComm PATHS /home/zjk/project/H100/H100PowerManger/lib)
if(NOT UDPCOMM_LIB)
message(FATAL_ERROR "udpComm library not found!")
endif()
# 添加 udpComm 测试可执行文件
add_executable(udpCommTest udpCommTest.cpp)
# 链接库文件(注意顺序:先项目库后系统库)
target_link_libraries(udpCommTest
${UDPCOMM_LIB} # 项目udpComm库
${MOOS_LIBRARIES}
Catch2::Catch2WithMain # 测试框架
)
# 链接库文件(注意顺序:先项目库后系统库)
target_link_libraries(SQLiteDBTest
${SQLiteDB_LIB} # 项目SQLiteDB库
+1 -1
View File
@@ -4,7 +4,7 @@ class msg_CcuStateFbMsg:
def __init__(self):
self.start1 = 0x20
self.start2 = 0x20
self.id = 0x0051
self.id = 0x0041
self.length = 0x0000
self.currentWorkCondition = 0x00
self.fcuState = 80
+37
View File
@@ -0,0 +1,37 @@
#include "../src/pPowerManger/udpComm.h"
#include "catch2/catch.hpp"
#include <iostream>
TEST_CASE("udpComm getDate function test", "[udpComm]") {
udpComm comm;
unsigned short year;
unsigned char month, day, hour, minute, second, milliseconds;
bool result = comm.getDate(year, month, day, hour, minute, second, milliseconds);
// 输出日期和时间信息
std::cout << "Year: " << year << std::endl;
std::cout << "Month: " << static_cast<int>(month) << std::endl;
std::cout << "Day: " << static_cast<int>(day) << std::endl;
std::cout << "Hour: " << static_cast<int>(hour) << std::endl;
std::cout << "Minute: " << static_cast<int>(minute) << std::endl;
std::cout << "Second: " << static_cast<int>(second) << std::endl;
std::cout << "Milliseconds: " << static_cast<int>(milliseconds) << std::endl;
REQUIRE(result == true);
REQUIRE(year >= 2023);
REQUIRE(year <= 2030);
REQUIRE(month >= 1);
REQUIRE(month <= 12);
REQUIRE(day >= 1);
REQUIRE(day <= 31);
REQUIRE(hour >= 0);
REQUIRE(hour <= 23);
REQUIRE(minute >= 0);
REQUIRE(minute <= 59);
REQUIRE(second >= 0);
REQUIRE(second <= 59);
REQUIRE(milliseconds >= 0);
REQUIRE(milliseconds <= 999);
}