| 1 |
function(assert_strequal input actual expected) |
| 2 |
if(NOT expected STREQUAL actual) |
| 3 |
message(SEND_ERROR "Output did not match expected\nInput string:\n ${input}\nExpected:\n ${expected}\nActual:\n ${actual}") |
| 4 |
endif() |
| 5 |
endfunction() |
| 6 |
|
| 7 |
set(_input1 "The quick brown fox jumps over the lazy dog.") |
| 8 |
string(HEX "${_input1}" _result1) |
| 9 |
assert_strequal("${_input1}" "${_result1}" "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f672e") |
| 10 |
|
| 11 |
set(_input2 "Hello world!") |
| 12 |
string(HEX "${_input2}" _result2) |
| 13 |
assert_strequal("${_input2}" "${_result2}" "48656c6c6f20776f726c6421") |
| 14 |
|
| 15 |
set(_input3 "Ash nazg durbatulûk\nAsh nazg gimbatul\nAsh nazg thrakatulûk\nAgh burzum-ishi krimpatul") # UTF-8 |
| 16 |
string(HEX "${_input3}" _result3) |
| 17 |
assert_strequal("${_input3}" "${_result3}" "417368206e617a6720647572626174756cc3bb6b0a417368206e617a672067696d626174756c0a417368206e617a6720746872616b6174756cc3bb6b0a416768206275727a756d2d69736869206b72696d706174756c") |
| 18 |
|
| 19 |
string(HEX "" _result_empty) |
| 20 |
assert_strequal("" "${_result_empty}" "") |