Merge topic 'string-repeat'

536cca60ea string: introduce `REPEAT` sub-command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3239
This commit is contained in:
Brad King
2019-04-16 17:39:51 +00:00
committed by Kitware Robot
12 changed files with 136 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
string(REPEAT "q" 4 q_out)
if(NOT DEFINED q_out)
message(FATAL_ERROR "q_out is not defined")
endif()
if(NOT q_out STREQUAL "qqqq")
message(FATAL_ERROR "unexpected result")
endif()
string(REPEAT "1234" 0 zero_out)
if(NOT DEFINED zero_out)
message(FATAL_ERROR "zero_out is not defined")
endif()
if(NOT zero_out STREQUAL "")
message(FATAL_ERROR "unexpected result")
endif()
unset(zero_out)
string(REPEAT "" 100 zero_out)
if(NOT DEFINED zero_out)
message(FATAL_ERROR "zero_out is not defined")
endif()
if(NOT zero_out STREQUAL "")
message(FATAL_ERROR "unexpected result")
endif()
string(REPEAT "1" 1 one_out)
if(NOT one_out STREQUAL "1")
message(FATAL_ERROR "unexpected result")
endif()
unset(one_out)
string(REPEAT "one" 1 one_out)
if(NOT one_out STREQUAL "one")
message(FATAL_ERROR "unexpected result")
endif()
@@ -0,0 +1 @@
1
@@ -0,0 +1,4 @@
CMake Error at RepeatNegativeCount.cmake:[0-9]+ \(string\):
repeat count is not a positive number.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
@@ -0,0 +1 @@
string(REPEAT "blah" -1 out)
@@ -0,0 +1 @@
1
@@ -0,0 +1,4 @@
CMake Error at RepeatNoArgs.cmake:[0-9]+ \(string\):
sub-command REPEAT requires three arguments.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+1
View File
@@ -0,0 +1 @@
string(REPEAT)
+4
View File
@@ -33,3 +33,7 @@ run_cmake(UTF-16BE)
run_cmake(UTF-16LE)
run_cmake(UTF-32BE)
run_cmake(UTF-32LE)
run_cmake(Repeat)
run_cmake(RepeatNoArgs)
run_cmake(RepeatNegativeCount)