|
1 | 1 | #include "flowmeasure/ConcreteMeasure.h" |
| 2 | +#include "ECFMP/flowmeasure/FlowMeasure.h" |
2 | 3 | #include "flowmeasure/ConcreteMeasureFactory.h" |
3 | 4 |
|
4 | 5 | namespace ECFMPTest::FlowMeasure { |
@@ -173,4 +174,144 @@ namespace ECFMPTest::FlowMeasure { |
173 | 174 | return "type_" + std::to_string((int) info.param.measureType); |
174 | 175 | } |
175 | 176 | ); |
| 177 | + |
| 178 | + struct ConcreteMeasureDescriptionTestCase { |
| 179 | + // Test description |
| 180 | + std::string testDescription; |
| 181 | + |
| 182 | + // The type of measure |
| 183 | + std::function<ECFMP::FlowMeasure::ConcreteMeasure()> measureGenerator; |
| 184 | + |
| 185 | + // The expected description |
| 186 | + std::string expectedDescription; |
| 187 | + }; |
| 188 | + |
| 189 | + class ConcreteMeasureDescriptionTest : public testing::TestWithParam<ConcreteMeasureDescriptionTestCase> |
| 190 | + { |
| 191 | + public: |
| 192 | + }; |
| 193 | + |
| 194 | + TEST_P(ConcreteMeasureDescriptionTest, ItHasAnAppropriateDescription) |
| 195 | + { |
| 196 | + auto measure = GetParam().measureGenerator(); |
| 197 | + EXPECT_EQ(GetParam().expectedDescription, measure.MeasureDescription()); |
| 198 | + } |
| 199 | + |
| 200 | + INSTANTIATE_TEST_SUITE_P( |
| 201 | + ConcreteMeasureDescriptionTestCases, ConcreteMeasureDescriptionTest, |
| 202 | + testing::Values( |
| 203 | + ConcreteMeasureDescriptionTestCase{ |
| 204 | + "minimum_departure_interval_seconds_only", |
| 205 | + []() { |
| 206 | + return ECFMP::FlowMeasure::MinimumDepartureInterval(5); |
| 207 | + }, |
| 208 | + "Minimum Departure Interval: 5 seconds"}, |
| 209 | + ConcreteMeasureDescriptionTestCase{ |
| 210 | + "minimum_departure_interval_minutes_only", |
| 211 | + []() { |
| 212 | + return ECFMP::FlowMeasure::MinimumDepartureInterval(300); |
| 213 | + }, |
| 214 | + "Minimum Departure Interval: 5 minutes"}, |
| 215 | + ConcreteMeasureDescriptionTestCase{ |
| 216 | + "minimum_departure_interval_minutes_and_seconds", |
| 217 | + []() { |
| 218 | + return ECFMP::FlowMeasure::MinimumDepartureInterval(305); |
| 219 | + }, |
| 220 | + "Minimum Departure Interval: 5 minutes 5 seconds"}, |
| 221 | + ConcreteMeasureDescriptionTestCase{ |
| 222 | + "average_departure_interval_seconds_only", |
| 223 | + []() { |
| 224 | + return ECFMP::FlowMeasure::AverageDepartureInterval(5); |
| 225 | + }, |
| 226 | + "Average Departure Interval: 5 seconds"}, |
| 227 | + ConcreteMeasureDescriptionTestCase{ |
| 228 | + "average_departure_interval_minutes_only", |
| 229 | + []() { |
| 230 | + return ECFMP::FlowMeasure::AverageDepartureInterval(300); |
| 231 | + }, |
| 232 | + "Average Departure Interval: 5 minutes"}, |
| 233 | + ConcreteMeasureDescriptionTestCase{ |
| 234 | + "average_departure_interval_minutes_and_seconds", |
| 235 | + []() { |
| 236 | + return ECFMP::FlowMeasure::AverageDepartureInterval(305); |
| 237 | + }, |
| 238 | + "Average Departure Interval: 5 minutes 5 seconds"}, |
| 239 | + ConcreteMeasureDescriptionTestCase{ |
| 240 | + "per_hour", |
| 241 | + []() { |
| 242 | + return ECFMP::FlowMeasure::PerHour(5); |
| 243 | + }, |
| 244 | + "Per Hour: 5"}, |
| 245 | + ConcreteMeasureDescriptionTestCase{ |
| 246 | + "miles_in_trail", |
| 247 | + []() { |
| 248 | + return ECFMP::FlowMeasure::MilesInTrail(5); |
| 249 | + }, |
| 250 | + "Miles in Trail: 5"}, |
| 251 | + // Max ias |
| 252 | + ConcreteMeasureDescriptionTestCase{ |
| 253 | + "max_ias", |
| 254 | + []() { |
| 255 | + return ECFMP::FlowMeasure::MaxIndicatedAirspeed(5); |
| 256 | + }, |
| 257 | + "Max IAS: 5kts"}, |
| 258 | + ConcreteMeasureDescriptionTestCase{ |
| 259 | + "ias_reduction", |
| 260 | + []() { |
| 261 | + return ECFMP::FlowMeasure::IndicatedAirspeedReduction(5); |
| 262 | + }, |
| 263 | + "IAS Reduction: 5kts"}, |
| 264 | + ConcreteMeasureDescriptionTestCase{ |
| 265 | + "max_mach", |
| 266 | + []() { |
| 267 | + return ECFMP::FlowMeasure::MaxMach(0.89123); |
| 268 | + }, |
| 269 | + "Max Mach: 0.89"}, |
| 270 | + ConcreteMeasureDescriptionTestCase{ |
| 271 | + "mach_reduction", |
| 272 | + []() { |
| 273 | + return ECFMP::FlowMeasure::MachReduction(0.89123); |
| 274 | + }, |
| 275 | + "Mach Reduction: 0.89"}, |
| 276 | + ConcreteMeasureDescriptionTestCase{ |
| 277 | + "mandatory_route", |
| 278 | + []() { |
| 279 | + return ECFMP::FlowMeasure::MandatoryRoute(std::set<std::string>({"foo boo", "bar"})); |
| 280 | + }, |
| 281 | + "Mandatory Route(s): bar, foo boo"}, |
| 282 | + ConcreteMeasureDescriptionTestCase{ |
| 283 | + "mandatory_route_empty", |
| 284 | + []() { |
| 285 | + return ECFMP::FlowMeasure::MandatoryRoute(std::set<std::string>()); |
| 286 | + }, |
| 287 | + "Mandatory Route(s): "}, |
| 288 | + ConcreteMeasureDescriptionTestCase{ |
| 289 | + "mandatory_route_single", |
| 290 | + []() { |
| 291 | + return ECFMP::FlowMeasure::MandatoryRoute(std::set<std::string>({"foo boo"})); |
| 292 | + }, |
| 293 | + "Mandatory Route(s): foo boo"}, |
| 294 | + ConcreteMeasureDescriptionTestCase{ |
| 295 | + "mandatory_route_single_empty", |
| 296 | + []() { |
| 297 | + return ECFMP::FlowMeasure::MandatoryRoute(std::set<std::string>({" "})); |
| 298 | + }, |
| 299 | + "Mandatory Route(s): "}, |
| 300 | + ConcreteMeasureDescriptionTestCase{ |
| 301 | + "prohibit", |
| 302 | + []() { |
| 303 | + return ECFMP::FlowMeasure::Prohibit(); |
| 304 | + }, |
| 305 | + "Prohibit"}, |
| 306 | + ConcreteMeasureDescriptionTestCase{ |
| 307 | + "ground_stop", |
| 308 | + []() { |
| 309 | + return ECFMP::FlowMeasure::GroundStop(); |
| 310 | + }, |
| 311 | + "Ground Stop"} |
| 312 | + ), |
| 313 | + [](const ::testing::TestParamInfo<ConcreteMeasureDescriptionTest::ParamType>& info) { |
| 314 | + return info.param.testDescription; |
| 315 | + } |
| 316 | + ); |
176 | 317 | }// namespace ECFMPTest::FlowMeasure |
0 commit comments