summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorPetr Kmoch <petr.kmoch@gmail.com>2012-09-29 14:41:07 +0200
committerRolf Eike Beer <eike@sf-mail.de>2012-11-02 17:08:49 +0100
commit1b078c304db63eb6cd46fe0f22988f8241a389b2 (patch)
treea6624366c4238f48a558bbc41e2baf8dc11e92f5 /Tests
parentf560977540215e533c5360e1ab84dd0846d18310 (diff)
downloadcmake-1b078c304db63eb6cd46fe0f22988f8241a389b2.tar.gz
Add tests for list() invalid arguments
Add tests for error reporting when list() arguments are invalid.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeTests/List-Get-Invalid-Index.cmake2
-rw-r--r--Tests/CMakeTests/List-Insert-Invalid-Index.cmake2
-rw-r--r--Tests/CMakeTests/List-Invalid-Subcommand.cmake1
-rw-r--r--Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake2
-rw-r--r--Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake2
-rw-r--r--Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake2
-rw-r--r--Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake2
-rw-r--r--Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake2
-rw-r--r--Tests/CMakeTests/List-Sort-Nonexistent-List.cmake2
-rw-r--r--Tests/CMakeTests/ListTest.cmake.in22
10 files changed, 39 insertions, 0 deletions
diff --git a/Tests/CMakeTests/List-Get-Invalid-Index.cmake b/Tests/CMakeTests/List-Get-Invalid-Index.cmake
new file mode 100644
index 0000000000..178295a209
--- /dev/null
+++ b/Tests/CMakeTests/List-Get-Invalid-Index.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(GET mylist 3 result)
diff --git a/Tests/CMakeTests/List-Insert-Invalid-Index.cmake b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake
new file mode 100644
index 0000000000..4103d974b4
--- /dev/null
+++ b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(INSERT mylist 3 delta)
diff --git a/Tests/CMakeTests/List-Invalid-Subcommand.cmake b/Tests/CMakeTests/List-Invalid-Subcommand.cmake
new file mode 100644
index 0000000000..40f2345953
--- /dev/null
+++ b/Tests/CMakeTests/List-Invalid-Subcommand.cmake
@@ -0,0 +1 @@
+list(NO_SUCH_SUBCOMMAND)
diff --git a/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake
new file mode 100644
index 0000000000..d4f3921263
--- /dev/null
+++ b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(REMOVE_AT mylist 3)
diff --git a/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake
new file mode 100644
index 0000000000..5266c7fe99
--- /dev/null
+++ b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(REMOVE_AT nosuchlist 0)
diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake
new file mode 100644
index 0000000000..218f2272cd
--- /dev/null
+++ b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(REMOVE_DUPLICATES nosuchlist)
diff --git a/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake
new file mode 100644
index 0000000000..079e7fbce2
--- /dev/null
+++ b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(REMOVE_ITEM nosuchlist alpha)
diff --git a/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake
new file mode 100644
index 0000000000..977e2ccac1
--- /dev/null
+++ b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(REVERSE nosuchlist)
diff --git a/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake
new file mode 100644
index 0000000000..8f48e10432
--- /dev/null
+++ b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(SORT nosuchlist)
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in
index 27858c0fef..b11a295530 100644
--- a/Tests/CMakeTests/ListTest.cmake.in
+++ b/Tests/CMakeTests/ListTest.cmake.in
@@ -133,6 +133,19 @@ set(Remove_Duplicates-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURREN
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.*")
+set(Invalid-Subcommand-RESULT 1)
+set(Invalid-Subcommand-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Invalid-Subcommand.cmake:1 \\(list\\):.*list does not recognize sub-command NO_SUCH_SUBCOMMAND.*")
+
+foreach(cmd Get Insert Remove_At)
+ set(${cmd}-Invalid-Index-RESULT 1)
+ set(${cmd}-Invalid-Index-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Invalid-Index.cmake:2 \\(list\\):.*list index: 3 out of range \\(-3, 2\\).*")
+endforeach()
+
+foreach(cmd Remove_Item Reverse Remove_Duplicates Sort Remove_At)
+ string(TOUPPER ${cmd} Cmd)
+ set(${cmd}-Nonexistent-List-RESULT 1)
+ set(${cmd}-Nonexistent-List-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Nonexistent-List.cmake:2 \\(list\\):.*sub-command ${Cmd} requires list to be present.*")
+endforeach()
check_cmake_test(List
No-Arguments
@@ -140,4 +153,13 @@ check_cmake_test(List
Reverse-Too-Many-Arguments
Remove_Duplicates-Too-Many-Arguments
Sort-Too-Many-Arguments
+ Invalid-Subcommand
+ Get-Invalid-Index
+ Insert-Invalid-Index
+ Remove_Item-Nonexistent-List
+ Reverse-Nonexistent-List
+ Remove_Duplicates-Nonexistent-List
+ Sort-Nonexistent-List
+ Remove_At-Nonexistent-List
+ Remove_At-Invalid-Index
)