32using namespace swift::misc::weather;
33using namespace swift::misc::aviation;
34using namespace swift::misc::physical_quantities;
54 void CTestWeather::cloudLayer()
59 CCloudLayer cl1(base1, top1, CCloudLayer::Scattered);
60 QVERIFY(cl1.getBase() == base1);
62 QCOMPARE(cl1.getPrecipitationRate(), 0.0);
63 QVERIFY(cl1.getPrecipitation() == CCloudLayer::NoPrecipitation);
64 QVERIFY(cl1.getClouds() == CCloudLayer::NoClouds);
65 QVERIFY(cl1.getCoverage() == CCloudLayer::Scattered);
70 CCloudLayer cl2 { base2, top2, 5, CCloudLayer::Rain, CCloudLayer::Cirrus, CCloudLayer::Scattered };
79 CCloudLayerList cll { cl1, cl2 };
88 void CTestWeather::windLayer()
95 CWindLayer wl1(level1, direction1, speed1, gustSpeed1);
96 QVERIFY(wl1.getLevel() == level1);
97 QVERIFY(wl1.getDirection() == direction1);
98 QVERIFY(wl1.getSpeed() == speed1);
99 QVERIFY(wl1.getGustSpeed() == gustSpeed1);
102 CWindLayerList wll { wl1 };
109 void CTestWeather::metarDecoder()
111 CMetarDecoder metarDecoder;
112 CMetar metar = metarDecoder.decode(
"KLBB 241753Z 20009KT 10SM -SHRA FEW045 SCT220 SCT300 28/17 A3022");
115 QVERIFY2(metar.
getTime() == CTime(17, 53, 0),
"Failed to parse time of report");
117 "Failed to parse wind direction");
126 QVERIFY2(presentWeatherList.size() == 1,
"Present weather has an incorrect size");
127 auto presentWeather = presentWeatherList.frontOrDefault();
128 QVERIFY2(presentWeather.getIntensity() == CPresentWeather::Light,
"Itensity should be light");
129 QVERIFY2(presentWeather.getDescriptor() == CPresentWeather::Showers,
"Descriptor should be showers");
130 QVERIFY2(presentWeather.getWeatherPhenomena() & CPresentWeather::Rain,
131 "Weather phenomina 'rain' should be set");
132 QVERIFY2((presentWeather.getWeatherPhenomena() & CPresentWeather::Snow) == 0,
133 "Weather phenomina 'Snow' should NOT be set");
137 "Cloud layer 4500 ft missing");
139 "Cloud layer 22000 ft missing");
141 "Cloud layer 30000 ft missing");
144 "Failed to parse cloud layer in 4500 ft");
146 CCloudLayer::Scattered,
147 "Failed to parse cloud layer in 22000 ft");
149 CCloudLayer::Scattered,
150 "Failed to parse cloud layer in 30000 ft");
152 CMetar metar2 = metarDecoder.decode(
"EDDM 241753Z 20009G11KT 9000NDV FEW045 SCT220 SCT300 ///// Q1013");
155 QVERIFY2(metar2.
getTime() == CTime(17, 53, 0),
"Failed to parse time of report");
157 "Failed to parse wind direction");
160 "Wind gust speed should be null");
167 QVERIFY2(presentWeatherList2.size() == 0,
"Present weather has an incorrect size");
171 "Cloud layer 4500 ft missing");
173 "Cloud layer 22000 ft missing");
175 "Cloud layer 30000 ft missing");
178 "Failed to parse cloud layer in 4500 ft");
180 CCloudLayer::Scattered,
181 "Failed to parse cloud layer in 22000 ft");
183 CCloudLayer::Scattered,
184 "Failed to parse cloud layer in 30000 ft");
192#include "testweather.moc"
static CAngleUnit deg()
Degrees.
Altitude as used in aviation, can be AGL or MSL altitude.
static CLengthUnit m()
Meter m.
static CLengthUnit SM()
Statute mile.
static CLengthUnit ft()
Foot ft.
static CPressureUnit inHg()
Inch of mercury at 0°C.
static CPressureUnit hPa()
Hectopascal.
static CSpeedUnit kts()
Knots.
static CTemperatureUnit C()
Centigrade C.
Clouds getClouds() const
Get cloud type.
misc::aviation::CAltitude getTop() const
Get layer top.
double getPrecipitationRate() const
Get precipitation rate in mm/h.
Coverage getCoverage() const
Get coverage.
misc::aviation::CAltitude getBase() const
Get base.
Precipitation getPrecipitation() const
Get precipitation.
CCloudLayer findByBase(const aviation::CAltitude &base) const
Find cloud layer by base.
bool containsBase(const aviation::CAltitude &base) const
Contains cloud layer with base?
physical_quantities::CSpeed getGustSpeed() const
Get weather phenomenas.
physical_quantities::CSpeed getSpeed() const
Get descriptor.
physical_quantities::CAngle getDirection() const
Get direction.
bool containsLevel(const swift::misc::aviation::CAltitude &level) const
Contains cloud layer with level?
CWindLayer findByLevel(const swift::misc::aviation::CAltitude &level) const
Find cloud layer by level.
QCOMPARE(actual, expected)
QVERIFY2(condition, message)
#define SWIFTTEST_APPLESS_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...