Added unit test based on discussion here

https://swift-project.slack.com/archives/G7GD2UP9C/p1515602377000431
This commit is contained in:
Klaus Basan
2018-01-10 18:32:23 +01:00
parent 48a85f80a8
commit 604c3eb088
2 changed files with 11 additions and 6 deletions

View File

@@ -41,7 +41,6 @@ using namespace BlackMisc::Math;
namespace BlackMiscTest namespace BlackMiscTest
{ {
/* /*
* Basic unit tests for physical units * Basic unit tests for physical units
*/ */
@@ -163,14 +162,22 @@ namespace BlackMiscTest
*/ */
void CTestPhysicalQuantities::pressureTests() void CTestPhysicalQuantities::pressureTests()
{ {
CPressure p1(1013.25, CPressureUnit::hPa()); const CPressure p1(1013.25, CPressureUnit::hPa());
CPressure p2(29.92, CPressureUnit::inHg()); const CPressure p2(29.92, CPressureUnit::inHg());
CPressure p4(p1); CPressure p4(p1);
p4.switchUnit(CPressureUnit::mbar()); p4.switchUnit(CPressureUnit::mbar());
// does not match exactly // does not match exactly
QVERIFY2(p1 != p2, "Standard pressure test little difference"); QVERIFY2(p1 != p2, "Standard pressure test little difference");
QVERIFY2(p1.value() == p4.value(), "mbar/hPa test"); QVERIFY2(p1.value() == p4.value(), "mbar/hPa test");
// Unit substract test
const CPressure seaLevelPressure(918.0, CPressureUnit::mbar());
const CPressure standardPressure(1013.2, CPressureUnit::mbar());
const CPressure delta = (standardPressure - seaLevelPressure);
const double expected = 95.2;
const double deltaV = delta.value(CPressureUnit::mbar());
QCOMPARE(deltaV, expected);
} }
/* /*

View File

@@ -46,7 +46,7 @@ namespace BlackMiscTest
//! Testing angles (degrees / radians) //! Testing angles (degrees / radians)
void angleTests(); void angleTests();
//! Testing angles //! Testing mass
void massTests(); void massTests();
//! Testing pressure //! Testing pressure
@@ -69,9 +69,7 @@ namespace BlackMiscTest
//! Basic arithmetic such as +/- //! Basic arithmetic such as +/-
void basicArithmetic(); void basicArithmetic();
}; };
} // namespace } // namespace
//! \endcond //! \endcond