From d8b778a59e935f1dca7c6778eef08a6ee7e3c63d Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Fri, 15 May 2020 21:22:08 +0100 Subject: [PATCH] Add (failing) test for indexOfWP function with procedures --- .../Instrumentation/test_rnav_procedures.cxx | 28 +++++++++++++++++++ .../Instrumentation/test_rnav_procedures.hxx | 2 ++ 2 files changed, 30 insertions(+) diff --git a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx index 593302f84..7ce5ac51b 100644 --- a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx +++ b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx @@ -655,3 +655,31 @@ void RNAVProcedureTests::testLEBL_LARP2F() FGTestApi::runForTime(180.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(199, m_gpsNode->getDoubleValue("wp/leg-true-course-deg"), 0.5); } + +// This could probably be in a better place but this allows it to access TestDelegate. +// Also it does relate to procedures as its a bug that only occurs with procedures +void RNAVProcedureTests::testIndexOf() +{ + auto egkk = FGAirport::findByIdent("EGKK"); + auto sid = egkk->findSIDWithIdent("SAM3P"); + // procedures not loaded, abandon test + if (!sid) + return; + + auto rm = globals->get_subsystem(); + auto fp = new FlightPlan; + + auto testDelegate = new TestFPDelegate; + testDelegate->thePlan = fp; + fp->addDelegate(testDelegate); + + rm->setFlightPlan(fp); + FGTestApi::setUp::populateFPWithNasal(fp, "EGKK", "08R", "EGJJ", "27", "LELNA"); + + fp->setSID(sid); + FGPositioned::TypeFilter f{FGPositioned::VOR}; + auto southamptonVOR = fgpositioned_cast(FGPositioned::findClosestWithIdent("SAM", SGGeod::fromDeg(-1.25, 51.0), &f)); + auto SAM = fp->legAtIndex(6)->waypoint(); + CPPUNIT_ASSERT_EQUAL(southamptonVOR->ident(), SAM->ident()); + CPPUNIT_ASSERT_EQUAL(6, fp->findWayptIndex(southamptonVOR)); +} \ No newline at end of file diff --git a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.hxx b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.hxx index 8b8150652..55b2a7768 100644 --- a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.hxx +++ b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.hxx @@ -45,6 +45,7 @@ class RNAVProcedureTests : public CppUnit::TestFixture CPPUNIT_TEST(testTransitionsSID); CPPUNIT_TEST(testTransitionsSTAR); CPPUNIT_TEST(testLEBL_LARP2F); + CPPUNIT_TEST(testIndexOf); CPPUNIT_TEST_SUITE_END(); @@ -71,6 +72,7 @@ public: void testTransitionsSID(); void testTransitionsSTAR(); void testLEBL_LARP2F(); + void testIndexOf(); private: GPS* m_gps = nullptr; SGPropertyNode_ptr m_gpsNode;