cpp, qt: Fix version info comparison
* lang/cpp/src/engineinfo.h (EngineInfo::Version::operator>(const Version &)): Fix logic. (EngineInfo::Version::operator>(const char *)): Use Version-overload of operator>. * lang/qt/tests/t-various.cpp: Add test. -- This fixes a logic error that 2.0.0 > 2.0.0 would return true.
This commit is contained in:
parent
25e2d717f4
commit
2f53a2f4be
@ -87,13 +87,14 @@ public:
|
|||||||
|
|
||||||
bool operator > (const char* other)
|
bool operator > (const char* other)
|
||||||
{
|
{
|
||||||
return !operator<(Version(other));
|
return operator>(Version(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (const Version & other)
|
bool operator > (const Version & other)
|
||||||
{
|
{
|
||||||
return !operator<(other);
|
return !operator<(other) && !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const Version& other)
|
bool operator == (const Version& other)
|
||||||
{
|
{
|
||||||
return major == other.major
|
return major == other.major
|
||||||
|
@ -241,6 +241,7 @@ private Q_SLOTS:
|
|||||||
QVERIFY(EngineInfo::Version("1.0.0") < EngineInfo::Version("2.0.0"));
|
QVERIFY(EngineInfo::Version("1.0.0") < EngineInfo::Version("2.0.0"));
|
||||||
QVERIFY(EngineInfo::Version("0.1.0") < EngineInfo::Version("1.0.0"));
|
QVERIFY(EngineInfo::Version("0.1.0") < EngineInfo::Version("1.0.0"));
|
||||||
QVERIFY(!(EngineInfo::Version("2.0.0") < EngineInfo::Version("2.0.0")));
|
QVERIFY(!(EngineInfo::Version("2.0.0") < EngineInfo::Version("2.0.0")));
|
||||||
|
QVERIFY(!(EngineInfo::Version("2.0.0") > EngineInfo::Version("2.0.0")));
|
||||||
QVERIFY(EngineInfo::Version("3.0.0") > EngineInfo::Version("2.3.20"));
|
QVERIFY(EngineInfo::Version("3.0.0") > EngineInfo::Version("2.3.20"));
|
||||||
QVERIFY(EngineInfo::Version("3.0.1") > EngineInfo::Version("3.0.0"));
|
QVERIFY(EngineInfo::Version("3.0.1") > EngineInfo::Version("3.0.0"));
|
||||||
QVERIFY(EngineInfo::Version("3.1.0") > EngineInfo::Version("3.0.20"));
|
QVERIFY(EngineInfo::Version("3.1.0") > EngineInfo::Version("3.0.20"));
|
||||||
|
Loading…
Reference in New Issue
Block a user