diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2010-07-04 18:56:05 +0200 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2010-12-08 16:38:30 -0500 |
commit | 36cb701690b201136ca4892eb561da3df34ae191 (patch) | |
tree | 11d778a3cf062db774a9dd7aa12d27671ab9701d /Tests/StringFileTest | |
parent | 02a8ea2d5b0b41858be8a9e28d41e06af744fd0b (diff) | |
download | cmake-36cb701690b201136ca4892eb561da3df34ae191.tar.gz |
allow STRING(SUBSTRING) work with length -1 as "rest of the string"
This fixes the first half of bug 10740.
Diffstat (limited to 'Tests/StringFileTest')
-rw-r--r-- | Tests/StringFileTest/CMakeLists.txt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index 2e052bf90f..7792a353d2 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -256,3 +256,27 @@ endif() if(NOT "${var_b}" STREQUAL "x") message(FATAL_ERROR "count incorrect \"b\": [${var_b}]") endif() + +# Test SUBSTRING command +SET(ST_INPUTSTRING "0123456789") +STRING(SUBSTRING ${ST_INPUTSTRING} 3 0 ST_EMPTY) +STRING(SUBSTRING ${ST_INPUTSTRING} 1 1 ST_ONE) +STRING(SUBSTRING ${ST_INPUTSTRING} 0 10 ST_ALL) +STRING(SUBSTRING ${ST_INPUTSTRING} 0 -1 ST_ALL_MINUS) +STRING(SUBSTRING ${ST_INPUTSTRING} 9 -1 ST_NINE) + +IF(ST_EMPTY) + MESSAGE(SEND_ERROR "SUBSTRING with length 0 does not return an empty string") +ENDIF(ST_EMPTY) +IF(NOT ST_ONE STREQUAL "1") + MESSAGE(SEND_ERROR "SUBSTING command does not cut the correct selected character, was \"" ${ST_ONE} "\", should be \"1\"") +ENDIF(NOT ST_ONE STREQUAL "1") +IF(NOT ST_INPUTSTRING STREQUAL ST_ALL) + MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with length") +ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL) +IF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS) + MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with -1") +ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS) +IF(NOT ST_NINE STREQUAL "9") + MESSAGE(SEND_ERROR "SUBSTRING does not return the tail when selected with -1") +ENDIF(NOT ST_NINE STREQUAL "9") |