38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#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);
|
|
}
|