summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeTests/VersionTest.cmake.in
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2014-10-26 16:54:26 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2014-10-29 20:28:33 (GMT)
commit667560c88a707ca7eeaad129e253cce371beed1d (patch)
treecdd91ccce828ad9deacc1ce16e8038b241f4cd26 /Tests/CMakeTests/VersionTest.cmake.in
parent3942cf68b2e3b808b87c0127b1aa7bf52c59696c (diff)
downloadCMake-667560c88a707ca7eeaad129e253cce371beed1d.zip
CMake-667560c88a707ca7eeaad129e253cce371beed1d.tar.gz
CMake-667560c88a707ca7eeaad129e253cce371beed1d.tar.bz2
extend the testing for version comparison
This now checks also the negative outcome of the comparision operation, and adds a bunch more different cases.
Diffstat (limited to 'Tests/CMakeTests/VersionTest.cmake.in')
-rw-r--r--Tests/CMakeTests/VersionTest.cmake.in86
1 files changed, 80 insertions, 6 deletions
diff --git a/Tests/CMakeTests/VersionTest.cmake.in b/Tests/CMakeTests/VersionTest.cmake.in
index 9e31cb4..bd54de5 100644
--- a/Tests/CMakeTests/VersionTest.cmake.in
+++ b/Tests/CMakeTests/VersionTest.cmake.in
@@ -8,9 +8,83 @@ else()
message("CMAKE_VERSION=[${CMAKE_VERSION}] is not less than [${min_ver}]")
endif()
-set(v 1.2.3.4.5.6.7)
-if("${v}.8" VERSION_LESS "${v}.9")
- message(STATUS "${v}.8 is less than ${v}.9")
-else()
- message(FATAL_ERROR "${v}.8 is not less than ${v}.9?")
-endif()
+set(EQUALV "1 1")
+list(APPEND EQUALV "1.0 1")
+list(APPEND EQUALV "1.2.3.4.5.6.7 1.2.3.4.5.6.7")
+
+foreach(v IN LISTS EQUALV)
+ string(REGEX MATCH "(.*) (.*)" _dummy "${v}")
+ # modify any of the operands to see the negative check also works
+ if("${CMAKE_MATCH_1}.2" VERSION_EQUAL CMAKE_MATCH_2)
+ message(FATAL_ERROR "${CMAKE_MATCH_1}.2 is equal ${CMAKE_MATCH_2}?")
+ else()
+ message(STATUS "${CMAKE_MATCH_1}.2 is not equal ${CMAKE_MATCH_2}")
+ endif()
+
+ if(CMAKE_MATCH_1 VERSION_EQUAL "${CMAKE_MATCH_2}.2")
+ message(FATAL_ERROR "${CMAKE_MATCH_1} is equal ${CMAKE_MATCH_2}.2?")
+ else()
+ message(STATUS "${CMAKE_MATCH_1} is not equal ${CMAKE_MATCH_2}.2")
+ endif()
+endforeach()
+
+# test the negative outcomes first, due to the implementation the positive
+# allow some additional strings to pass that would not fail for the negative
+# tests
+
+list(APPEND EQUALV "1a 1")
+list(APPEND EQUALV "1.1a 1.1")
+list(APPEND EQUALV "1.0a 1")
+list(APPEND EQUALV "1a 1.0")
+
+foreach(v IN LISTS EQUALV)
+ # check equal versions
+ string(REGEX MATCH "(.*) (.*)" _dummy "${v}")
+ if(CMAKE_MATCH_1 VERSION_EQUAL CMAKE_MATCH_2)
+ message(STATUS "${CMAKE_MATCH_1} is equal ${CMAKE_MATCH_2}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_1} is not equal ${CMAKE_MATCH_2}?")
+ endif()
+
+ # still equal, but inverted order of operands
+ string(REGEX MATCH "(.*) (.*)" _dummy "${v}")
+ if(CMAKE_MATCH_2 VERSION_EQUAL CMAKE_MATCH_1)
+ message(STATUS "${CMAKE_MATCH_2} is equal ${CMAKE_MATCH_1}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_2} is not equal ${CMAKE_MATCH_1}?")
+ endif()
+endforeach()
+
+set(LESSV "1.2.3.4.5.6.7.8 1.2.3.4.5.6.7.9")
+list(APPEND LESSV "1.2.3.4.5.6.7 1.2.3.4.5.6.7.9")
+list(APPEND LESSV "1 1.0.0.1")
+foreach(v IN LISTS LESSV)
+ string(REGEX MATCH "(.*) (.*)" _dummy "${v}")
+ # check less
+ if(CMAKE_MATCH_1 VERSION_LESS CMAKE_MATCH_2)
+ message(STATUS "${CMAKE_MATCH_1} is less than ${CMAKE_MATCH_2}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_1} is not less than ${CMAKE_MATCH_2}?")
+ endif()
+
+ # check greater
+ if(CMAKE_MATCH_2 VERSION_GREATER CMAKE_MATCH_1)
+ message(STATUS "${CMAKE_MATCH_2} is greater than ${CMAKE_MATCH_1}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_2} is not greater than ${CMAKE_MATCH_1}?")
+ endif()
+
+ # check less negative case
+ if(NOT CMAKE_MATCH_2 VERSION_LESS CMAKE_MATCH_1)
+ message(STATUS "${CMAKE_MATCH_2} is not less than ${CMAKE_MATCH_1}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_2} is less than ${CMAKE_MATCH_1}?")
+ endif()
+
+ # check greater negative case
+ if(NOT CMAKE_MATCH_1 VERSION_GREATER CMAKE_MATCH_2)
+ message(STATUS "${CMAKE_MATCH_1} is not greater than ${CMAKE_MATCH_2}")
+ else()
+ message(FATAL_ERROR "${CMAKE_MATCH_1} is greater than ${CMAKE_MATCH_2}?")
+ endif()
+endforeach()