Test Nasal trunc/floor/round
This commit is contained in:
parent
6320c06e6b
commit
aad67cdad9
2 changed files with 26 additions and 0 deletions
|
@ -203,3 +203,27 @@ void NasalSysTests::testCompileLarge()
|
|||
// )");
|
||||
// CPPUNIT_ASSERT(ok);
|
||||
}
|
||||
|
||||
|
||||
void NasalSysTests::testRoundFloor()
|
||||
{
|
||||
auto nasalSys = globals->get_subsystem<FGNasalSys>();
|
||||
nasalSys->getAndClearErrorList();
|
||||
|
||||
bool ok = FGTestApi::executeNasal(R"(
|
||||
unitTest.assert_equal(math.round(121266, 1000), 121000);
|
||||
unitTest.assert_equal(math.round(121.1234, 0.01), 121.12);
|
||||
unitTest.assert_equal(math.round(121266, 10), 121270);
|
||||
|
||||
unitTest.assert_equal(math.floor(121766, 1000), 121000);
|
||||
unitTest.assert_equal(math.floor(121.1299, 0.01), 121.12);
|
||||
|
||||
# floor towards lower value
|
||||
unitTest.assert_equal(math.floor(-121.1229, 0.01), -121.13);
|
||||
|
||||
# truncate towards zero
|
||||
unitTest.assert_equal(math.trunc(-121.1229, 0.01), -121.12);
|
||||
unitTest.assert_equal(math.trunc(-121.1299, 0.01), -121.12);
|
||||
)");
|
||||
CPPUNIT_ASSERT(ok);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class NasalSysTests : public CppUnit::TestFixture
|
|||
CPPUNIT_TEST(testCommands);
|
||||
CPPUNIT_TEST(testAirportGhost);
|
||||
CPPUNIT_TEST(testCompileLarge);
|
||||
CPPUNIT_TEST(testRoundFloor);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
void testCommands();
|
||||
void testAirportGhost();
|
||||
void testCompileLarge();
|
||||
void testRoundFloor();
|
||||
};
|
||||
|
||||
#endif // _FG_NASALSYS_UNIT_TESTS_HXX
|
||||
|
|
Loading…
Reference in a new issue