Resurrected an old test case for parsing and comparing config version numbers

This commit is contained in:
Lukas Matena 2022-09-30 13:45:30 +02:00
parent 32e6972eba
commit 49c817c40b
3 changed files with 85 additions and 74 deletions

View File

@ -69,80 +69,7 @@ bool Version::is_current_slic3r_downgrade() const
{
return Slic3r::SEMVER < min_slic3r_version;
}
#if 0
//TODO: This test should be moved to a unit test, once we have C++ unit tests in place.
static int version_test()
{
Version v;
v.config_version = *Semver::parse("1.1.2");
v.min_slic3r_version = *Semver::parse("1.38.0");
v.max_slic3r_version = Semver::inf();
assert(v.is_slic3r_supported(*Semver::parse("1.38.0")));
assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha")));
assert(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha")));
// Test the prerelease status.
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-alpha");
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-alpha1");
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-beta");
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-rc");
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-rc2");
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
assert(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
assert(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
// Test the upper boundary.
v.config_version = *Semver::parse("1.1.2");
v.max_slic3r_version = *Semver::parse("1.39.3-beta1");
assert(v.is_slic3r_supported(*Semver::parse("1.38.0")));
assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha")));
assert(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha1")));
assert(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha")));
return 0;
}
static int version_test_run = version_test();
#endif
inline char* left_trim(char *c)
{

View File

@ -2,6 +2,7 @@ get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
add_executable(${_TEST_NAME}_tests
${_TEST_NAME}_tests_main.cpp
slic3r_jobs_tests.cpp
slic3r_version_tests.cpp
)
# mold linker for successful linking needs also to link TBB library and link it before libslic3r.

View File

@ -0,0 +1,83 @@
#include "catch2/catch.hpp"
#include "slic3r/Config/Version.hpp"
TEST_CASE("Check parsing and comparing of config versions", "[Version]") {
using namespace Slic3r;
GUI::Config::Version v;
v.config_version = *Semver::parse("1.1.2");
v.min_slic3r_version = *Semver::parse("1.38.0");
v.max_slic3r_version = Semver::inf();
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.38.0")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha")));
// Test the prerelease status.
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-alpha");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-alpha1");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-beta");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-rc");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
v.config_version = *Semver::parse("1.1.2-rc2");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-alpha1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-beta1")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-rc")));
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.39.0-rc2")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.39.0")));
// Test the upper boundary.
v.config_version = *Semver::parse("1.1.2");
v.max_slic3r_version = *Semver::parse("1.39.3-beta1");
REQUIRE(v.is_slic3r_supported(*Semver::parse("1.38.0")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.38.0-alpha1")));
REQUIRE(! v.is_slic3r_supported(*Semver::parse("1.37.0-alpha")));
}