refs #212,improved tests and samples

This commit is contained in:
Klaus Basan
2014-04-30 02:34:55 +02:00
parent 036de1b0e6
commit 96200953ea
3 changed files with 54 additions and 69 deletions

View File

@@ -92,14 +92,6 @@ namespace BlackMiscTest
qDebug() << t1 << t2 << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true); qDebug() << t1 << t2 << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true);
qDebug() << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << "I18N/UTF"; qDebug() << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << "I18N/UTF";
// some logging with CLogMessage
// bDebug << p1;
// bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
// some of the faults Mathew has pointed out, not longer possible
// CAngleUnit::rad() = CAngleUnit::deg();
// qDebug() << CAngleUnit::rad(); // wrong
(t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const (t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const
// CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible // CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible
CLengthUnit duB(CLengthUnit::cm()); CLengthUnit duB(CLengthUnit::cm());
@@ -111,7 +103,12 @@ namespace BlackMiscTest
CTime ti3(1.0101, CTimeUnit::hms()); CTime ti3(1.0101, CTimeUnit::hms());
CTime ti4(1.15, CTimeUnit::hrmin()); CTime ti4(1.15, CTimeUnit::hrmin());
CTime ti5(1.30, CTimeUnit::minsec()); CTime ti5(1.30, CTimeUnit::minsec());
CTime ti6("12:30");
CTime ti7("20s");
CTime ti8("12:30:40");
qDebug() << ti1 << ti2 << ti3 << ti4 << ti5; qDebug() << ti1 << ti2 << ti3 << ti4 << ti5;
qDebug() << ti6 << ti7 << ti8;
CAcceleration ac1(10, CAccelerationUnit::m_s2()); CAcceleration ac1(10, CAccelerationUnit::m_s2());
qDebug() << ac1 << ac1.toQString(true) << ac1.valueRoundedWithUnit(-1, true) << "I18N/UTF"; qDebug() << ac1 << ac1.toQString(true) << ac1.valueRoundedWithUnit(-1, true) << "I18N/UTF";

View File

@@ -197,6 +197,18 @@ namespace BlackMiscTest
delete a; delete a;
} }
/*
* Parsing tests
*/
void CTestPhysicalQuantities::parserTests()
{
QVERIFY2(CLength(33.0, CLengthUnit::ft()) == CLength("33.0 ft"), "Length");
QVERIFY2(CLength(33.0, CLengthUnit::ft()) != CLength("33.1 ft"), "Length !=");
QVERIFY2(CLength(-22.8, CLengthUnit::ft()) != CLength("-22.8 cm"), "Length !=");
QVERIFY2(CSpeed(123.45, CSpeedUnit::km_h()) == CSpeed("123.45km/h"), "Speed");
QVERIFY2(CMass(33.45, CMassUnit::kg()) == CMass("33.45000 kg"), "CMass");
}
/* /*
* Some very basic arithmetic tests on the PQs * Some very basic arithmetic tests on the PQs
*/ */

View File

@@ -12,82 +12,58 @@
namespace BlackMiscTest namespace BlackMiscTest
{ {
/*! /*!
* \brief Physical quantities, basic tests * \brief Physical quantities, basic tests
*/ */
class CTestPhysicalQuantities : public QObject class CTestPhysicalQuantities : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
/*! //! Standard test case constructor
* \brief Standard test case constructor
* \param parent
*/
explicit CTestPhysicalQuantities(QObject *parent = nullptr) : QObject(parent) {} explicit CTestPhysicalQuantities(QObject *parent = nullptr) : QObject(parent) {}
private slots: private slots:
/*! //! Basic unit tests for physical units
* \brief Basic unit tests for physical units
*/
void unitsBasics(); void unitsBasics();
/*! //! Basic tests around length
* \brief Basic tests around length
*/
void lengthBasics(); void lengthBasics();
/*! //! Basic tests about speed
* \brief Basic tests about speed
*/
void speedBasics(); void speedBasics();
/*! //! Frequency tests
* \brief Frequency tests
*/
void frequencyTests(); void frequencyTests();
/*! //! Testing angles (degrees / radians)
* \brief Testing angles (degrees / radians)
*/
void angleTests(); void angleTests();
/*! //! Testing angles
* \brief Testing angles
*/
void massTests(); void massTests();
/*! //! Testing pressure
* \brief Testing pressure
*/
void pressureTests(); void pressureTests();
/*! //! Testing temperature
* \brief Testing temperature
*/
void temperatureTests(); void temperatureTests();
/*! //! Testing time
* \brief Testing time
*/
void timeTests(); void timeTests();
/*! //! Testing acceleration
* \brief Testing acceleration
*/
void accelerationTests(); void accelerationTests();
/*! //! Testing construction / destruction in memory
* \brief Testing construction / destruction in memory
*/
void memoryTests(); void memoryTests();
/*! //! Test parsing on PQs
* \brief Basic arithmetic such as +/- void parserTests();
*/
//! Basic arithmetic such as +/-
void basicArithmetic(); void basicArithmetic();
}; };
} // namespace } // namespace