diff --git a/NEWS b/NEWS index 2b74c69f..b4579b0c 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ Noteworthy changes in version 1.14.1 (unreleased) gpgme_op_setexpire NEW. cpp: Context::setExpire NEW. cpp: Context::startSetExpire NEW. + cpp: EngineInfo::Version::operator<= NEW. + cpp: EngineInfo::Version::operator>= NEW. + cpp: EngineInfo::Version::operator!= NEW. Noteworthy changes in version 1.14.0 (2020-07-16) diff --git a/lang/cpp/src/engineinfo.h b/lang/cpp/src/engineinfo.h index 0bf7d0e8..52bf3474 100644 --- a/lang/cpp/src/engineinfo.h +++ b/lang/cpp/src/engineinfo.h @@ -85,6 +85,16 @@ public: return operator<(Version(other)); } + bool operator <= (const Version &other) + { + return !operator>(other); + } + + bool operator <= (const char *other) + { + return operator<=(Version(other)); + } + bool operator > (const char* other) { return operator>(Version(other)); @@ -95,6 +105,16 @@ public: return !operator<(other) && !operator==(other); } + bool operator >= (const Version &other) + { + return !operator<(other); + } + + bool operator >= (const char *other) + { + return operator>=(Version(other)); + } + bool operator == (const Version& other) { return major == other.major @@ -107,6 +127,16 @@ public: return operator==(Version(other)); } + bool operator != (const Version &other) + { + return !operator==(other); + } + + bool operator != (const char *other) + { + return operator!=(Version(other)); + } + friend std::ostream& operator << (std::ostream& stream, const Version& ver) { stream << ver.major; diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index 9f7b1cec..bec0a57e 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -245,6 +245,38 @@ private Q_SLOTS: 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.1.0") > EngineInfo::Version("3.0.20")); + + QVERIFY(EngineInfo::Version("1.1.1") <= "2.0.0"); + QVERIFY(EngineInfo::Version("1.1.1") <= "1.2.0"); + QVERIFY(EngineInfo::Version("1.1.1") <= "1.1.2"); + QVERIFY(EngineInfo::Version("1.1.1") <= "1.1.1"); + QVERIFY(!(EngineInfo::Version("1.1.1") <= "1.1.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") <= "1.0.9")); + QVERIFY(!(EngineInfo::Version("1.1.1") <= "0.9.9")); + + QVERIFY(!(EngineInfo::Version("1.1.1") == "2.0.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") == "1.2.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") == "1.1.2")); + QVERIFY(EngineInfo::Version("1.1.1") == "1.1.1"); + QVERIFY(!(EngineInfo::Version("1.1.1") == "1.1.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") == "1.0.9")); + QVERIFY(!(EngineInfo::Version("1.1.1") == "0.9.9")); + + QVERIFY(EngineInfo::Version("1.1.1") != "2.0.0"); + QVERIFY(EngineInfo::Version("1.1.1") != "1.2.0"); + QVERIFY(EngineInfo::Version("1.1.1") != "1.1.2"); + QVERIFY(!(EngineInfo::Version("1.1.1") != "1.1.1")); + QVERIFY(EngineInfo::Version("1.1.1") != "1.1.0"); + QVERIFY(EngineInfo::Version("1.1.1") != "1.0.9"); + QVERIFY(EngineInfo::Version("1.1.1") != "0.9.9"); + + QVERIFY(!(EngineInfo::Version("1.1.1") >= "2.0.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") >= "1.2.0")); + QVERIFY(!(EngineInfo::Version("1.1.1") >= "1.1.2")); + QVERIFY(EngineInfo::Version("1.1.1") >= "1.1.1"); + QVERIFY(EngineInfo::Version("1.1.1") >= "1.1.0"); + QVERIFY(EngineInfo::Version("1.1.1") >= "1.0.9"); + QVERIFY(EngineInfo::Version("1.1.1") >= "0.9.9"); } void initTestCase()