修改编译错误
This commit is contained in:
parent
f09f7d4c88
commit
6afb09ffb5
@ -163,4 +163,12 @@ message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
configure_file(${CMAKE_SOURCE_DIR}/config/system_config.json ${CMAKE_BINARY_DIR}/config/system_config.json COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/config/intersections.json ${CMAKE_BINARY_DIR}/config/intersections.json COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/config/vehicle_control.json ${CMAKE_BINARY_DIR}/config/vehicle_control.json COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/config/airport_bounds.json ${CMAKE_BINARY_DIR}/config/airport_bounds.json COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/config/airport_bounds.json ${CMAKE_BINARY_DIR}/config/airport_bounds.json COPYONLY)
|
||||
|
||||
if(NOT APPLE)
|
||||
target_link_libraries(airport_collision_avoidance
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_lib
|
||||
pthread
|
||||
)
|
||||
endif()
|
||||
@ -91,13 +91,13 @@ TEST_F(DataCollectorTest, RefreshTest) {
|
||||
};
|
||||
|
||||
// 设置 Mock 数据返回
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillOnce(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testAircraft),
|
||||
::testing::Return(true)
|
||||
));
|
||||
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData)
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData(::testing::_))
|
||||
.WillOnce(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testVehicles),
|
||||
::testing::Return(true)
|
||||
@ -133,13 +133,13 @@ TEST_F(DataCollectorTest, DataCollectionLoop) {
|
||||
};
|
||||
|
||||
// 设置 Mock 数据返回
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillRepeatedly(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testAircraft),
|
||||
::testing::Return(true)
|
||||
));
|
||||
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData)
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData(::testing::_))
|
||||
.WillRepeatedly(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testVehicles),
|
||||
::testing::Return(true)
|
||||
@ -165,9 +165,9 @@ TEST_F(DataCollectorTest, DataCollectionLoop) {
|
||||
// 测试错误处理
|
||||
TEST_F(DataCollectorTest, ErrorHandling) {
|
||||
// 设置 Mock 返回错误
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillOnce(::testing::Return(false));
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData)
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData(::testing::_))
|
||||
.WillOnce(::testing::Return(false));
|
||||
|
||||
// 执行刷新
|
||||
@ -190,7 +190,7 @@ TEST_F(DataCollectorTest, TrafficLightSignalsTest) {
|
||||
};
|
||||
|
||||
// 设置 Mock 数据返回
|
||||
EXPECT_CALL(*mockSource, fetchTrafficLightSignals)
|
||||
EXPECT_CALL(*mockSource, fetchTrafficLightSignals(::testing::_))
|
||||
.WillOnce(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testSignals),
|
||||
::testing::Return(true)
|
||||
@ -213,7 +213,7 @@ TEST_F(DataCollectorTest, TrafficLightSignalsTest) {
|
||||
// 测试红绿灯信号错误处理
|
||||
TEST_F(DataCollectorTest, TrafficLightSignalsErrorTest) {
|
||||
// 设置 Mock 返回错误
|
||||
EXPECT_CALL(*mockSource, fetchTrafficLightSignals)
|
||||
EXPECT_CALL(*mockSource, fetchTrafficLightSignals(::testing::_))
|
||||
.WillOnce(::testing::Return(false));
|
||||
|
||||
// 执行刷新
|
||||
@ -241,10 +241,10 @@ TEST_F(DataCollectorTest, ConnectionHealthAndTimeout) {
|
||||
EXPECT_CALL(*mockSource, isAvailable())
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
|
||||
// 模据取失败
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
// 模拟数据获取失败
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData)
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData(::testing::_))
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
|
||||
// 启动采集
|
||||
@ -280,7 +280,7 @@ TEST_F(DataCollectorTest, ConnectionRecovery) {
|
||||
};
|
||||
|
||||
// 移除 InSequence,直接设置期望
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillOnce(::testing::Return(false))
|
||||
.WillOnce(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testAircraft),
|
||||
@ -317,7 +317,7 @@ TEST_F(DataCollectorTest, LongConnectionDataFetch) {
|
||||
.WillRepeatedly(::testing::Return(true));
|
||||
|
||||
// 模拟多次成功获取数据
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.Times(::testing::AtLeast(3))
|
||||
.WillRepeatedly(::testing::DoAll(
|
||||
::testing::SetArgReferee<0>(testAircraft),
|
||||
@ -372,7 +372,7 @@ TEST_F(DataCollectorTest, TimeoutWarningTest) {
|
||||
EXPECT_CALL(*mockSource, isAvailable())
|
||||
.WillRepeatedly(::testing::Return(true));
|
||||
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillRepeatedly(::testing::Return(false)); // 持续读取超时
|
||||
|
||||
// 启动采集
|
||||
@ -409,7 +409,7 @@ TEST_F(DataCollectorTest, TimeoutWarningMechanism) {
|
||||
auto mockSystem = std::make_shared<MockSystem>();
|
||||
|
||||
// 设置期望接收到超时警告
|
||||
EXPECT_CALL(*mockSystem, broadcastTimeoutWarning)
|
||||
EXPECT_CALL(*mockSystem, broadcastTimeoutWarning(::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke([&warningCount](const network::TimeoutWarningMessage& warning) {
|
||||
warningCount++;
|
||||
// 验证警告消息的内容
|
||||
@ -426,7 +426,7 @@ TEST_F(DataCollectorTest, TimeoutWarningMechanism) {
|
||||
collector->start();
|
||||
|
||||
// 模拟数据获取失败
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
|
||||
// 等待足够长的时间以确保警告被发送
|
||||
@ -464,7 +464,7 @@ TEST_F(DataCollectorTest, ReadTimeoutMechanism) {
|
||||
auto mockSystem = std::make_shared<MockSystem>();
|
||||
|
||||
// 设置期望接收到超时警告
|
||||
EXPECT_CALL(*mockSystem, broadcastTimeoutWarning)
|
||||
EXPECT_CALL(*mockSystem, broadcastTimeoutWarning(::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke([&warningCount](const network::TimeoutWarningMessage& warning) {
|
||||
warningCount++;
|
||||
// 验证警告消息的内容
|
||||
@ -481,9 +481,9 @@ TEST_F(DataCollectorTest, ReadTimeoutMechanism) {
|
||||
collector->start();
|
||||
|
||||
// 模拟读取超时
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData(::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke([](std::vector<Aircraft>& aircraft) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(60)); // 睡眠超过读取超时时间但小于连接超时
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(60)); // 睡眠超过读取超时时间但小于连<EFBFBD><EFBFBD><EFBFBD>超时
|
||||
return false;
|
||||
}));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user