Unit tests for acceleration and more for vector

This commit is contained in:
Klaus Basan
2013-04-25 20:21:04 +02:00
parent 2d8720c6ae
commit 5eac9be7d5
16 changed files with 88 additions and 59 deletions

View File

@@ -10,14 +10,6 @@ using namespace BlackMisc::PhysicalQuantities;
namespace BlackMiscTest
{
/*
* Constructor
*/
CTestPhysicalQuantities::CTestPhysicalQuantities(QObject *parent) : QObject(parent)
{
// void
}
/*
* Basic unit tests for physical units
*/
@@ -163,6 +155,22 @@ void CTestPhysicalQuantities::timeTests()
QVERIFY2(t1.convertedSiValueToInteger() == 3600, "1hour shall be 3600s");
}
/*
* Test acceleration
*/
void CTestPhysicalQuantities::accelerationTests()
{
CLength oneMeter(1, CLengthUnit::m());
double ftFactor = oneMeter.switchUnit(CLengthUnit::ft()).unitValueToDouble();
CAcceleration a1(10.0, CAccelerationUnit::m_s2());
CAcceleration a2(a1);
a1.switchUnit(CAccelerationUnit::ft_s2());
QVERIFY2(a1 == a2, "Accelerations should be similar");
QVERIFY2(BlackMisc::Math::CMath::round(a1.unitValueToDouble() * ftFactor, 6) == a2.unitValueToDoubleRounded(6),
"Numerical values should be equal");
}
/*
* Just testing obvious memory create / destruct flaws
*/
@@ -182,7 +190,7 @@ void CTestPhysicalQuantities::memoryTests()
}
/*
* @brief Just testing obvious memory create / destruct flaws
* Some very basic arithmetic tests on the PQs
*/
void CTestPhysicalQuantities::basicArithmetic()
{
@@ -195,5 +203,7 @@ void CTestPhysicalQuantities::basicArithmetic()
QVERIFY2(p3 == p1, "Pressure needs to be the same (1time)");
p3 = p3 - p3;
QVERIFY2(p3.unitValueToDouble() == 0, "Value needs to be zero");
p3 = CPressure(1013, CPressureUnit::hPa());
QVERIFY2(p3 * 1.5 == 1.5 * p3, "Basic commutative test on PQ failed");
}
} // namespace