修改编译错误
This commit is contained in:
parent
7f551e28ae
commit
f09f7d4c88
@ -16,7 +16,7 @@ struct CoordinatePoint {
|
||||
};
|
||||
|
||||
// JSON 序列化/反序列化函数
|
||||
void to_json(json& j, const CoordinatePoint& p) {
|
||||
inline void to_json(json& j, const CoordinatePoint& p) {
|
||||
j = json{
|
||||
{"point", p.point},
|
||||
{"latitude", p.latitude},
|
||||
@ -24,7 +24,7 @@ void to_json(json& j, const CoordinatePoint& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, CoordinatePoint& p) {
|
||||
inline void from_json(const json& j, CoordinatePoint& p) {
|
||||
j.at("point").get_to(p.point);
|
||||
j.at("latitude").get_to(p.latitude);
|
||||
j.at("longitude").get_to(p.longitude);
|
||||
@ -115,19 +115,19 @@ private:
|
||||
};
|
||||
|
||||
// 为每个嵌套结构体定义 JSON 序列化/反序列化函数
|
||||
void to_json(json& j, const SystemConfig::Airport::ReferencePoint& p) {
|
||||
inline void to_json(json& j, const SystemConfig::Airport::ReferencePoint& p) {
|
||||
j = json{
|
||||
{"latitude", p.latitude},
|
||||
{"longitude", p.longitude}
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::Airport::ReferencePoint& p) {
|
||||
inline void from_json(const json& j, SystemConfig::Airport::ReferencePoint& p) {
|
||||
j.at("latitude").get_to(p.latitude);
|
||||
j.at("longitude").get_to(p.longitude);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::Airport& p) {
|
||||
inline void to_json(json& j, const SystemConfig::Airport& p) {
|
||||
j = json{
|
||||
{"name", p.name},
|
||||
{"iata", p.iata},
|
||||
@ -137,7 +137,7 @@ void to_json(json& j, const SystemConfig::Airport& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::Airport& p) {
|
||||
inline void from_json(const json& j, SystemConfig::Airport& p) {
|
||||
j.at("name").get_to(p.name);
|
||||
j.at("iata").get_to(p.iata);
|
||||
j.at("icao").get_to(p.icao);
|
||||
@ -145,7 +145,7 @@ void from_json(const json& j, SystemConfig::Airport& p) {
|
||||
j.at("coordinate_points").get_to(p.coordinate_points);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::WebSocket::PositionUpdate& p) {
|
||||
inline void to_json(json& j, const SystemConfig::WebSocket::PositionUpdate& p) {
|
||||
j = json{
|
||||
{"aircraft_interval_ms", p.aircraft_interval_ms},
|
||||
{"vehicle_interval_ms", p.vehicle_interval_ms},
|
||||
@ -153,13 +153,13 @@ void to_json(json& j, const SystemConfig::WebSocket::PositionUpdate& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::WebSocket::PositionUpdate& p) {
|
||||
inline void from_json(const json& j, SystemConfig::WebSocket::PositionUpdate& p) {
|
||||
j.at("aircraft_interval_ms").get_to(p.aircraft_interval_ms);
|
||||
j.at("vehicle_interval_ms").get_to(p.vehicle_interval_ms);
|
||||
j.at("traffic_light_interval_ms").get_to(p.traffic_light_interval_ms);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::WebSocket& p) {
|
||||
inline void to_json(json& j, const SystemConfig::WebSocket& p) {
|
||||
j = json{
|
||||
{"port", p.port},
|
||||
{"max_connections", p.max_connections},
|
||||
@ -168,14 +168,14 @@ void to_json(json& j, const SystemConfig::WebSocket& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::WebSocket& p) {
|
||||
inline void from_json(const json& j, SystemConfig::WebSocket& p) {
|
||||
j.at("port").get_to(p.port);
|
||||
j.at("max_connections").get_to(p.max_connections);
|
||||
j.at("ping_interval_ms").get_to(p.ping_interval_ms);
|
||||
j.at("position_update").get_to(p.position_update);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::CollisionDetection::Prediction& p) {
|
||||
inline void to_json(json& j, const SystemConfig::CollisionDetection::Prediction& p) {
|
||||
j = json{
|
||||
{"time_window", p.time_window},
|
||||
{"vehicle_size", p.vehicle_size},
|
||||
@ -184,26 +184,26 @@ void to_json(json& j, const SystemConfig::CollisionDetection::Prediction& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::CollisionDetection::Prediction& p) {
|
||||
inline void from_json(const json& j, SystemConfig::CollisionDetection::Prediction& p) {
|
||||
j.at("time_window").get_to(p.time_window);
|
||||
j.at("vehicle_size").get_to(p.vehicle_size);
|
||||
j.at("aircraft_size").get_to(p.aircraft_size);
|
||||
j.at("min_unmanned_speed").get_to(p.min_unmanned_speed);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::CollisionDetection& p) {
|
||||
inline void to_json(json& j, const SystemConfig::CollisionDetection& p) {
|
||||
j = json{
|
||||
{"update_interval_ms", p.update_interval_ms},
|
||||
{"prediction", p.prediction}
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::CollisionDetection& p) {
|
||||
inline void from_json(const json& j, SystemConfig::CollisionDetection& p) {
|
||||
j.at("update_interval_ms").get_to(p.update_interval_ms);
|
||||
j.at("prediction").get_to(p.prediction);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::DataSource& p) {
|
||||
inline void to_json(json& j, const SystemConfig::DataSource& p) {
|
||||
j = json{
|
||||
{"host", p.host},
|
||||
{"port", p.port},
|
||||
@ -216,7 +216,7 @@ void to_json(json& j, const SystemConfig::DataSource& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::DataSource& p) {
|
||||
inline void from_json(const json& j, SystemConfig::DataSource& p) {
|
||||
j.at("host").get_to(p.host);
|
||||
j.at("port").get_to(p.port);
|
||||
j.at("aircraft_path").get_to(p.aircraft_path);
|
||||
@ -227,7 +227,7 @@ void from_json(const json& j, SystemConfig::DataSource& p) {
|
||||
j.at("read_timeout_ms").get_to(p.read_timeout_ms);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::Logging& p) {
|
||||
inline void to_json(json& j, const SystemConfig::Logging& p) {
|
||||
j = json{
|
||||
{"level", p.level},
|
||||
{"file", p.file},
|
||||
@ -237,7 +237,7 @@ void to_json(json& j, const SystemConfig::Logging& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::Logging& p) {
|
||||
inline void from_json(const json& j, SystemConfig::Logging& p) {
|
||||
j.at("level").get_to(p.level);
|
||||
j.at("file").get_to(p.file);
|
||||
j.at("max_size_mb").get_to(p.max_size_mb);
|
||||
@ -245,7 +245,7 @@ void from_json(const json& j, SystemConfig::Logging& p) {
|
||||
j.at("console_output").get_to(p.console_output);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::Debug& p) {
|
||||
inline void to_json(json& j, const SystemConfig::Debug& p) {
|
||||
j = json{
|
||||
{"enable_mock_data", p.enable_mock_data},
|
||||
{"save_raw_data", p.save_raw_data},
|
||||
@ -253,25 +253,25 @@ void to_json(json& j, const SystemConfig::Debug& p) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::Debug& p) {
|
||||
inline void from_json(const json& j, SystemConfig::Debug& p) {
|
||||
j.at("enable_mock_data").get_to(p.enable_mock_data);
|
||||
j.at("save_raw_data").get_to(p.save_raw_data);
|
||||
j.at("profile_performance").get_to(p.profile_performance);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig::Warning& p) {
|
||||
inline void to_json(json& j, const SystemConfig::Warning& p) {
|
||||
j = json{
|
||||
{"warning_interval_ms", p.warning_interval_ms},
|
||||
{"log_interval_ms", p.log_interval_ms}
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig::Warning& p) {
|
||||
inline void from_json(const json& j, SystemConfig::Warning& p) {
|
||||
j.at("warning_interval_ms").get_to(p.warning_interval_ms);
|
||||
j.at("log_interval_ms").get_to(p.log_interval_ms);
|
||||
}
|
||||
|
||||
void to_json(json& j, const SystemConfig& config) {
|
||||
inline void to_json(json& j, const SystemConfig& config) {
|
||||
j = json{
|
||||
{"airport", config.airport},
|
||||
{"data_source", config.data_source},
|
||||
@ -283,7 +283,7 @@ void to_json(json& j, const SystemConfig& config) {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& j, SystemConfig& config) {
|
||||
inline void from_json(const json& j, SystemConfig& config) {
|
||||
j.at("airport").get_to(config.airport);
|
||||
j.at("data_source").get_to(config.data_source);
|
||||
j.at("websocket").get_to(config.websocket);
|
||||
|
||||
1
src/config/SystemConfigJson.cpp
Normal file
1
src/config/SystemConfigJson.cpp
Normal file
@ -0,0 +1 @@
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
// 创建一个 Mock DataSource 类
|
||||
class MockDataSource : public DataSource {
|
||||
public:
|
||||
MOCK_METHOD(bool, connect, (), (override));
|
||||
MOCK_METHOD(void, disconnect, (), (override));
|
||||
MOCK_METHOD(bool, isAvailable, (), (const, override));
|
||||
MOCK_METHOD(bool, fetchAircraftData, (std::vector<Aircraft>&), (override));
|
||||
MOCK_METHOD(bool, fetchVehicleData, (std::vector<Vehicle>&), (override));
|
||||
MOCK_METHOD(bool, fetchTrafficLightSignals, (std::vector<TrafficLightSignal>&), (override));
|
||||
MOCK_METHOD0(connect, bool());
|
||||
MOCK_METHOD0(disconnect, void());
|
||||
MOCK_CONST_METHOD0(isAvailable, bool());
|
||||
MOCK_METHOD1(fetchAircraftData, bool(std::vector<Aircraft>&));
|
||||
MOCK_METHOD1(fetchVehicleData, bool(std::vector<Vehicle>&));
|
||||
MOCK_METHOD1(fetchTrafficLightSignals, bool(std::vector<TrafficLightSignal>&));
|
||||
};
|
||||
|
||||
class DataCollectorTest : public ::testing::Test {
|
||||
@ -241,7 +241,7 @@ TEST_F(DataCollectorTest, ConnectionHealthAndTimeout) {
|
||||
EXPECT_CALL(*mockSource, isAvailable())
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
|
||||
// 模据<EFBFBD><EFBFBD>取失败
|
||||
// 模据取失败
|
||||
EXPECT_CALL(*mockSource, fetchAircraftData)
|
||||
.WillRepeatedly(::testing::Return(false));
|
||||
EXPECT_CALL(*mockSource, fetchVehicleData)
|
||||
@ -287,7 +287,7 @@ TEST_F(DataCollectorTest, ConnectionRecovery) {
|
||||
::testing::Return(true)
|
||||
));
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>行两次刷新
|
||||
// 行两次刷新
|
||||
collector->refresh(); // 第一次失败
|
||||
collector->refresh(); // 第二次成功
|
||||
|
||||
@ -403,7 +403,7 @@ TEST_F(DataCollectorTest, TimeoutWarningMechanism) {
|
||||
// 创建一个 mock System 来捕获警告
|
||||
class MockSystem : public System {
|
||||
public:
|
||||
MOCK_METHOD(void, broadcastTimeoutWarning, (const network::TimeoutWarningMessage&), (override));
|
||||
MOCK_METHOD1(broadcastTimeoutWarning, void(const network::TimeoutWarningMessage&));
|
||||
};
|
||||
|
||||
auto mockSystem = std::make_shared<MockSystem>();
|
||||
@ -458,7 +458,7 @@ TEST_F(DataCollectorTest, ReadTimeoutMechanism) {
|
||||
// 创建一个 mock System 来捕获警告
|
||||
class MockSystem : public System {
|
||||
public:
|
||||
MOCK_METHOD(void, broadcastTimeoutWarning, (const network::TimeoutWarningMessage&), (override));
|
||||
MOCK_METHOD1(broadcastTimeoutWarning, void(const network::TimeoutWarningMessage&));
|
||||
};
|
||||
|
||||
auto mockSystem = std::make_shared<MockSystem>();
|
||||
|
||||
@ -126,7 +126,7 @@ TEST_F(SafetyZoneTest, SafetyZoneTypeLocking) {
|
||||
auto vehicle = createSpecialVehicle("TQ001", vehicleEffectiveDistance - 5.0, 0.0);
|
||||
EXPECT_FALSE(safetyZone->isObjectInZone(vehicle));
|
||||
|
||||
// 确认安全区类型和尺寸没有改变
|
||||
// 确认安全区类型和尺寸没有改<EFBFBD><EFBFBD><EFBFBD>
|
||||
EXPECT_EQ(safetyZone->getType(), SafetyZoneType::AIRCRAFT);
|
||||
EXPECT_EQ(safetyZone->getCurrentRadius(), 50.0);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user