| 1 |
function(check_output name expected) |
| 2 |
set(output "${${name}}") |
| 3 |
if(NOT output STREQUAL expected) |
| 4 |
message(FATAL_ERROR "\"string(REGEX)\" set ${name} to \"${output}\", expected \"${expected}\"") |
| 5 |
endif() |
| 6 |
endfunction() |
| 7 |
|
| 8 |
# OLD |
| 9 |
cmake_policy(SET CMP0186 OLD) |
| 10 |
|
| 11 |
string(REGEX MATCHALL "^0" out "0000") |
| 12 |
check_output(out "0;0;0;0") |
| 13 |
|
| 14 |
string(REGEX MATCHALL "^0+" out "0000") |
| 15 |
check_output(out "0000") |
| 16 |
|
| 17 |
string(REGEX MATCHALL "^(0|a)" out "0000" ) |
| 18 |
check_output(out "0;0;0;0") |
| 19 |
|
| 20 |
string(REGEX MATCHALL "^(0|a)" out "aaaa") |
| 21 |
check_output(out "a;a;a;a") |
| 22 |
|
| 23 |
string(REGEX MATCHALL "^(0|a)" out "a0a0") |
| 24 |
check_output(out "a;0;a;0") |
| 25 |
|
| 26 |
string(REGEX MATCHALL "(^|a)0" out "00a0") |
| 27 |
check_output(out "0;0;a0") |
| 28 |
|
| 29 |
string(REGEX REPLACE "^0" "" out "0000") |
| 30 |
check_output(out "") |
| 31 |
|
| 32 |
string(REGEX REPLACE "^0" "x" out "0000") |
| 33 |
check_output(out "xxxx") |
| 34 |
|
| 35 |
string(REGEX REPLACE "^0+" "x" out "0000") |
| 36 |
check_output(out "x") |
| 37 |
|
| 38 |
string(REGEX REPLACE "^(0|a)" "x" out "0000") |
| 39 |
check_output(out "xxxx") |
| 40 |
|
| 41 |
string(REGEX REPLACE "^(0|a)" "x" out "aaaa") |
| 42 |
check_output(out "xxxx") |
| 43 |
|
| 44 |
string(REGEX REPLACE "^(0|a)" "x" out "a0a0") |
| 45 |
check_output(out "xxxx") |
| 46 |
|
| 47 |
string(REGEX REPLACE "(^|a)0" "x" out "00a0") |
| 48 |
check_output(out "xxx") |
| 49 |
|
| 50 |
# NEW, same cases as above |
| 51 |
cmake_policy(SET CMP0186 NEW) |
| 52 |
|
| 53 |
string(REGEX MATCHALL "^0" out "0000") |
| 54 |
check_output(out "0") |
| 55 |
|
| 56 |
string(REGEX MATCHALL "^0+" out "0000") |
| 57 |
check_output(out "0000") |
| 58 |
|
| 59 |
string(REGEX MATCHALL "^(0|a)" out "0000") |
| 60 |
check_output(out "0") |
| 61 |
|
| 62 |
string(REGEX MATCHALL "^(0|a)" out "aaaa") |
| 63 |
check_output(out "a") |
| 64 |
|
| 65 |
string(REGEX MATCHALL "^(0|a)" out "a0a0") |
| 66 |
check_output(out "a") |
| 67 |
|
| 68 |
string(REGEX MATCHALL "(^|a)0" out "00a0") |
| 69 |
check_output(out "0;a0") |
| 70 |
|
| 71 |
string(REGEX REPLACE "^0" "" out "0000") |
| 72 |
check_output(out "000") |
| 73 |
|
| 74 |
string(REGEX REPLACE "^0" "x" out "0000") |
| 75 |
check_output(out "x000") |
| 76 |
|
| 77 |
string(REGEX REPLACE "^0+" "x" out "0000") |
| 78 |
check_output(out "x") |
| 79 |
|
| 80 |
string(REGEX REPLACE "^(0|a)" "x" out "0000") |
| 81 |
check_output(out "x000") |
| 82 |
|
| 83 |
string(REGEX REPLACE "^(0|a)" "x" out "aaaa") |
| 84 |
check_output(out "xaaa") |
| 85 |
|
| 86 |
string(REGEX REPLACE "^(0|a)" "x" out "a0a0") |
| 87 |
check_output(out "x0a0") |
| 88 |
|
| 89 |
string(REGEX REPLACE "(^|a)0" "x" out "00a0") |
| 90 |
check_output(out "x0x") |