630 lines
29 KiB
C++
630 lines
29 KiB
C++
/*
|
|
* Copyright (c) 2025. MadVoxel AG
|
|
* All rights reserved.
|
|
*/
|
|
|
|
/*
|
|
* 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 <catch2/catch_all.hpp>
|
|
|
|
#include "Base/Version.hpp"
|
|
|
|
using namespace OpenVulkano;
|
|
|
|
namespace
|
|
{
|
|
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<const std::string&>(Version("1.8.0")));
|
|
REQUIRE("1.8-alpha-snapshot" == static_cast<const std::string&>(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<const std::string&>(version_1));
|
|
REQUIRE(VERSION_1_0 == static_cast<const std::string&>(version_1_0));
|
|
REQUIRE(VERSION_V1_0 == static_cast<const std::string&>(version_v1_0));
|
|
REQUIRE(VERSION_1_2 == static_cast<const std::string&>(version_1_2));
|
|
REQUIRE(VERSION_1_2 == static_cast<const std::string&>(version_1_2_it));
|
|
REQUIRE(VERSION_1_2_SNAPSHOT == static_cast<const std::string&>(version_1_2_snapshot));
|
|
REQUIRE(VERSION_1_2_SNAPSHOT == static_cast<const std::string&>(version_1_2_snapshot_it));
|
|
REQUIRE(VERSION_1_2_BETA == static_cast<const std::string&>(version_1_2_beta));
|
|
REQUIRE(VERSION_1_2_BETA2 == static_cast<const std::string&>(version_1_2_beta2));
|
|
REQUIRE("v2.0" == static_cast<const std::string&>(version_v2_0));
|
|
REQUIRE(VERSION_2_0_SNAPSHOT == static_cast<const std::string&>(version_2_0_snapshot));
|
|
REQUIRE_FALSE(VERSION_1_0 == static_cast<const std::string&>(version_v1_0));
|
|
REQUIRE_FALSE(VERSION_1_0 == static_cast<const std::string&>(version_1));
|
|
REQUIRE_FALSE(VERSION_1_0 == static_cast<const std::string&>(version_1_2));
|
|
REQUIRE_FALSE("2.0" == static_cast<const std::string&>(version_v2_0));
|
|
REQUIRE("v2.0" == version_v2_0.String());
|
|
}
|
|
|
|
TEST_CASE("testTags", "[Version]")
|
|
{
|
|
const Version taged("v1.2.3-ALPHA-B99");
|
|
REQUIRE(taged.Build() == 99);
|
|
REQUIRE(taged.GetTags().size() == 2);
|
|
REQUIRE(taged.GetTags()[0] == "ALPHA");
|
|
REQUIRE(taged.GetTags()[1] == "B99");
|
|
REQUIRE(Version("1.90").GetTags().empty());
|
|
}
|
|
|
|
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"));
|
|
}
|
|
|
|
TEST_CASE("testCopyConstructorAndAssignment", "[Version]")
|
|
{
|
|
Version original("1.5.3");
|
|
Version copyConstructed(original);
|
|
REQUIRE(copyConstructed == original);
|
|
REQUIRE(static_cast<const std::string&>(copyConstructed) == static_cast<const std::string&>(original));
|
|
|
|
Version copyAssigned("2.0");
|
|
copyAssigned = original;
|
|
REQUIRE(copyAssigned == original);
|
|
REQUIRE(static_cast<const std::string&>(copyAssigned) == static_cast<const std::string&>(original));
|
|
|
|
Version extended("1.2.3-ALPHA-B99-T11");
|
|
Version cpConstructedExtended(extended);
|
|
REQUIRE(cpConstructedExtended.Timestamp() == 11);
|
|
REQUIRE(cpConstructedExtended == extended);
|
|
|
|
Version extended3 = extended;
|
|
REQUIRE(extended3.Timestamp() == 11);
|
|
REQUIRE(extended3 == extended);
|
|
}
|
|
|
|
TEST_CASE("testMoveConstructorAndAssignment", "[Version]")
|
|
{
|
|
Version original("3.1.4");
|
|
Version movedConstructed(std::move(original));
|
|
REQUIRE(static_cast<const std::string&>(movedConstructed) == "3.1.4");
|
|
|
|
Version another("0.9.9");
|
|
another = std::move(movedConstructed);
|
|
REQUIRE(static_cast<const std::string&>(another) == "3.1.4");
|
|
|
|
Version extended("1.2.3-ALPHA-B99-T11");
|
|
Version mvConstructedExtended(std::move(extended));
|
|
REQUIRE(mvConstructedExtended.Timestamp() == 11);
|
|
REQUIRE(mvConstructedExtended != extended);
|
|
|
|
Version extended3 = std::move(mvConstructedExtended);
|
|
REQUIRE(extended3.Timestamp() == 11);
|
|
REQUIRE(extended3 != extended);
|
|
REQUIRE(extended3 != mvConstructedExtended);
|
|
}
|
|
|
|
TEST_CASE("testLiterals", "[Version]")
|
|
{
|
|
REQUIRE(version_1 == 1_v);
|
|
REQUIRE(version_1 == 1.0_v);
|
|
REQUIRE(version_1_2 == 1.2_v);
|
|
REQUIRE(version_1_2 == 1.2_version);
|
|
REQUIRE(Version(1, 2, 3) == "1.2.3"_version);
|
|
} |