From 1a94f4858bdbb3dd6a2f23baa630e97ab32001bf Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 24 May 2020 23:46:42 +0100 Subject: [PATCH] Test for cloning plan with procedures --- .../unit_tests/Navaids/test_flightplan.cxx | 26 +++++++++++++++++++ .../unit_tests/Navaids/test_flightplan.hxx | 2 ++ 2 files changed, 28 insertions(+) diff --git a/test_suite/unit_tests/Navaids/test_flightplan.cxx b/test_suite/unit_tests/Navaids/test_flightplan.cxx index 1878230ba..17e5d92b7 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.cxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.cxx @@ -949,4 +949,30 @@ void FlightplanTests::testCloningFGFP() CPPUNIT_ASSERT(fp2->legAtIndex(6)->waypoint()->source()->ident() == "PSA"); CPPUNIT_ASSERT_EQUAL(7, fp2->numLegs()); +} + +void FlightplanTests::testCloningProcedures() { + // procedures not loaded, abandon test + if (!static_haveProcedures) + return; + + static_factory = std::make_shared(); + FlightPlan::registerDelegateFactory(static_factory); + + auto egkk = FGAirport::findByIdent("EGKK"); + auto sid = egkk->findSIDWithIdent("SAM3P"); + + FlightPlanRef fp1 = makeTestFP("EGKK", "08R", "EGJJ", "27", + ""); + auto ourDelegate = TestFPDelegateFactory::delegateForPlan(fp1); + + fp1->setSID(sid); + auto fp2 = fp1->clone(); + CPPUNIT_ASSERT(fp2->departureAirport()->ident() == "EGKK"); + CPPUNIT_ASSERT(fp2->departureRunway()->ident() == "08R"); + CPPUNIT_ASSERT(fp2->destinationAirport()->ident() == "EGJJ"); + CPPUNIT_ASSERT(fp2->destinationRunway()->ident() == "27"); + + CPPUNIT_ASSERT(fp2->legAtIndex(0)->waypoint()->source()->ident() == "08R"); + CPPUNIT_ASSERT_EQUAL(fp2->sid()->ident(), string{"SAM3P"}); } \ No newline at end of file diff --git a/test_suite/unit_tests/Navaids/test_flightplan.hxx b/test_suite/unit_tests/Navaids/test_flightplan.hxx index 970acc037..abf1ab3b3 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.hxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.hxx @@ -51,6 +51,7 @@ class FlightplanTests : public CppUnit::TestFixture CPPUNIT_TEST(loadFGFPWithProcedureIdents); CPPUNIT_TEST(testCloningBasic); CPPUNIT_TEST(testCloningFGFP); + CPPUNIT_TEST(testCloningProcedures); // CPPUNIT_TEST(testParseICAORoute); // CPPUNIT_TEST(testParseICANLowLevelRoute); @@ -86,6 +87,7 @@ public: void loadFGFPWithProcedureIdents(); void testCloningBasic(); void testCloningFGFP(); + void testCloningProcedures(); }; #endif // FG_FLIGHTPLAN_UNIT_TESTS_HXX