Add tests for list() invalid arguments

Add tests for error reporting when list() arguments are invalid.
This commit is contained in:
Petr Kmoch 2012-09-29 14:41:07 +02:00 committed by Rolf Eike Beer
parent f560977540
commit 1b078c304d
10 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,2 @@
set(mylist alpha bravo charlie)
list(GET mylist 3 result)

View File

@ -0,0 +1,2 @@
set(mylist alpha bravo charlie)
list(INSERT mylist 3 delta)

View File

@ -0,0 +1 @@
list(NO_SUCH_SUBCOMMAND)

View File

@ -0,0 +1,2 @@
set(mylist alpha bravo charlie)
list(REMOVE_AT mylist 3)

View File

@ -0,0 +1,2 @@
unset(nosuchlist)
list(REMOVE_AT nosuchlist 0)

View File

@ -0,0 +1,2 @@
unset(nosuchlist)
list(REMOVE_DUPLICATES nosuchlist)

View File

@ -0,0 +1,2 @@
unset(nosuchlist)
list(REMOVE_ITEM nosuchlist alpha)

View File

@ -0,0 +1,2 @@
unset(nosuchlist)
list(REVERSE nosuchlist)

View File

@ -0,0 +1,2 @@
unset(nosuchlist)
list(SORT nosuchlist)

View File

@ -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
)