summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake14
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/CornerCasesArgvN.cmake53
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/Utils.cmake1
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/test_utils.cmake44
5 files changed, 84 insertions, 29 deletions
diff --git a/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake b/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
index 63a1b01..96a373d 100644
--- a/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
@@ -1,15 +1,5 @@
include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake)
-function(test_multi list)
- set(i 0)
- foreach(value IN LISTS ${list})
- math(EXPR j "${i} + 1")
- set(${list}[${i}] "${value}")
- TEST(${list}[${i}] "${ARGV${j}}")
- set(i ${j})
- endforeach()
-endfunction()
-
function(test1)
cmake_parse_arguments(PARSE_ARGV 0
pref "OPT1;OPT2" "SINGLE1;SINGLE2" "MULTI1;MULTI2")
@@ -33,7 +23,7 @@ function(test2 arg1)
TEST(pref_OPT2 FALSE)
TEST(pref_SINGLE1 "foo;bar")
TEST(pref_SINGLE2 UNDEFINED)
- test_multi(pref_MULTI1 bar "foo;bar")
+ TEST(pref_MULTI1 bar "foo;bar")
TEST(pref_MULTI2 UNDEFINED)
TEST(pref_UNPARSED_ARGUMENTS UNDEFINED)
endfunction()
@@ -43,6 +33,6 @@ function(test3 arg1)
cmake_parse_arguments(PARSE_ARGV 0
pref "" "" "")
- test_multi(pref_UNPARSED_ARGUMENTS "foo;bar" dog cat)
+ TEST(pref_UNPARSED_ARGUMENTS "foo;bar" dog cat)
endfunction()
test3("foo;bar" dog cat)
diff --git a/Tests/RunCMake/cmake_parse_arguments/CornerCasesArgvN.cmake b/Tests/RunCMake/cmake_parse_arguments/CornerCasesArgvN.cmake
new file mode 100644
index 0000000..807ed03
--- /dev/null
+++ b/Tests/RunCMake/cmake_parse_arguments/CornerCasesArgvN.cmake
@@ -0,0 +1,53 @@
+include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake)
+
+function(test1)
+ cmake_parse_arguments(PARSE_ARGV 0
+ mpref "" "" "MULTI")
+
+ TEST(mpref_MULTI foo "foo\;bar")
+
+ cmake_parse_arguments(PARSE_ARGV 1
+ upref "" "" "MULTI")
+
+ TEST(upref_UNPARSED_ARGUMENTS foo "foo\;bar")
+endfunction()
+test1(MULTI foo "foo\;bar")
+
+function(test2)
+ cmake_parse_arguments(PARSE_ARGV 0
+ mpref "" "" "MULTI")
+
+ TEST(mpref_MULTI "foo;" "bar;")
+
+ cmake_parse_arguments(PARSE_ARGV 1
+ upref "" "" "MULTI")
+
+ TEST(upref_UNPARSED_ARGUMENTS "foo;" "bar;")
+endfunction()
+test2(MULTI "foo;" "bar;")
+
+function(test3)
+ cmake_parse_arguments(PARSE_ARGV 0
+ mpref "" "" "MULTI")
+
+ TEST(mpref_MULTI "[foo;]" "bar\\")
+
+ cmake_parse_arguments(PARSE_ARGV 1
+ upref "" "" "MULTI")
+
+ TEST(upref_UNPARSED_ARGUMENTS "[foo;]" "bar\\")
+endfunction()
+test3(MULTI "[foo;]" "bar\\")
+
+function(test4)
+ cmake_parse_arguments(PARSE_ARGV 0
+ mpref "" "" "MULTI")
+
+ TEST(mpref_MULTI foo "bar;none")
+
+ cmake_parse_arguments(PARSE_ARGV 1
+ upref "" "" "MULTI")
+
+ TEST(upref_UNPARSED_ARGUMENTS foo "bar;none")
+endfunction()
+test4(MULTI foo bar\\ none)
diff --git a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
index 22d7ee4..1e15b3b 100644
--- a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
@@ -10,3 +10,4 @@ run_cmake(BadArgvN1)
run_cmake(BadArgvN2)
run_cmake(BadArgvN3)
run_cmake(BadArgvN4)
+run_cmake(CornerCasesArgvN)
diff --git a/Tests/RunCMake/cmake_parse_arguments/Utils.cmake b/Tests/RunCMake/cmake_parse_arguments/Utils.cmake
index 3bbf115..f2001f2 100644
--- a/Tests/RunCMake/cmake_parse_arguments/Utils.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/Utils.cmake
@@ -17,4 +17,5 @@ SET (asdf "some value")
TEST(asdf "some value")
SET (asdf some list)
+TEST(asdf some list)
TEST(asdf "some;list")
diff --git a/Tests/RunCMake/cmake_parse_arguments/test_utils.cmake b/Tests/RunCMake/cmake_parse_arguments/test_utils.cmake
index f5425c2..9ce99b8 100644
--- a/Tests/RunCMake/cmake_parse_arguments/test_utils.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/test_utils.cmake
@@ -1,20 +1,30 @@
-macro(TEST variable)
- SET(expected "${ARGN}")
- if ( "${expected}" STREQUAL "UNDEFINED" )
- if (DEFINED ${variable})
- message(FATAL_ERROR "'${variable}' shall be undefined but has value '${${variable}}'")
- endif()
- elseif( "${expected}" STREQUAL "FALSE" )
- if (NOT ${variable} STREQUAL "FALSE")
- message(FATAL_ERROR "'${variable}' shall be FALSE")
- endif()
- elseif( "${expected}" STREQUAL "TRUE" )
- if (NOT ${variable} STREQUAL "TRUE")
- message(FATAL_ERROR "'${variable}' shall be TRUE")
- endif()
+function(TEST variable)
+ if(ARGC GREATER 2)
+ set(i 0)
+ foreach(value IN LISTS ${variable})
+ math(EXPR j "${i} + 1")
+ set(${variable}[${i}] "${value}")
+ TEST(${variable}[${i}] "${ARGV${j}}")
+ set(i ${j})
+ endforeach()
else()
- if (NOT ${variable} STREQUAL "${expected}")
- message(FATAL_ERROR "'${variable}' shall be '${expected}'")
+ set(expected "${ARGN}")
+ if("${expected}" STREQUAL "UNDEFINED")
+ if(DEFINED ${variable})
+ message(FATAL_ERROR "'${variable}' shall be undefined but has value '${${variable}}'")
+ endif()
+ elseif("${expected}" STREQUAL "FALSE")
+ if(NOT ${variable} STREQUAL "FALSE")
+ message(FATAL_ERROR "'${variable}' shall be FALSE")
+ endif()
+ elseif("${expected}" STREQUAL "TRUE")
+ if(NOT ${variable} STREQUAL "TRUE")
+ message(FATAL_ERROR "'${variable}' shall be TRUE")
+ endif()
+ else()
+ if(NOT ${variable} STREQUAL "${expected}")
+ message(FATAL_ERROR "'${variable}' shall be '${expected}'")
+ endif()
endif()
endif()
-endmacro()
+endfunction()