109 lines
4.0 KiB
CMake
109 lines
4.0 KiB
CMake
|
|
cmake_minimum_required(VERSION 3.23)
|
||
|
|
project(cmake-version)
|
||
|
|
|
||
|
|
include("helpers.cmake")
|
||
|
|
|
||
|
|
# ToDo: Add even more test cases, as we don't want a burning bar because someone asked where the toilet is.
|
||
|
|
|
||
|
|
# Generation
|
||
|
|
message(STATUS "\n\n===== Generation =====")
|
||
|
|
# - Valid Cases
|
||
|
|
test_generate("0.0")
|
||
|
|
test_generate("1.0" MAJOR 1)
|
||
|
|
test_generate("0.2" MINOR 2)
|
||
|
|
test_generate("0.0.3" PATCH 3)
|
||
|
|
test_generate("0.0.0.4" TWEAK 4)
|
||
|
|
test_generate("0.0-5" COMPRESS PRERELEASE 5)
|
||
|
|
test_generate("0.0a5" COMPRESS PRERELEASE a5)
|
||
|
|
test_generate("0.0+6" BUILD 6)
|
||
|
|
# - Invalid Cases
|
||
|
|
test_generate("-1.0.0" FAIL MAJOR "-1")
|
||
|
|
test_generate("0.-1.0" FAIL MINOR "-1")
|
||
|
|
test_generate("0.0.-1" FAIL PATCH "-1")
|
||
|
|
test_generate("0.0.0.-1" FAIL TWEAK "-1")
|
||
|
|
test_generate("0.0.0-#" FAIL PRERELEASE "#")
|
||
|
|
test_generate("0.0.0-0 0" FAIL PRERELEASE "0 0")
|
||
|
|
test_generate("0.0.0+#" FAIL BUILD "#")
|
||
|
|
test_generate("0.0.0+0 0" FAIL BUILD "0 0")
|
||
|
|
|
||
|
|
# Parsing
|
||
|
|
message(STATUS "\n\n===== Parsing =====")
|
||
|
|
# - Valid Cases
|
||
|
|
test_parse("1.2" MAJOR 1 MINOR 2)
|
||
|
|
test_parse("1.2.3" MAJOR 1 MINOR 2 PATCH 3)
|
||
|
|
test_parse("1.2.3.4" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4)
|
||
|
|
test_parse("1.2-5" MAJOR 1 MINOR 2 PRERELEASE 5)
|
||
|
|
test_parse("1.2.3-5" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE 5)
|
||
|
|
test_parse("1.2.3.4-5" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE 5)
|
||
|
|
test_parse("1.2a5" MAJOR 1 MINOR 2 PRERELEASE a5)
|
||
|
|
test_parse("1.2.3a5" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE a5)
|
||
|
|
test_parse("1.2.3.4a5" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE a5)
|
||
|
|
test_parse("1.2+6" MAJOR 1 MINOR 2 BUILD 6)
|
||
|
|
test_parse("1.2.3+6" MAJOR 1 MINOR 2 PATCH 3 BUILD 6)
|
||
|
|
test_parse("1.2.3.4+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 BUILD 6)
|
||
|
|
test_parse("1.2-5+6" MAJOR 1 MINOR 2 PRERELEASE 5 BUILD 6)
|
||
|
|
test_parse("1.2.3-5+6" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE 5 BUILD 6)
|
||
|
|
test_parse("1.2.3.4-5+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE 5 BUILD 6)
|
||
|
|
test_parse("1.2a5+6" MAJOR 1 MINOR 2 PRERELEASE a5 BUILD 6)
|
||
|
|
test_parse("1.2.3a5+6" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE a5 BUILD 6)
|
||
|
|
test_parse("1.2.3.4a5+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE a5 BUILD 6)
|
||
|
|
# - Invalid Cases
|
||
|
|
test_parse("" FAIL)
|
||
|
|
test_parse("cmake" FAIL)
|
||
|
|
test_parse("0" FAIL)
|
||
|
|
test_parse("-1.0.0" FAIL)
|
||
|
|
test_parse("11.bad.0" FAIL)
|
||
|
|
test_parse("0.0.0+.0" FAIL)
|
||
|
|
|
||
|
|
# Modifying
|
||
|
|
message(STATUS "\n\n===== Modifying =====")
|
||
|
|
# - Valid Cases
|
||
|
|
test_modify("1.0" "0.0" MAJOR 1)
|
||
|
|
test_modify("1.0" "0.0" MAJOR "+1")
|
||
|
|
test_modify("1.0" "2.0" MAJOR "-1")
|
||
|
|
test_modify("0.2" "0.0" MINOR 2)
|
||
|
|
test_modify("0.2" "0.0" MINOR "+2")
|
||
|
|
test_modify("0.2" "0.3" MINOR "-1")
|
||
|
|
test_modify("0.0.3" "0.0" PATCH 3)
|
||
|
|
test_modify("0.0.3" "0.0.2" PATCH "+1")
|
||
|
|
test_modify("0.0.3" "0.0.4" PATCH "-1")
|
||
|
|
test_modify("0.0.0.4" "0.0" TWEAK 4)
|
||
|
|
test_modify("0.0.0.4" "0.0.0.3" TWEAK "+1")
|
||
|
|
test_modify("0.0.0.4" "0.0.0.5" TWEAK "-1")
|
||
|
|
test_modify("0.0-5" "0.0" COMPRESS PRERELEASE 5)
|
||
|
|
test_modify("0.0a5" "0.0" COMPRESS PRERELEASE a5)
|
||
|
|
test_modify("0.0+6" "0.0" COMPRESS BUILD 6)
|
||
|
|
test_modify("0.0-5+6" "0.0" COMPRESS PRERELEASE 5 BUILD 6)
|
||
|
|
test_modify("0.0a5+6" "0.0" COMPRESS PRERELEASE a5 BUILD 6)
|
||
|
|
# - Invalid Cases
|
||
|
|
test_modify("0.0" "0.0" FAIL MAJOR -1)
|
||
|
|
test_modify("0.0" "0.0" FAIL MINOR -1)
|
||
|
|
test_modify("0.0" "0.0" FAIL PATCH -1)
|
||
|
|
test_modify("0.0" "0.0" FAIL TWEAK -1)
|
||
|
|
test_modify("0.0" "0.0" FAIL COMPRESS PRERELEASE "#")
|
||
|
|
test_modify("0.0" "0.0" FAIL COMPRESS BUILD "#")
|
||
|
|
|
||
|
|
# Comparing
|
||
|
|
message(STATUS "\n\n===== Comparing =====")
|
||
|
|
# - Base Components Comparison
|
||
|
|
test_compare("0.0" "" "0.0")
|
||
|
|
test_compare("1.0" ">MAJOR" "0.0")
|
||
|
|
test_compare("0.0" "<MAJOR" "1.0")
|
||
|
|
test_compare("0.2" ">MINOR" "0.0")
|
||
|
|
test_compare("0.0" "<MINOR" "0.2")
|
||
|
|
test_compare("0.0.3" ">PATCH" "0.0.0")
|
||
|
|
test_compare("0.0.0" "<PATCH" "0.0.3")
|
||
|
|
test_compare("0.0.0.4" ">TWEAK" "0.0.0.0")
|
||
|
|
test_compare("0.0.0.0" "<TWEAK" "0.0.0.4")
|
||
|
|
test_compare("0.0-5" "PRERELEASE" "0.0-6")
|
||
|
|
test_compare("0.0+6" "BUILD" "0.0+7")
|
||
|
|
# - Missing Components Tests
|
||
|
|
test_compare("0.0.3" "+PATCH" "0.0")
|
||
|
|
test_compare("0.0" "-PATCH" "0.0.3")
|
||
|
|
test_compare("0.0.0.4" "+TWEAK" "0.0.0")
|
||
|
|
test_compare("0.0.0" "-TWEAK" "0.0.0.4")
|
||
|
|
test_compare("0.0-5" "+PRERELEASE" "0.0")
|
||
|
|
test_compare("0.0" "-PRERELEASE" "0.0-5")
|
||
|
|
test_compare("0.0+6" "+BUILD" "0.0")
|
||
|
|
test_compare("0.0" "-BUILD" "0.0+6")
|