diff --git a/src/blackmisc/pqphysicalquantity.cpp b/src/blackmisc/pqphysicalquantity.cpp index 92e86d177..0e3f951d1 100644 --- a/src/blackmisc/pqphysicalquantity.cpp +++ b/src/blackmisc/pqphysicalquantity.cpp @@ -36,6 +36,7 @@ namespace BlackMisc template bool CPhysicalQuantity::operator ==(const CPhysicalQuantity &other) const { 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)); return diff <= this->m_unit.getEpsilon(); } diff --git a/tests/blackmisc/testvariantandmap.cpp b/tests/blackmisc/testvariantandmap.cpp index 315d6ac7e..5dc52693e 100644 --- a/tests/blackmisc/testvariantandmap.cpp +++ b/tests/blackmisc/testvariantandmap.cpp @@ -6,6 +6,7 @@ #include "testvariantandmap.h" #include "blackmisc/avatcstation.h" #include "blackmisc/valuemap.h" +#include "blackmisc/tuple.h" #include #include #include @@ -39,8 +40,16 @@ namespace BlackMiscTest geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2); // compare + CLength l1(0, CLengthUnit::nullUnit()); + CLength l2(0, CLengthUnit::nullUnit()); + QVERIFY2(l1 == l2, "Null lengths should be equal"); + QVariant station1qv = QVariant::fromValue(station1); 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 != station3, "Station should not be equal"); QVERIFY2(station1qv == station1, "Station should be equal (QVariant)");