Add tests for list() invalid arguments
Add tests for error reporting when list() arguments are invalid.
This commit is contained in:
parent
f560977540
commit
1b078c304d
|
@ -0,0 +1,2 @@
|
|||
set(mylist alpha bravo charlie)
|
||||
list(GET mylist 3 result)
|
|
@ -0,0 +1,2 @@
|
|||
set(mylist alpha bravo charlie)
|
||||
list(INSERT mylist 3 delta)
|
|
@ -0,0 +1 @@
|
|||
list(NO_SUCH_SUBCOMMAND)
|
|
@ -0,0 +1,2 @@
|
|||
set(mylist alpha bravo charlie)
|
||||
list(REMOVE_AT mylist 3)
|
|
@ -0,0 +1,2 @@
|
|||
unset(nosuchlist)
|
||||
list(REMOVE_AT nosuchlist 0)
|
|
@ -0,0 +1,2 @@
|
|||
unset(nosuchlist)
|
||||
list(REMOVE_DUPLICATES nosuchlist)
|
|
@ -0,0 +1,2 @@
|
|||
unset(nosuchlist)
|
||||
list(REMOVE_ITEM nosuchlist alpha)
|
|
@ -0,0 +1,2 @@
|
|||
unset(nosuchlist)
|
||||
list(REVERSE nosuchlist)
|
|
@ -0,0 +1,2 @@
|
|||
unset(nosuchlist)
|
||||
list(SORT nosuchlist)
|
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue