diff --git a/samples/blackmiscquantities/samplesphysicalquantities.cpp b/samples/blackmiscquantities/samplesphysicalquantities.cpp index ea942d3c4..25078f6e5 100644 --- a/samples/blackmiscquantities/samplesphysicalquantities.cpp +++ b/samples/blackmiscquantities/samplesphysicalquantities.cpp @@ -92,14 +92,6 @@ namespace BlackMiscTest qDebug() << t1 << t2 << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true); 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 // CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible CLengthUnit duB(CLengthUnit::cm()); @@ -111,7 +103,12 @@ namespace BlackMiscTest CTime ti3(1.0101, CTimeUnit::hms()); CTime ti4(1.15, CTimeUnit::hrmin()); 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() << ti6 << ti7 << ti8; CAcceleration ac1(10, CAccelerationUnit::m_s2()); qDebug() << ac1 << ac1.toQString(true) << ac1.valueRoundedWithUnit(-1, true) << "I18N/UTF"; diff --git a/tests/blackmisc/testphysicalquantities.cpp b/tests/blackmisc/testphysicalquantities.cpp index d2e2b5ce2..5c813de04 100644 --- a/tests/blackmisc/testphysicalquantities.cpp +++ b/tests/blackmisc/testphysicalquantities.cpp @@ -197,6 +197,18 @@ namespace BlackMiscTest 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 */ diff --git a/tests/blackmisc/testphysicalquantities.h b/tests/blackmisc/testphysicalquantities.h index 510b3f7d6..19abe604f 100644 --- a/tests/blackmisc/testphysicalquantities.h +++ b/tests/blackmisc/testphysicalquantities.h @@ -12,82 +12,58 @@ namespace BlackMiscTest { -/*! - * \brief Physical quantities, basic tests - */ -class CTestPhysicalQuantities : public QObject -{ - Q_OBJECT - -public: /*! - * \brief Standard test case constructor - * \param parent + * \brief Physical quantities, basic tests */ - explicit CTestPhysicalQuantities(QObject *parent = nullptr) : QObject(parent) {} + class CTestPhysicalQuantities : public QObject + { + Q_OBJECT -private slots: - /*! - * \brief Basic unit tests for physical units - */ - void unitsBasics(); + public: + //! Standard test case constructor + explicit CTestPhysicalQuantities(QObject *parent = nullptr) : QObject(parent) {} - /*! - * \brief Basic tests around length - */ - void lengthBasics(); + private slots: + //! Basic unit tests for physical units + void unitsBasics(); - /*! - * \brief Basic tests about speed - */ - void speedBasics(); + //! Basic tests around length + void lengthBasics(); - /*! - * \brief Frequency tests - */ - void frequencyTests(); + //! Basic tests about speed + void speedBasics(); - /*! - * \brief Testing angles (degrees / radians) - */ - void angleTests(); + //! Frequency tests + void frequencyTests(); - /*! - * \brief Testing angles - */ - void massTests(); + //! Testing angles (degrees / radians) + void angleTests(); - /*! - * \brief Testing pressure - */ - void pressureTests(); + //! Testing angles + void massTests(); - /*! - * \brief Testing temperature - */ - void temperatureTests(); + //! Testing pressure + void pressureTests(); - /*! - * \brief Testing time - */ - void timeTests(); + //! Testing temperature + void temperatureTests(); - /*! - * \brief Testing acceleration - */ - void accelerationTests(); + //! Testing time + void timeTests(); - /*! - * \brief Testing construction / destruction in memory - */ - void memoryTests(); + //! Testing acceleration + void accelerationTests(); - /*! - * \brief Basic arithmetic such as +/- - */ - void basicArithmetic(); + //! Testing construction / destruction in memory + void memoryTests(); -}; + //! Test parsing on PQs + void parserTests(); + + //! Basic arithmetic such as +/- + void basicArithmetic(); + + }; } // namespace