Compare commits
No commits in common. "test_20260508_114622" and "main" have entirely different histories.
test_20260
...
main
|
|
@ -1,25 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.10.0)
|
||||
project(test_plan_execute_t1)
|
||||
include(FetchContent)
|
||||
if (MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
endif()
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
add_executable(test_plan_execute_t1 test_app.cpp ../src/app.cpp)
|
||||
|
||||
target_link_libraries(test_plan_execute_t1 gtest gmock gtest_main)
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(test_plan_execute_t1)
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "app.hpp"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
// Mock classes to support testing if needed, or use direct access if public
|
||||
// Since CmsEngine is likely in a namespace or header, we assume app.hpp provides the interface
|
||||
|
||||
class CmsEngineTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
engine_ = std::make_unique<CmsEngine>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
engine_.reset();
|
||||
}
|
||||
|
||||
std::unique_ptr<CmsEngine> engine_;
|
||||
};
|
||||
|
||||
TEST_F(CmsEngineTest, TestPushNotification_Normal) {
|
||||
NotificationMessage msg;
|
||||
msg.id = "NOTIF-001";
|
||||
msg.summary = "Test notification";
|
||||
msg.isRead = false;
|
||||
|
||||
EXPECT_NO_THROW(engine_->pushNotification(msg));
|
||||
|
||||
auto unread = engine_->getUnreadNotifications();
|
||||
EXPECT_EQ(unread.size(), 1);
|
||||
EXPECT_EQ(unread[0].id, "NOTIF-001");
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestGetUnreadNotifications_Empty) {
|
||||
auto unread = engine_->getUnreadNotifications();
|
||||
EXPECT_TRUE(unread.empty());
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestGetUnreadNotifications_Mixed) {
|
||||
NotificationMessage readMsg;
|
||||
readMsg.id = "READ-001";
|
||||
readMsg.summary = "Read message";
|
||||
readMsg.isRead = true;
|
||||
|
||||
NotificationMessage unreadMsg;
|
||||
unreadMsg.id = "UNREAD-001";
|
||||
unreadMsg.summary = "Unread message";
|
||||
unreadMsg.isRead = false;
|
||||
|
||||
engine_->pushNotification(readMsg);
|
||||
engine_->pushNotification(unreadMsg);
|
||||
|
||||
auto unread = engine_->getUnreadNotifications();
|
||||
EXPECT_EQ(unread.size(), 1);
|
||||
EXPECT_EQ(unread[0].id, "UNREAD-001");
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestSwitchMode_Success) {
|
||||
EXPECT_TRUE(engine_->switchMode(RunMode::AutoExec));
|
||||
|
||||
auto context = engine_->getSystemContext();
|
||||
EXPECT_EQ(context.currentMode, RunMode::AutoExec);
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestSwitchMode_DegradedRestriction) {
|
||||
engine_->switchMode(RunMode::Degraded);
|
||||
|
||||
// Should fail to switch out of degraded mode
|
||||
EXPECT_FALSE(engine_->switchMode(RunMode::Idle));
|
||||
|
||||
auto context = engine_->getSystemContext();
|
||||
EXPECT_EQ(context.currentMode, RunMode::Degraded);
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestGetSystemContext_Valid) {
|
||||
engine_->switchMode(RunMode::HumanLoop);
|
||||
|
||||
auto context = engine_->getSystemContext();
|
||||
EXPECT_EQ(context.currentMode, RunMode::HumanLoop);
|
||||
EXPECT_NE(context.switchTime.time_since_epoch(), std::chrono::seconds(0));
|
||||
}
|
||||
|
||||
TEST_F(CmsEngineTest, TestGetSummary_Format) {
|
||||
engine_->switchMode(RunMode::AutoExec);
|
||||
|
||||
std::string summary = engine_->getSummary();
|
||||
|
||||
EXPECT_NE(summary.find("Events"), std::string::npos);
|
||||
EXPECT_NE(summary.find("Plans"), std::string::npos);
|
||||
EXPECT_NE(summary.find("Templates"), std::string::npos);
|
||||
EXPECT_NE(summary.find("Monitor Nodes"), std::string::npos);
|
||||
EXPECT_NE(summary.find("Active Sessions"), std::string::npos);
|
||||
EXPECT_NE(summary.find("Notifications"), std::string::npos);
|
||||
EXPECT_NE(summary.find("AutoExec"), std::string::npos);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Loading…
Reference in New Issue