From 179b751bf5cee941511e00877d0476db17f459c5 Mon Sep 17 00:00:00 2001
From: James Turner <james@flightgear.org>
Date: Fri, 7 Jan 2022 16:16:01 +0000
Subject: [PATCH] Unit-tests for Nasal range()

---
 test_suite/unit_tests/Scripting/testNasalSys.cxx | 14 ++++++++++++++
 test_suite/unit_tests/Scripting/testNasalSys.hxx |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/test_suite/unit_tests/Scripting/testNasalSys.cxx b/test_suite/unit_tests/Scripting/testNasalSys.cxx
index d536a8958..08acc2dae 100644
--- a/test_suite/unit_tests/Scripting/testNasalSys.cxx
+++ b/test_suite/unit_tests/Scripting/testNasalSys.cxx
@@ -227,3 +227,17 @@ void NasalSysTests::testRoundFloor()
     )");
     CPPUNIT_ASSERT(ok);
 }
+
+void NasalSysTests::testRange()
+{
+    auto nasalSys = globals->get_subsystem<FGNasalSys>();
+    nasalSys->getAndClearErrorList();
+
+    bool ok = FGTestApi::executeNasal(R"(
+        unitTest.assert_equal(range(5), [0, 1, 2, 3, 4]);
+        unitTest.assert_equal(range(2, 8), [2, 3, 4, 5, 6, 7]);
+        unitTest.assert_equal(range(2, 10, 3), [2, 5, 8]);
+
+    )");
+    CPPUNIT_ASSERT(ok);
+}
diff --git a/test_suite/unit_tests/Scripting/testNasalSys.hxx b/test_suite/unit_tests/Scripting/testNasalSys.hxx
index 256bab50e..036a5bbbd 100644
--- a/test_suite/unit_tests/Scripting/testNasalSys.hxx
+++ b/test_suite/unit_tests/Scripting/testNasalSys.hxx
@@ -36,6 +36,7 @@ class NasalSysTests : public CppUnit::TestFixture
     CPPUNIT_TEST(testAirportGhost);
     CPPUNIT_TEST(testCompileLarge);
     CPPUNIT_TEST(testRoundFloor);
+    CPPUNIT_TEST(testRange);
     CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -51,6 +52,7 @@ public:
     void testAirportGhost();
     void testCompileLarge();
     void testRoundFloor();
+    void testRange();
 };
 
 #endif  // _FG_NASALSYS_UNIT_TESTS_HXX