Skip to content

Commit

Permalink
Add test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Birkhold committed Nov 22, 2024
1 parent 3a01248 commit 8f6328e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/unit_tests/FGAtmosphereTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions tests/unit_tests/FGColumnVector3Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tests/unit_tests/FGGroundCallbackTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/FGLocationTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 8f6328e

Please sign in to comment.