Mercurial > hg > orthanc
diff OrthancFramework/UnitTestsSources/FrameworkTests.cpp @ 5575:d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2024 17:17:34 +0200 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
line wrap: on
line diff
--- a/OrthancFramework/UnitTestsSources/FrameworkTests.cpp Fri Apr 26 16:01:26 2024 +0200 +++ b/OrthancFramework/UnitTestsSources/FrameworkTests.cpp Fri Apr 26 17:17:34 2024 +0200 @@ -1602,3 +1602,53 @@ } } #endif + + +TEST(Toolbox, IsVersionAbove) +{ + unsigned int a, b, c; + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "nope")); + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "mainline")); + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "")); + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "-1")); + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "1.-1")); + ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "1.1.-1")); + + ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "14.17.20")); + ASSERT_EQ(14u, a); + ASSERT_EQ(17u, b); + ASSERT_EQ(20u, c); + + ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "18.19")); + ASSERT_EQ(18u, a); + ASSERT_EQ(19u, b); + ASSERT_EQ(0u, c); + + ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "78")); + ASSERT_EQ(78u, a); + ASSERT_EQ(0u, b); + ASSERT_EQ(0u, c); + + ASSERT_TRUE(Toolbox::IsVersionAbove("mainline", 99, 99, 99)); + + ASSERT_TRUE(Toolbox::IsVersionAbove("18", 17, 99, 99)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18", 18, 0, 0)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18", 18, 0, 1)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18", 18, 1, 0)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18", 19, 0, 0)); + + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 17, 99, 99)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 18, 18, 99)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 18, 19, 0)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 18, 19, 1)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 18, 20, 0)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 19, 0, 0)); + + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 17, 99, 99)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 18, 99)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 19)); + ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 20)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 21)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 18, 20, 0)); + ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 19, 0, 0)); +}