From 8f6328eea80106c14f04dfa1d241d1299b9519bd Mon Sep 17 00:00:00 2001 From: Chris Birkhold Date: Fri, 22 Nov 2024 15:11:45 -0800 Subject: [PATCH] Add test coverage. --- tests/unit_tests/FGAtmosphereTest.h | 3 +++ tests/unit_tests/FGColumnVector3Test.h | 18 ++++++++++++++++++ tests/unit_tests/FGGroundCallbackTest.h | 8 ++++++++ tests/unit_tests/FGLocationTest.h | 3 +++ 4 files changed, 32 insertions(+) diff --git a/tests/unit_tests/FGAtmosphereTest.h b/tests/unit_tests/FGAtmosphereTest.h index 25ada7598f..331f9c5ae1 100644 --- a/tests/unit_tests/FGAtmosphereTest.h +++ b/tests/unit_tests/FGAtmosphereTest.h @@ -153,6 +153,9 @@ class FGAtmosphereTest : public CxxTest::TestSuite double T = T0 + 0.1*h; double P = P0 + 1.0*h; + FGAtmosphere::AltitudeDependentValues adv; + atm.GetAltitudeDependentValues(adv); + TS_ASSERT_DELTA(atm.GetTemperature(h), T, epsilon); TS_ASSERT_EQUALS(atm.GetTemperature(0.0), T0); TS_ASSERT_DELTA(atm.GetTemperatureRatio(h), T/T0, epsilon); diff --git a/tests/unit_tests/FGColumnVector3Test.h b/tests/unit_tests/FGColumnVector3Test.h index 5a092ce697..974013accc 100644 --- a/tests/unit_tests/FGColumnVector3Test.h +++ b/tests/unit_tests/FGColumnVector3Test.h @@ -577,6 +577,24 @@ class FGColumnVector3Test : public CxxTest::TestSuite TS_ASSERT_EQUALS(Z(3), 1.0); } + void testSqrMagnitude(void) { + JSBSim::FGColumnVector3 v0; + JSBSim::FGColumnVector3 v(3.0, 4.0, 0.0); + + TS_ASSERT_EQUALS(v0.SqrMagnitude(), 0.0); + TS_ASSERT_EQUALS(v.SqrMagnitude(), 25.0); + TS_ASSERT_EQUALS(DotProduct(v,v), v.SqrMagnitude()); + + // Verify that the operands are not modified + TS_ASSERT_EQUALS(v0(1), 0.0); + TS_ASSERT_EQUALS(v0(2), 0.0); + TS_ASSERT_EQUALS(v0(3), 0.0); + + TS_ASSERT_EQUALS(v(1), 3.0); + TS_ASSERT_EQUALS(v(2), 4.0); + TS_ASSERT_EQUALS(v(3), 0.0); + } + void testMagnitude(void) { JSBSim::FGColumnVector3 v0; JSBSim::FGColumnVector3 v(3.0, 4.0, 0.0); diff --git a/tests/unit_tests/FGGroundCallbackTest.h b/tests/unit_tests/FGGroundCallbackTest.h index 1b9728b5ca..3030025928 100644 --- a/tests/unit_tests/FGGroundCallbackTest.h +++ b/tests/unit_tests/FGGroundCallbackTest.h @@ -55,6 +55,8 @@ class FGGroundCallbackTest : public CxxTest::TestSuite double lat_rad = lat*M_PI/180.; loc = FGLocation(lon_rad, lat_rad, RadiusReference); double agl = cb->GetAGLevel(loc, contact, normal, v, w); + double agl_2 = cb->GetAGLevel(loc); + TS_ASSERT_EQUALS(agl, agl_2); TS_ASSERT_DELTA(0.0, agl, 1e-8); TS_ASSERT_VECTOR_EQUALS(v, zero); TS_ASSERT_VECTOR_EQUALS(w, zero); @@ -88,6 +90,8 @@ class FGGroundCallbackTest : public CxxTest::TestSuite double lat_rad = lat*M_PI/180.; loc = FGLocation(lon_rad, lat_rad, RadiusReference+h); double agl = cb->GetAGLevel(loc, contact, normal, v, w); + double agl_2 = cb->GetAGLevel(loc); + TS_ASSERT_EQUALS(agl, agl_2); TS_ASSERT_DELTA(h/agl, 1.0, epsilon*100.); TS_ASSERT_VECTOR_EQUALS(v, zero); TS_ASSERT_VECTOR_EQUALS(w, zero); @@ -129,6 +133,8 @@ class FGGroundCallbackTest : public CxxTest::TestSuite double lat_rad = lat*M_PI/180.; loc = FGLocation(lon_rad, lat_rad, RadiusReference+h); double agl = cb->GetAGLevel(loc, contact, normal, v, w); + double agl_2 = cb->GetAGLevel(loc); + TS_ASSERT_EQUALS(agl, agl_2); TS_ASSERT_DELTA((h-elevation)/agl, 1.0, epsilon*100.); TS_ASSERT_VECTOR_EQUALS(v, zero); TS_ASSERT_VECTOR_EQUALS(w, zero); @@ -195,6 +201,8 @@ class FGGroundCallbackTest : public CxxTest::TestSuite double lat_rad = lat*M_PI/180.; loc.SetPositionGeodetic(lon_rad, lat_rad, h); double agl = cb->GetAGLevel(loc, contact, normal, v, w); + double agl_2 = cb->GetAGLevel(loc); + TS_ASSERT_EQUALS(agl, agl_2); TS_ASSERT_DELTA(h, agl, 1e-8); TS_ASSERT_VECTOR_EQUALS(v, zero); TS_ASSERT_VECTOR_EQUALS(w, zero); diff --git a/tests/unit_tests/FGLocationTest.h b/tests/unit_tests/FGLocationTest.h index 44ddd30793..221049e3e4 100644 --- a/tests/unit_tests/FGLocationTest.h +++ b/tests/unit_tests/FGLocationTest.h @@ -115,6 +115,9 @@ class FGLocationTest : public CxxTest::TestSuite lv3.SetEllipse(1., 1.); CheckLocation(lv3, v); + + JSBSim::FGLocation lv4(v, 1., 1.); + CheckLocation(lv3, v); } void testCopyConstructor() {