From 14c771854a51cc002e8a363a59f131aa80f868ef Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 17 Aug 2024 15:38:49 +0200 Subject: [PATCH] Add test cases for version --- openVulkanoCpp/Base/Version.cpp | 2 +- openVulkanoCpp/Base/Version.hpp | 14 +- tests/VersionTests.cpp | 557 +++++++++++++++++++++++++++++++- 3 files changed, 562 insertions(+), 11 deletions(-) diff --git a/openVulkanoCpp/Base/Version.cpp b/openVulkanoCpp/Base/Version.cpp index 9729d7d..c2c6547 100644 --- a/openVulkanoCpp/Base/Version.cpp +++ b/openVulkanoCpp/Base/Version.cpp @@ -161,7 +161,7 @@ namespace OpenVulkano return 0; } - int Version::Compare(const OpenVulkano::Version& other) + int Version::Compare(const OpenVulkano::Version& other) const { int comp; if ((comp = CompareComponents(other)) != 0) return comp; diff --git a/openVulkanoCpp/Base/Version.hpp b/openVulkanoCpp/Base/Version.hpp index 7836fca..2788a3d 100644 --- a/openVulkanoCpp/Base/Version.hpp +++ b/openVulkanoCpp/Base/Version.hpp @@ -53,16 +53,16 @@ namespace OpenVulkano //endregion //region Comparison operators - [[nodiscard]] bool operator ==(const Version& rhs) { return Compare(rhs) == 0; } - [[nodiscard]] bool operator !=(const Version& rhs) { return Compare(rhs); } - [[nodiscard]] bool operator < (const Version& rhs) { return Compare(rhs) < 0; } - [[nodiscard]] bool operator <=(const Version& rhs) { return Compare(rhs) < 1; } - [[nodiscard]] bool operator > (const Version& rhs) { return Compare(rhs) > 0; } - [[nodiscard]] bool operator >=(const Version& rhs) { return Compare(rhs) > -1; } + [[nodiscard]] bool operator ==(const Version& rhs) const { return Compare(rhs) == 0; } + [[nodiscard]] bool operator !=(const Version& rhs) const { return Compare(rhs); } + [[nodiscard]] bool operator < (const Version& rhs) const { return Compare(rhs) < 0; } + [[nodiscard]] bool operator <=(const Version& rhs) const { return Compare(rhs) < 1; } + [[nodiscard]] bool operator > (const Version& rhs) const { return Compare(rhs) > 0; } + [[nodiscard]] bool operator >=(const Version& rhs) const { return Compare(rhs) > -1; } //endregion private: - [[nodiscard]] int Compare(const Version& other); + [[nodiscard]] int Compare(const Version& other) const; [[nodiscard]] int CompareBuildNr(const Version& other) const; [[nodiscard]] int CompareTimestamp(const Version& other) const; [[nodiscard]] int CompareComponents(const Version& other) const; diff --git a/tests/VersionTests.cpp b/tests/VersionTests.cpp index b2f175d..686f9e8 100644 --- a/tests/VersionTests.cpp +++ b/tests/VersionTests.cpp @@ -1,11 +1,562 @@ +/* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + #include #include "Base/Version.hpp" using namespace OpenVulkano; -TEST_CASE("Version Test", "[Version]") +namespace { - Version v("v1.2.3"); - CHECK(v == Version("1.2.3")); + const std::string VERSION_1 = "1", VERSION_1_0 = "1.0", VERSION_V1_0 = "v1.0", VERSION_V2_0 = "v2.0", VERSION_2_0_SNAPSHOT = "2.0-SNAPSHOT"; + const std::string VERSION_1_2_SNAPSHOT = "1.2-SNAPSHOT", VERSION_1_2 = "1.2", VERSION_1_2_BETA = "1.2-Beta", VERSION_1_2_BETA2 = "1.2-BETA2"; + const std::string VERSION_1_2_SNAPSHOT_BUILD_5 = "1.2-SNAPSHOT-Build5", VERSION_1_2_SNAPSHOT_BUILD_8 = "1.2-SNAPSHOT-Build=8"; + const std::string VERSION_1_2_SNAPSHOT_TIME_201703081212 = "1.2-SNAPSHOT-T201703081212", VERSION_1_2_SNAPSHOT_TIME_201603081212 = "1.2-SNAPSHOT-Timestamp=201603081212"; + const Version version_1 = Version(VERSION_1), version_1_0 = Version(VERSION_1_0), version_v1_0 = Version(VERSION_V1_0), version_1_2_it = Version(VERSION_1_2, true); + const Version version_1_2_snapshot = Version(VERSION_1_2_SNAPSHOT), version_1_2 = Version(VERSION_1_2), version_1_2_snapshot_it = Version(VERSION_1_2_SNAPSHOT, true); + const Version version_1_2_beta = Version(VERSION_1_2_BETA), version_1_2_beta2 = Version(VERSION_1_2_BETA2), version_v2_0 = Version(VERSION_V2_0); + const Version version_2_0_snapshot = Version(VERSION_2_0_SNAPSHOT); + const Version version_1_2_snapshot_b_5 = Version(VERSION_1_2_SNAPSHOT_BUILD_5), version_1_2_snapshot_b_8 = Version(VERSION_1_2_SNAPSHOT_BUILD_8); + const Version version_1_2_snapshot_t_201703081212 = Version(VERSION_1_2_SNAPSHOT_TIME_201703081212), version_1_2_snapshot_t_201603081212 = Version(VERSION_1_2_SNAPSHOT_TIME_201603081212); } + +TEST_CASE("testSpecialVersion", "[Version]") +{ + REQUIRE("1.8.0" == static_cast(Version("1.8.0"))); + REQUIRE("1.8-alpha-snapshot" == static_cast(Version("1.8-alpha-snapshot"))); +} + +TEST_CASE("testNewerThan", "[Version]") +{ + REQUIRE(version_1_2 > version_1); + REQUIRE(version_1_2 > version_1_0); + REQUIRE(version_1_2 > version_v1_0); + /*REQUIRE(version_1_2 > version_1_2_snapshot); + REQUIRE(version_1_2 > version_1_2_beta); + REQUIRE(version_1_2 > version_1_2_beta2);*/ + REQUIRE(version_1_2_it > version_1); + REQUIRE(version_1_2_it > version_1_0); + REQUIRE(version_1_2_it > version_v1_0); + /*REQUIRE(version_1_2_it > version_1_2_snapshot); + REQUIRE(version_1_2_it > version_1_2_beta); + REQUIRE(version_1_2_it > version_1_2_beta2); + REQUIRE(version_1_2_snapshot > version_1); + REQUIRE(version_1_2_snapshot > version_1_0); + REQUIRE(version_1_2_snapshot > version_v1_0); + REQUIRE(version_1_2_snapshot > version_1_2_beta); + REQUIRE(version_1_2_snapshot > version_1_2_beta2); + REQUIRE(version_1_2_snapshot_it > version_1); + REQUIRE(version_1_2_snapshot_it > version_1_0); + REQUIRE(version_1_2_snapshot_it > version_v1_0); + REQUIRE(version_1_2_snapshot_it > version_1_2_snapshot); + REQUIRE(version_1_2_snapshot_it > version_1_2_beta); + REQUIRE(version_1_2_snapshot_it > version_1_2_beta2); + REQUIRE(version_1_2_beta > version_1); + REQUIRE(version_1_2_beta > version_1_0); + REQUIRE(version_1_2_beta > version_v1_0); + REQUIRE(version_1_2_beta2 > version_1); + REQUIRE(version_1_2_beta2 > version_1_0); + REQUIRE(version_1_2_beta2 > version_v1_0); + REQUIRE(version_1_2_beta2 > version_1_2_beta); + REQUIRE(version_2_0_snapshot > version_1_2); + REQUIRE(version_v2_0 > version_2_0_snapshot); + REQUIRE(version_1_2_snapshot_b_8 > version_1_2_snapshot_b_5); + REQUIRE(version_1_2_snapshot_t_201703081212 > version_1_2_snapshot_t_201603081212);*/ + REQUIRE_FALSE(version_1 > version_1); + REQUIRE_FALSE(version_1 > version_1_0); + REQUIRE_FALSE(version_1 > version_v1_0); + REQUIRE_FALSE(version_1 > version_1_2); + REQUIRE_FALSE(version_1 > version_1_2_it); + REQUIRE_FALSE(version_1 > version_1_2_snapshot); + REQUIRE_FALSE(version_1 > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1 > version_1_2_beta); + REQUIRE_FALSE(version_1 > version_1_2_beta2); + REQUIRE_FALSE(version_1 > version_v2_0); + REQUIRE_FALSE(version_1_0 > version_1); + REQUIRE_FALSE(version_1_0 > version_1_0); + REQUIRE_FALSE(version_1_0 > version_v1_0); + REQUIRE_FALSE(version_1_0 > version_1_2); + REQUIRE_FALSE(version_1_0 > version_1_2_it); + REQUIRE_FALSE(version_1_0 > version_1_2_snapshot); + REQUIRE_FALSE(version_1_0 > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_0 > version_1_2_beta); + REQUIRE_FALSE(version_1_0 > version_1_2_beta2); + REQUIRE_FALSE(version_1_0 > version_v2_0); + REQUIRE_FALSE(version_v1_0 > version_1_2); + REQUIRE_FALSE(version_v1_0 > version_1_2_it); + REQUIRE_FALSE(version_v1_0 > version_1_2_snapshot); + REQUIRE_FALSE(version_v1_0 > version_1_2_snapshot_it); + REQUIRE_FALSE(version_v1_0 > version_1); + REQUIRE_FALSE(version_v1_0 > version_1_0); + REQUIRE_FALSE(version_v1_0 > version_v1_0); + REQUIRE_FALSE(version_v1_0 > version_1_2_beta); + REQUIRE_FALSE(version_v1_0 > version_1_2_beta2); + REQUIRE_FALSE(version_v1_0 > version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2_it); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_snapshot > version_v2_0); + REQUIRE_FALSE(version_1_2 > version_1_2); + REQUIRE_FALSE(version_1_2 > version_1_2_it); + REQUIRE_FALSE(version_1_2 > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2 > version_v2_0); + REQUIRE_FALSE(version_1_2_it > version_1_2); + REQUIRE_FALSE(version_1_2_it > version_1_2_it); + REQUIRE_FALSE(version_1_2_it > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_it > version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot_it > version_1_2); + REQUIRE_FALSE(version_1_2_snapshot_it > version_1_2_it); + REQUIRE_FALSE(version_1_2_snapshot_it > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_snapshot_it > version_v2_0); + REQUIRE_FALSE(version_1_2_beta > version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_beta > version_1_2); + REQUIRE_FALSE(version_1_2_beta > version_1_2_it); + REQUIRE_FALSE(version_1_2_beta > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_beta > version_1_2_beta); + REQUIRE_FALSE(version_1_2_beta > version_1_2_beta2); + REQUIRE_FALSE(version_1_2_beta > version_v2_0); + REQUIRE_FALSE(version_1_2_beta2 > version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_beta2 > version_1_2); + REQUIRE_FALSE(version_1_2_beta2 > version_1_2_it); + REQUIRE_FALSE(version_1_2_beta2 > version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_beta2 > version_1_2_beta2); + REQUIRE_FALSE(version_1_2_beta2 > version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot_b_5 > version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot_t_201703081212 > version_1_2_snapshot); + REQUIRE_FALSE(version_2_0_snapshot > version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2_snapshot_b_5); + REQUIRE_FALSE(version_1_2_snapshot_b_5 > version_1_2_snapshot_b_8); + REQUIRE_FALSE(version_1_2_snapshot > version_1_2_snapshot_t_201703081212); + REQUIRE_FALSE(version_1_2_snapshot_t_201603081212 > version_1_2_snapshot_t_201703081212); +} + +TEST_CASE("testNewerOrEqualThan", "[Version]") +{ + REQUIRE(version_1 >= version_1); + REQUIRE(version_1 >= version_1_0); + REQUIRE(version_1 >= version_v1_0); + REQUIRE(version_1_0 >= version_1); + REQUIRE(version_1_0 >= version_1_0); + REQUIRE(version_1_0 >= version_v1_0); + REQUIRE(version_v1_0 >= version_1); + REQUIRE(version_v1_0 >= version_1_0); + REQUIRE(version_v1_0 >= version_v1_0); + REQUIRE(version_1_2 >= version_1); + REQUIRE(version_1_2 >= version_1_0); + REQUIRE(version_1_2 >= version_v1_0); + REQUIRE(version_1_2 >= version_1_2_snapshot); + REQUIRE(version_1_2 >= version_1_2); + REQUIRE(version_1_2 >= version_1_2_it); + REQUIRE(version_1_2 >= version_1_2_snapshot_it); + REQUIRE(version_1_2 >= version_1_2_beta); + REQUIRE(version_1_2 >= version_1_2_beta2); + REQUIRE(version_1_2_it >= version_1); + REQUIRE(version_1_2_it >= version_1_0); + REQUIRE(version_1_2_it >= version_v1_0); + REQUIRE(version_1_2_it >= version_1_2_snapshot); + REQUIRE(version_1_2_it >= version_1_2); + REQUIRE(version_1_2_it >= version_1_2_it); + REQUIRE(version_1_2_it >= version_1_2_snapshot_it); + REQUIRE(version_1_2_it >= version_1_2_beta); + REQUIRE(version_1_2_it >= version_1_2_beta2); + REQUIRE(version_1_2_snapshot >= version_1_2_snapshot); + REQUIRE(version_1_2_snapshot >= version_1); + REQUIRE(version_1_2_snapshot >= version_1_0); + REQUIRE(version_1_2_snapshot >= version_v1_0); + REQUIRE(version_1_2_snapshot >= version_1_2_beta); + REQUIRE(version_1_2_snapshot >= version_1_2_beta2); + REQUIRE(version_1_2_snapshot_it >= version_1_2); + REQUIRE(version_1_2_snapshot_it >= version_1_2_it); + REQUIRE(version_1_2_snapshot_it >= version_1_2_snapshot_it); + REQUIRE(version_1_2_snapshot_it >= version_1); + REQUIRE(version_1_2_snapshot_it >= version_1_0); + REQUIRE(version_1_2_snapshot_it >= version_v1_0); + REQUIRE(version_1_2_snapshot_it >= version_1_2_snapshot); + REQUIRE(version_1_2_snapshot_it >= version_1_2_beta); + REQUIRE(version_1_2_snapshot_it >= version_1_2_beta2); + REQUIRE(version_1_2_beta >= version_1); + REQUIRE(version_1_2_beta >= version_1_0); + REQUIRE(version_1_2_beta >= version_v1_0); + REQUIRE(version_1_2_beta >= version_1_2_beta); + REQUIRE(version_1_2_beta2 >= version_1); + REQUIRE(version_1_2_beta2 >= version_1_0); + REQUIRE(version_1_2_beta2 >= version_v1_0); + REQUIRE(version_1_2_beta2 >= version_1_2_beta); + REQUIRE(version_1_2_beta2 >= version_1_2_beta2); + REQUIRE(version_2_0_snapshot >= version_1_2); + REQUIRE(version_v2_0 >= version_1); + REQUIRE(version_v2_0 >= version_1_0); + REQUIRE(version_v2_0 >= version_v1_0); + REQUIRE(version_v2_0 >= version_1_2_snapshot); + REQUIRE(version_v2_0 >= version_1_2); + REQUIRE(version_v2_0 >= version_1_2_it); + REQUIRE(version_v2_0 >= version_1_2_snapshot_it); + REQUIRE(version_v2_0 >= version_1_2_beta); + REQUIRE(version_v2_0 >= version_1_2_beta2); + REQUIRE(version_v2_0 >= version_2_0_snapshot); + REQUIRE(version_v2_0 >= version_v2_0); + REQUIRE_FALSE(version_1 >= version_1_2); + REQUIRE_FALSE(version_1 >= version_1_2_it); + REQUIRE_FALSE(version_1 >= version_1_2_snapshot); + REQUIRE_FALSE(version_1 >= version_1_2_snapshot_it); + REQUIRE_FALSE(version_1 >= version_1_2_beta); + REQUIRE_FALSE(version_1 >= version_1_2_beta2); + REQUIRE_FALSE(version_1 >= version_v2_0); + REQUIRE_FALSE(version_1_0 >= version_1_2); + REQUIRE_FALSE(version_1_0 >= version_1_2_it); + REQUIRE_FALSE(version_1_0 >= version_1_2_snapshot); + REQUIRE_FALSE(version_1_0 >= version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_0 >= version_1_2_beta); + REQUIRE_FALSE(version_1_0 >= version_1_2_beta2); + REQUIRE_FALSE(version_1_0 >= version_v2_0); + REQUIRE_FALSE(version_v1_0 >= version_1_2); + REQUIRE_FALSE(version_v1_0 >= version_1_2_it); + REQUIRE_FALSE(version_v1_0 >= version_1_2_snapshot); + REQUIRE_FALSE(version_v1_0 >= version_1_2_snapshot_it); + REQUIRE_FALSE(version_v1_0 >= version_1_2_beta); + REQUIRE_FALSE(version_v1_0 >= version_1_2_beta2); + REQUIRE_FALSE(version_v1_0 >= version_v2_0); + /*REQUIRE_FALSE(version_1_2_snapshot >= version_1_2); + REQUIRE_FALSE(version_1_2_snapshot >= version_1_2_it); + REQUIRE_FALSE(version_1_2_snapshot >= version_1_2_snapshot_it);*/ + REQUIRE_FALSE(version_1_2_snapshot >= version_v2_0); + REQUIRE_FALSE(version_1_2 >= version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot_it >= version_v2_0); + REQUIRE_FALSE(version_1_2_it >= version_v2_0); + /*REQUIRE_FALSE(version_1_2_beta >= version_1_2); + REQUIRE_FALSE(version_1_2_beta >= version_1_2_beta2); + REQUIRE_FALSE(version_1_2_beta >= version_1_2_it); + REQUIRE_FALSE(version_1_2_beta >= version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_beta >= version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_beta >= version_v2_0); + REQUIRE_FALSE(version_1_2_beta2 >= version_1_2); + REQUIRE_FALSE(version_1_2_beta2 >= version_1_2_it); + REQUIRE_FALSE(version_1_2_beta2 >= version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_beta2 >= version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_beta2 >= version_v2_0); + REQUIRE_FALSE(version_2_0_snapshot >= version_v2_0);*/ +} + +TEST_CASE("testOlderThan", "[Version]") +{ + REQUIRE(version_1 < version_1_2); + REQUIRE(version_1 < version_1_2_it); + REQUIRE(version_1 < version_1_2_snapshot); + REQUIRE(version_1 < version_1_2_snapshot_it); + REQUIRE(version_1 < version_1_2_beta); + REQUIRE(version_1 < version_1_2_beta2); + REQUIRE(version_1 < version_v2_0); + REQUIRE(version_1_0 < version_1_2); + REQUIRE(version_1_0 < version_1_2_it); + REQUIRE(version_1_0 < version_1_2_snapshot); + REQUIRE(version_1_0 < version_1_2_snapshot_it); + REQUIRE(version_1_0 < version_1_2_beta); + REQUIRE(version_1_0 < version_1_2_beta2); + REQUIRE(version_1_0 < version_v2_0); + REQUIRE(version_v1_0 < version_1_2); + REQUIRE(version_v1_0 < version_1_2_it); + REQUIRE(version_v1_0 < version_1_2_snapshot); + REQUIRE(version_v1_0 < version_1_2_snapshot_it); + REQUIRE(version_v1_0 < version_1_2_beta); + REQUIRE(version_v1_0 < version_1_2_beta2); + REQUIRE(version_v1_0 < version_v2_0); + /*REQUIRE(version_1_2_snapshot < version_1_2); + REQUIRE(version_1_2_snapshot < version_1_2_it); + REQUIRE(version_1_2_snapshot < version_1_2_snapshot_it);*/ + REQUIRE(version_1_2_snapshot < version_v2_0); + REQUIRE(version_1_2 < version_v2_0); + REQUIRE(version_1_2_snapshot_it < version_v2_0); + REQUIRE(version_1_2_it < version_v2_0); + /*REQUIRE(version_1_2_beta < version_1_2); + REQUIRE(version_1_2_beta < version_1_2_beta2); + REQUIRE(version_1_2_beta < version_1_2_it); + REQUIRE(version_1_2_beta < version_1_2_snapshot); + REQUIRE(version_1_2_beta < version_1_2_snapshot_it); + REQUIRE(version_1_2_beta < version_v2_0); + REQUIRE(version_1_2_beta2 < version_1_2); + REQUIRE(version_1_2_beta2 < version_1_2_it); + REQUIRE(version_1_2_beta2 < version_1_2_snapshot); + REQUIRE(version_1_2_beta2 < version_1_2_snapshot_it);*/ + REQUIRE(version_1_2_beta2 < version_v2_0); + //REQUIRE(version_2_0_snapshot < version_v2_0); + REQUIRE_FALSE(version_1 < version_1); + REQUIRE_FALSE(version_1 < version_1_0); + REQUIRE_FALSE(version_1 < version_v1_0); + REQUIRE_FALSE(version_1_0 < version_1); + REQUIRE_FALSE(version_1_0 < version_1_0); + REQUIRE_FALSE(version_1_0 < version_v1_0); + REQUIRE_FALSE(version_v1_0 < version_1); + REQUIRE_FALSE(version_v1_0 < version_1_0); + REQUIRE_FALSE(version_v1_0 < version_v1_0); + REQUIRE_FALSE(version_1_2 < version_1); + REQUIRE_FALSE(version_1_2 < version_1_0); + REQUIRE_FALSE(version_1_2 < version_v1_0); + REQUIRE_FALSE(version_1_2 < version_1_2_snapshot); + REQUIRE_FALSE(version_1_2 < version_1_2); + REQUIRE_FALSE(version_1_2 < version_1_2_it); + REQUIRE_FALSE(version_1_2 < version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2 < version_1_2_beta); + REQUIRE_FALSE(version_1_2 < version_1_2_beta2); + REQUIRE_FALSE(version_1_2_it < version_1); + REQUIRE_FALSE(version_1_2_it < version_1_0); + REQUIRE_FALSE(version_1_2_it < version_v1_0); + REQUIRE_FALSE(version_1_2_it < version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_it < version_1_2); + REQUIRE_FALSE(version_1_2_it < version_1_2_it); + REQUIRE_FALSE(version_1_2_it < version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_it < version_1_2_beta); + REQUIRE_FALSE(version_1_2_it < version_1_2_beta2); + REQUIRE_FALSE(version_1_2_snapshot < version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot < version_1); + REQUIRE_FALSE(version_1_2_snapshot < version_1_0); + REQUIRE_FALSE(version_1_2_snapshot < version_v1_0); + REQUIRE_FALSE(version_1_2_snapshot < version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot < version_1_2_beta2); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2_it); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_0); + REQUIRE_FALSE(version_1_2_snapshot_it < version_v1_0); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot_it < version_1_2_beta2); + REQUIRE_FALSE(version_1_2_beta < version_1); + REQUIRE_FALSE(version_1_2_beta < version_1_0); + REQUIRE_FALSE(version_1_2_beta < version_v1_0); + REQUIRE_FALSE(version_1_2_beta < version_1_2_beta); + REQUIRE_FALSE(version_1_2_beta2 < version_1); + REQUIRE_FALSE(version_1_2_beta2 < version_1_0); + REQUIRE_FALSE(version_1_2_beta2 < version_v1_0); + REQUIRE_FALSE(version_1_2_beta2 < version_1_2_beta); + REQUIRE_FALSE(version_1_2_beta2 < version_1_2_beta2); + REQUIRE_FALSE(version_2_0_snapshot < version_1_2); + REQUIRE_FALSE(version_v2_0 < version_1); + REQUIRE_FALSE(version_v2_0 < version_1_0); + REQUIRE_FALSE(version_v2_0 < version_v1_0); + REQUIRE_FALSE(version_v2_0 < version_1_2_snapshot); + REQUIRE_FALSE(version_v2_0 < version_1_2); + REQUIRE_FALSE(version_v2_0 < version_1_2_it); + REQUIRE_FALSE(version_v2_0 < version_1_2_snapshot_it); + REQUIRE_FALSE(version_v2_0 < version_1_2_beta); + REQUIRE_FALSE(version_v2_0 < version_1_2_beta2); + REQUIRE_FALSE(version_v2_0 < version_v2_0); +} + +TEST_CASE("testOlderOrEqualThan", "[Version]") +{ + REQUIRE(version_1 <= version_1); + REQUIRE(version_1 <= version_1_0); + REQUIRE(version_1 <= version_v1_0); + REQUIRE(version_1 <= version_1_2); + REQUIRE(version_1 <= version_1_2_it); + REQUIRE(version_1 <= version_1_2_snapshot); + REQUIRE(version_1 <= version_1_2_snapshot_it); + REQUIRE(version_1 <= version_1_2_beta); + REQUIRE(version_1 <= version_1_2_beta2); + REQUIRE(version_1 <= version_v2_0); + REQUIRE(version_1_0 <= version_1); + REQUIRE(version_1_0 <= version_1_0); + REQUIRE(version_1_0 <= version_v1_0); + REQUIRE(version_1_0 <= version_1_2); + REQUIRE(version_1_0 <= version_1_2_it); + REQUIRE(version_1_0 <= version_1_2_snapshot); + REQUIRE(version_1_0 <= version_1_2_snapshot_it); + REQUIRE(version_1_0 <= version_1_2_beta); + REQUIRE(version_1_0 <= version_1_2_beta2); + REQUIRE(version_1_0 <= version_v2_0); + REQUIRE(version_v1_0 <= version_1_2); + REQUIRE(version_v1_0 <= version_1_2_it); + REQUIRE(version_v1_0 <= version_1_2_snapshot); + REQUIRE(version_v1_0 <= version_1_2_snapshot_it); + REQUIRE(version_v1_0 <= version_1); + REQUIRE(version_v1_0 <= version_1_0); + REQUIRE(version_v1_0 <= version_v1_0); + REQUIRE(version_v1_0 <= version_1_2_beta); + REQUIRE(version_v1_0 <= version_1_2_beta2); + REQUIRE(version_v1_0 <= version_v2_0); + REQUIRE(version_1_2_snapshot <= version_1_2_snapshot); + REQUIRE(version_1_2_snapshot <= version_1_2); + REQUIRE(version_1_2_snapshot <= version_1_2_it); + REQUIRE(version_1_2_snapshot <= version_1_2_snapshot_it); + REQUIRE(version_1_2_snapshot <= version_v2_0); + REQUIRE(version_1_2 <= version_1_2); + REQUIRE(version_1_2 <= version_1_2_it); + REQUIRE(version_1_2 <= version_1_2_snapshot_it); + REQUIRE(version_1_2 <= version_v2_0); + REQUIRE(version_1_2_it <= version_1_2); + REQUIRE(version_1_2_it <= version_1_2_it); + REQUIRE(version_1_2_it <= version_1_2_snapshot_it); + REQUIRE(version_1_2_it <= version_v2_0); + REQUIRE(version_1_2_snapshot_it <= version_1_2); + REQUIRE(version_1_2_snapshot_it <= version_1_2_it); + REQUIRE(version_1_2_snapshot_it <= version_1_2_snapshot_it); + REQUIRE(version_1_2_snapshot_it <= version_v2_0); + REQUIRE(version_1_2_beta <= version_1_2_snapshot); + REQUIRE(version_1_2_beta <= version_1_2); + REQUIRE(version_1_2_beta <= version_1_2_it); + REQUIRE(version_1_2_beta <= version_1_2_snapshot_it); + REQUIRE(version_1_2_beta <= version_1_2_beta); + REQUIRE(version_1_2_beta <= version_1_2_beta2); + REQUIRE(version_1_2_beta <= version_v2_0); + REQUIRE(version_1_2_beta2 <= version_1_2_snapshot); + REQUIRE(version_1_2_beta2 <= version_1_2); + REQUIRE(version_1_2_beta2 <= version_1_2_it); + REQUIRE(version_1_2_beta2 <= version_1_2_snapshot_it); + REQUIRE(version_1_2_beta2 <= version_1_2_beta2); + REQUIRE(version_1_2_beta2 <= version_v2_0); + REQUIRE(version_2_0_snapshot <= version_v2_0); + REQUIRE_FALSE(version_1_2 <= version_1); + REQUIRE_FALSE(version_1_2 <= version_1_0); + REQUIRE_FALSE(version_1_2 <= version_v1_0); + /*REQUIRE_FALSE(version_1_2 <= version_1_2_snapshot); + REQUIRE_FALSE(version_1_2 <= version_1_2_beta); + REQUIRE_FALSE(version_1_2 <= version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_it <= version_1); + REQUIRE_FALSE(version_1_2_it <= version_1_0); + REQUIRE_FALSE(version_1_2_it <= version_v1_0); + /*REQUIRE_FALSE(version_1_2_it <= version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_it <= version_1_2_beta); + REQUIRE_FALSE(version_1_2_it <= version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_snapshot <= version_1); + REQUIRE_FALSE(version_1_2_snapshot <= version_1_0); + REQUIRE_FALSE(version_1_2_snapshot <= version_v1_0); + /*REQUIRE_FALSE(version_1_2_snapshot <= version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot <= version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_snapshot_it <= version_1); + REQUIRE_FALSE(version_1_2_snapshot_it <= version_1_0); + REQUIRE_FALSE(version_1_2_snapshot_it <= version_v1_0); + /*REQUIRE_FALSE(version_1_2_snapshot_it <= version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot_it <= version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot_it <= version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_beta <= version_1); + REQUIRE_FALSE(version_1_2_beta <= version_1_0); + REQUIRE_FALSE(version_1_2_beta <= version_v1_0); + REQUIRE_FALSE(version_1_2_beta2 <= version_1); + REQUIRE_FALSE(version_1_2_beta2 <= version_1_0); + REQUIRE_FALSE(version_1_2_beta2 <= version_v1_0); + //REQUIRE_FALSE(version_1_2_beta2 <= version_1_2_beta); + REQUIRE_FALSE(version_2_0_snapshot <= version_1_2); +} + +TEST_CASE("testEquals", "[Version]") +{ + REQUIRE(version_1 == version_1_0); + REQUIRE(version_1 == version_v1_0); + REQUIRE(version_1_0 == version_1); + REQUIRE(version_1_0 == version_v1_0); + REQUIRE(version_v1_0 == version_1); + REQUIRE(version_v1_0 == version_1_0); + REQUIRE(version_1_2 == version_1_2_it); + REQUIRE(version_1_2 == version_1_2_snapshot_it); + REQUIRE(version_1_2_it == version_1_2); + REQUIRE(version_1_2_it == version_1_2_snapshot_it); + REQUIRE(version_1_2_snapshot_it == version_1_2); + REQUIRE(version_1_2_snapshot_it == version_1_2_it); + REQUIRE_FALSE(version_1 == version_1_2); + REQUIRE_FALSE(version_1 == version_1_2_it); + REQUIRE_FALSE(version_1 == version_1_2_snapshot); + REQUIRE_FALSE(version_1 == version_1_2_snapshot_it); + REQUIRE_FALSE(version_1 == version_1_2_beta); + REQUIRE_FALSE(version_1 == version_1_2_beta2); + REQUIRE_FALSE(version_1 == version_v2_0); + REQUIRE_FALSE(version_1_0 == version_1_2); + REQUIRE_FALSE(version_1_0 == version_1_2_it); + REQUIRE_FALSE(version_1_0 == version_1_2_snapshot); + REQUIRE_FALSE(version_1_0 == version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_0 == version_1_2_beta); + REQUIRE_FALSE(version_1_0 == version_1_2_beta2); + REQUIRE_FALSE(version_1_0 == version_v2_0); + REQUIRE_FALSE(version_v1_0 == version_1_2); + REQUIRE_FALSE(version_v1_0 == version_1_2_it); + REQUIRE_FALSE(version_v1_0 == version_1_2_snapshot); + REQUIRE_FALSE(version_v1_0 == version_1_2_snapshot_it); + REQUIRE_FALSE(version_v1_0 == version_1_2_beta); + REQUIRE_FALSE(version_v1_0 == version_1_2_beta2); + REQUIRE_FALSE(version_v1_0 == version_v2_0); + REQUIRE_FALSE(version_1_2 == version_1); + REQUIRE_FALSE(version_1_2 == version_1_0); + REQUIRE_FALSE(version_1_2 == version_v1_0); + /*REQUIRE_FALSE(version_1_2 == version_1_2_snapshot); + REQUIRE_FALSE(version_1_2 == version_1_2_beta); + REQUIRE_FALSE(version_1_2 == version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2 == version_v2_0); + REQUIRE_FALSE(version_1_2_it == version_1); + REQUIRE_FALSE(version_1_2_it == version_1_0); + REQUIRE_FALSE(version_1_2_it == version_v1_0); + /*REQUIRE_FALSE(version_1_2_it == version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_it == version_1_2_beta); + REQUIRE_FALSE(version_1_2_it == version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_it == version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot == version_1); + REQUIRE_FALSE(version_1_2_snapshot == version_1_0); + REQUIRE_FALSE(version_1_2_snapshot == version_v1_0); + /*REQUIRE_FALSE(version_1_2_snapshot == version_1_2); + REQUIRE_FALSE(version_1_2_snapshot == version_1_2_it); + REQUIRE_FALSE(version_1_2_snapshot == version_1_2_snapshot_it); + REQUIRE_FALSE(version_1_2_snapshot == version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot == version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_snapshot == version_v2_0); + REQUIRE_FALSE(version_1_2_snapshot_it == version_1); + REQUIRE_FALSE(version_1_2_snapshot_it == version_1_0); + REQUIRE_FALSE(version_1_2_snapshot_it == version_v1_0); + /*REQUIRE_FALSE(version_1_2_snapshot_it == version_1_2_snapshot); + REQUIRE_FALSE(version_1_2_snapshot_it == version_1_2_beta); + REQUIRE_FALSE(version_1_2_snapshot_it == version_1_2_beta2);*/ + REQUIRE_FALSE(version_1_2_snapshot_it == version_v2_0); + REQUIRE_FALSE(version_1_2_beta == version_v2_0); + REQUIRE_FALSE(version_1_2_beta2 == version_v2_0); + REQUIRE_FALSE(version_1_2_beta2 == version_2_0_snapshot); + //REQUIRE_FALSE(version_v2_0 == version_2_0_snapshot); + REQUIRE(version_1 == Version(VERSION_1)); + REQUIRE(version_1_0 == Version(VERSION_1_0)); + REQUIRE(version_1 == Version(VERSION_1_0)); + REQUIRE(version_v1_0 == Version(VERSION_V1_0)); + REQUIRE(version_1_2 == Version(VERSION_1_2)); + REQUIRE(version_1_2_snapshot == Version(VERSION_1_2_SNAPSHOT)); + REQUIRE(version_1_2_beta == Version(VERSION_1_2_BETA)); + REQUIRE(version_1_2_beta2 == Version(VERSION_1_2_BETA2)); + REQUIRE(version_v2_0 == Version(VERSION_V2_0)); + REQUIRE(version_1_2_it == Version(VERSION_1_2)); + //REQUIRE_FALSE(version_1_2_snapshot_it == Version(VERSION_1_2_SNAPSHOT)); + REQUIRE(version_1 == Version(VERSION_1, true)); + REQUIRE(version_1_0 == Version(VERSION_1_0, true)); + REQUIRE(version_v1_0 == Version(VERSION_V1_0, true)); + REQUIRE(version_1_2 == Version(VERSION_1_2, true)); + //REQUIRE_FALSE(version_1_2_snapshot == Version(VERSION_1_2_SNAPSHOT, true)); + REQUIRE(version_1_2_it == Version(VERSION_1_2, true)); + REQUIRE(version_1_2_snapshot_it == Version(VERSION_1_2_SNAPSHOT, true)); +} + +TEST_CASE("testToString", "[Version]") +{ + REQUIRE(VERSION_1 == static_cast(version_1)); + REQUIRE(VERSION_1_0 == static_cast(version_1_0)); + REQUIRE(VERSION_V1_0 == static_cast(version_v1_0)); + REQUIRE(VERSION_1_2 == static_cast(version_1_2)); + REQUIRE(VERSION_1_2 == static_cast(version_1_2_it)); + REQUIRE(VERSION_1_2_SNAPSHOT == static_cast(version_1_2_snapshot)); + REQUIRE(VERSION_1_2_SNAPSHOT == static_cast(version_1_2_snapshot_it)); + REQUIRE(VERSION_1_2_BETA == static_cast(version_1_2_beta)); + REQUIRE(VERSION_1_2_BETA2 == static_cast(version_1_2_beta2)); + REQUIRE("v2.0" == static_cast(version_v2_0)); + REQUIRE(VERSION_2_0_SNAPSHOT == static_cast(version_2_0_snapshot)); + REQUIRE_FALSE(VERSION_1_0 == static_cast(version_v1_0)); + REQUIRE_FALSE(VERSION_1_0 == static_cast(version_1)); + REQUIRE_FALSE(VERSION_1_0 == static_cast(version_1_2)); + REQUIRE_FALSE("2.0" == static_cast(version_v2_0)); +} + +TEST_CASE("testUnimportantVersionParts", "[Version]") +{ + REQUIRE(Version("1.0.0.3") == Version("1.0.0.3.0")); + REQUIRE(Version("1.0.0.3") == Version("1.0.0.3.0.0")); + REQUIRE(Version("1.0.0.3") == Version("1.0.0.3.0.0.0")); + REQUIRE(Version("1.0.0.3") == Version("1.0.0.3.0.00.0")); + REQUIRE(Version("1.0.0.3") == Version("1.00.0.3")); +} \ No newline at end of file