mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 20:55:42 +08:00
refs #197, unit test and preliminary fix for nullUnit comparison
This commit is contained in:
@@ -36,6 +36,7 @@ namespace BlackMisc
|
|||||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator ==(const CPhysicalQuantity<MU, PQ> &other) const
|
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator ==(const CPhysicalQuantity<MU, PQ> &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
|
if (this->isNull() && other.isNull()) return true; // preliminary fix
|
||||||
double diff = std::abs(this->m_value - other.value(this->m_unit));
|
double diff = std::abs(this->m_value - other.value(this->m_unit));
|
||||||
return diff <= this->m_unit.getEpsilon();
|
return diff <= this->m_unit.getEpsilon();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "testvariantandmap.h"
|
#include "testvariantandmap.h"
|
||||||
#include "blackmisc/avatcstation.h"
|
#include "blackmisc/avatcstation.h"
|
||||||
#include "blackmisc/valuemap.h"
|
#include "blackmisc/valuemap.h"
|
||||||
|
#include "blackmisc/tuple.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -39,8 +40,16 @@ namespace BlackMiscTest
|
|||||||
geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2);
|
geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2);
|
||||||
|
|
||||||
// compare
|
// compare
|
||||||
|
CLength l1(0, CLengthUnit::nullUnit());
|
||||||
|
CLength l2(0, CLengthUnit::nullUnit());
|
||||||
|
QVERIFY2(l1 == l2, "Null lengths should be equal");
|
||||||
|
|
||||||
QVariant station1qv = QVariant::fromValue(station1);
|
QVariant station1qv = QVariant::fromValue(station1);
|
||||||
QVERIFY2(station1 == station1, "Station should be equal");
|
QVERIFY2(station1 == station1, "Station should be equal");
|
||||||
|
|
||||||
|
QVERIFY(station1.getController() == station2.getController());
|
||||||
|
QVERIFY(station1.getDistanceToPlane() == station2.getDistanceToPlane());
|
||||||
|
|
||||||
QVERIFY2(station1 == station2, "Station should be equal");
|
QVERIFY2(station1 == station2, "Station should be equal");
|
||||||
QVERIFY2(station1 != station3, "Station should not be equal");
|
QVERIFY2(station1 != station3, "Station should not be equal");
|
||||||
QVERIFY2(station1qv == station1, "Station should be equal (QVariant)");
|
QVERIFY2(station1qv == station1, "Station should be equal (QVariant)");
|
||||||
|
|||||||
Reference in New Issue
Block a user