diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-03-16 13:12:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-21 16:54:53 (GMT) |
commit | 768225837db303e8b568e39ade730eea8ac6b573 (patch) | |
tree | 8438f1112f7eae9ee54afbbdd958af55f57e94c2 /Tests/RunCMake/list | |
parent | d41abae70f282c718f3109b7f76644adce41ff37 (diff) | |
download | CMake-768225837db303e8b568e39ade730eea8ac6b573.zip CMake-768225837db303e8b568e39ade730eea8ac6b573.tar.gz CMake-768225837db303e8b568e39ade730eea8ac6b573.tar.bz2 |
list: Add SUBLIST sub-command
Issue: #17823
Diffstat (limited to 'Tests/RunCMake/list')
17 files changed, 86 insertions, 0 deletions
diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index 1be4f85..3913783 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -13,6 +13,7 @@ run_cmake(FILTER-REGEX-InvalidRegex) run_cmake(GET-InvalidIndex) run_cmake(INSERT-InvalidIndex) run_cmake(REMOVE_AT-InvalidIndex) +run_cmake(SUBLIST-InvalidIndex) run_cmake(FILTER-REGEX-TooManyArguments) run_cmake(JOIN-TooManyArguments) @@ -20,6 +21,7 @@ run_cmake(LENGTH-TooManyArguments) run_cmake(REMOVE_DUPLICATES-TooManyArguments) run_cmake(REVERSE-TooManyArguments) run_cmake(SORT-TooManyArguments) +run_cmake(SUBLIST-TooManyArguments) run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) @@ -36,3 +38,8 @@ run_cmake(FILTER-REGEX-Valid1) run_cmake(JOIN-NoArguments) run_cmake(JOIN-NoVariable) run_cmake(JOIN) + +run_cmake(SUBLIST-NoArguments) +run_cmake(SUBLIST-NoVariable) +run_cmake(SUBLIST-InvalidLength) +run_cmake(SUBLIST) diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt new file mode 100644 index 0000000..5e67b27 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-InvalidIndex.cmake:2 \(list\): + list begin index: 3 is out of range 0 - 2 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake new file mode 100644 index 0000000..565b9dc --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 3 -1 result) diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt new file mode 100644 index 0000000..16c6ecb --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-InvalidLength.cmake:2 \(list\): + list length: -2 should be -1 or greater +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake new file mode 100644 index 0000000..1dab83f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 0 -2 result) diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt new file mode 100644 index 0000000..073173c --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-NoArguments.cmake:1 \(list\): + list sub-command SUBLIST requires four arguments \(1 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments.cmake b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake new file mode 100644 index 0000000..df38b87 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake @@ -0,0 +1 @@ +list(SUBLIST mylist) diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt new file mode 100644 index 0000000..6f80c1a --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-NoVariable.cmake:2 \(list\): + list sub-command SUBLIST requires four arguments \(3 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable.cmake b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake new file mode 100644 index 0000000..83edae9 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 0 -1) diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt new file mode 100644 index 0000000..eb46844 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-TooManyArguments.cmake:1 \(list\): + list sub-command SUBLIST requires four arguments \(5 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake new file mode 100644 index 0000000..28f20c1 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake @@ -0,0 +1 @@ +list(SUBLIST mylist 0 -1 result one_too_many) diff --git a/Tests/RunCMake/list/SUBLIST.cmake b/Tests/RunCMake/list/SUBLIST.cmake new file mode 100644 index 0000000..fd15c28 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST.cmake @@ -0,0 +1,46 @@ +set(mylist alpha bravo charlie delta) +list(SUBLIST mylist 1 2 result) + +if (NOT result STREQUAL "bravo;charlie") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie\"") +endif() + + +unset(result) +list(SUBLIST mylist 0 2 result) + +if (NOT result STREQUAL "alpha;bravo") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"alpha;bravo\"") +endif() + + +unset(result) +list(SUBLIST mylist 3 2 result) + +if (NOT result STREQUAL "delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"delta\"") +endif() + + +unset(result) +list(SUBLIST mylist 2 0 result) +list(LENGTH result length) +if (NOT length EQUAL 0) + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is an empty list") +endif() + + +unset(result) +list(SUBLIST mylist 1 5 result) + +if (NOT result STREQUAL "bravo;charlie;delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"") +endif() + + +unset(result) +list(SUBLIST mylist 1 -1 result) + +if (NOT result STREQUAL "bravo;charlie;delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"") +endif() |