summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorPetr Kmoch <petr.kmoch@gmail.com>2012-09-29 11:02:38 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2012-11-02 16:08:44 (GMT)
commitf560977540215e533c5360e1ab84dd0846d18310 (patch)
tree94e2371fff0e5093fe8f5e844af4e27039a6d535 /Tests
parentd211e5d20324783b7c5eb06725dda08c12c41787 (diff)
downloadCMake-f560977540215e533c5360e1ab84dd0846d18310.zip
CMake-f560977540215e533c5360e1ab84dd0846d18310.tar.gz
CMake-f560977540215e533c5360e1ab84dd0846d18310.tar.bz2
Add tests for list() argument count
Add test for error reporting when list() subcommands have wrong number of arguments.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake1
-rw-r--r--Tests/CMakeTests/List-No-Arguments.cmake1
-rw-r--r--Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake1
-rw-r--r--Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake1
-rw-r--r--Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake1
-rw-r--r--Tests/CMakeTests/ListTest.cmake.in44
6 files changed, 49 insertions, 0 deletions
diff --git a/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake
new file mode 100644
index 0000000..327db6a
--- /dev/null
+++ b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake
@@ -0,0 +1 @@
+list(LENGTH mylist result one_too_many)
diff --git a/Tests/CMakeTests/List-No-Arguments.cmake b/Tests/CMakeTests/List-No-Arguments.cmake
new file mode 100644
index 0000000..7916aaa
--- /dev/null
+++ b/Tests/CMakeTests/List-No-Arguments.cmake
@@ -0,0 +1 @@
+list()
diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake
new file mode 100644
index 0000000..b5eb46e
--- /dev/null
+++ b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake
@@ -0,0 +1 @@
+list(REMOVE_DUPLICATES mylist one_too_many)
diff --git a/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake
new file mode 100644
index 0000000..3a554a0
--- /dev/null
+++ b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake
@@ -0,0 +1 @@
+list(REVERSE mylist one_too_many)
diff --git a/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake
new file mode 100644
index 0000000..81b195d
--- /dev/null
+++ b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake
@@ -0,0 +1 @@
+list(SORT mylist one_too_many)
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in
index a167503..27858c0 100644
--- a/Tests/CMakeTests/ListTest.cmake.in
+++ b/Tests/CMakeTests/ListTest.cmake.in
@@ -1,3 +1,5 @@
+include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
+
macro(TEST command expected)
if("x${result}" STREQUAL "x${expected}")
#message("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"")
@@ -97,3 +99,45 @@ TEST("REVERSE empty result" "")
list(SORT result)
TEST("SORT empty result" "")
+
+set(No-Arguments-RESULT 1)
+set(No-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least one argument.*")
+
+set(Get-No-Arguments-STDERR ".*CMake Error at List-Get-No-Arguments.cmake:1 \\(list\\):.*list sub-command GET requires at least three arguments.*")
+set(Append-No-Arguments-STDERR ".*CMake Error at List-Append-No-Arguments.cmake:1 \\(list\\):.*list sub-command APPEND requires at least one argument.*")
+set(Find-No-Arguments-STDERR ".*CMake Error at List-Find-No-Arguments.cmake:1 \\(list\\):.*list sub-command FIND requires three arguments.*")
+set(Insert-No-Arguments-STDERR ".*CMake Error at List-Insert-No-Arguments.cmake:1 \\(list\\):.*list sub-command INSERT requires at least three arguments.*")
+set(Remove_Item-No-Arguments-STDERR ".*CMake Error at List-Remove_Item-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_ITEM requires two or more arguments.*")
+set(Reverse-No-Arguments-STDERR ".*CMake Error at List-Reverse-No-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE requires a list as an argument.*")
+set(Remove_Duplicates-No-Arguments-STDERR ".*CMake Error at List-Remove_Duplicates-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES requires a list as an argument.*")
+set(Sort-No-Arguments-STDERR ".*CMake Error at List-Sort-No-Arguments.cmake:1 \\(list\\):.*list sub-command SORT requires a list as an argument.*")
+set(Remove_At-No-Arguments-STDERR ".*CMake Error at List-Remove_At-No-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_AT requires at least two arguments.*")
+
+foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort)
+ set(${cmd}-No-Arguments-RESULT 1)
+ string(TOUPPER ${cmd} cmd_upper)
+ set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-No-Arguments.cmake")
+ file(WRITE "${_test_file_name}" "list(${cmd_upper})\n")
+ check_cmake_test_single(List "${cmd}-No-Arguments" "${_test_file_name}")
+endforeach()
+
+set(Length-Too-Many-Arguments-RESULT 1)
+set(Length-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Length-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command LENGTH requires two arguments.*")
+
+set(Reverse-Too-Many-Arguments-RESULT 1)
+set(Reverse-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Reverse-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE only takes one argument.*")
+
+set(Remove_Duplicates-Too-Many-Arguments-RESULT 1)
+set(Remove_Duplicates-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Remove_Duplicates-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES only takes one argument.*")
+
+set(Sort-Too-Many-Arguments-RESULT 1)
+set(Sort-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Sort-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command SORT only takes one argument.*")
+
+
+check_cmake_test(List
+ No-Arguments
+ Length-Too-Many-Arguments
+ Reverse-Too-Many-Arguments
+ Remove_Duplicates-Too-Many-Arguments
+ Sort-Too-Many-Arguments
+)