Debian Codegraph @

test_suite/unit_tests/FDM/testYASimAtmosphere.cxx

raw symbols SCIP
1 #include "test_suite/FGTestApi/PrivateAccessorFDM.hxx"
2
3 #include "testYASimAtmosphere.hxx"
4
5 #include <FDM/YASim/Math.hpp>
6
7 #include <simgear/debug/logstream.hxx>
8
9
10 using namespace yasim;
11
12 void YASimAtmosphereTests::setUp()
13 {
14 a.reset(new Atmosphere());
15 }
16
17
18 void YASimAtmosphereTests::tearDown()
19 {
20 a.reset();
21 }
22
23
24 void YASimAtmosphereTests::testAtmosphere()
25 {
26 auto accessor = FGTestApi::PrivateAccessor::FDM::Accessor();
27
28 int numColumns = accessor.read_FDM_YASim_Atmosphere_numColumns(a);
29 int maxTableIndex = a->maxTableIndex();
30 int rows = maxTableIndex + 1;
31 const float maxDeviation = 0.0002f;
32
33 SG_LOG(SG_GENERAL, SG_INFO, "Columns = " << numColumns);
34 SG_LOG(SG_GENERAL, SG_INFO, "Rows = " << rows);
35
36 for (int alt = 0; alt <= maxTableIndex; alt++) {
37 float density = a->calcStdDensity(accessor.read_FDM_YASim_Atmosphere_data(a, alt, a->PRESSURE), accessor.read_FDM_YASim_Atmosphere_data(a, alt, a->TEMPERATURE));
38 float delta = accessor.read_FDM_YASim_Atmosphere_data(a, alt, a->DENSITY) - density;
39 SG_LOG(SG_GENERAL, SG_INFO, "alt: " << alt << ", delta: " << delta);
40 if (Math::abs(delta) > maxDeviation)
41 CPPUNIT_FAIL("Deviation above limit of 0.0002");
42 }
43 SG_LOG(SG_GENERAL, SG_INFO, "Deviation below " << maxDeviation << " for all rows.");
44 }