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