summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/string/Hex.cmake
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-18 15:49:02 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-19 14:11:05 (GMT)
commit5395bf05ebaa122400a2bd9f0b0547cf760aa43c (patch)
tree5ba56ea071815b63403b535f53622dc3f9dde2a4 /Tests/RunCMake/string/Hex.cmake
parent952945813c091c4267590e80bd8e5421fe64508b (diff)
downloadCMake-5395bf05ebaa122400a2bd9f0b0547cf760aa43c.zip
CMake-5395bf05ebaa122400a2bd9f0b0547cf760aa43c.tar.gz
CMake-5395bf05ebaa122400a2bd9f0b0547cf760aa43c.tar.bz2
string: Add new HEX sub-command
Diffstat (limited to 'Tests/RunCMake/string/Hex.cmake')
-rw-r--r--Tests/RunCMake/string/Hex.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/Tests/RunCMake/string/Hex.cmake b/Tests/RunCMake/string/Hex.cmake
new file mode 100644
index 0000000..1c5aaa1
--- /dev/null
+++ b/Tests/RunCMake/string/Hex.cmake
@@ -0,0 +1,20 @@
+function(assert_strequal input actual expected)
+ if(NOT expected STREQUAL actual)
+ message(SEND_ERROR "Output did not match expected\nInput string:\n ${input}\nExpected:\n ${expected}\nActual:\n ${actual}")
+ endif()
+endfunction()
+
+set(_input1 "The quick brown fox jumps over the lazy dog.")
+string(HEX "${_input1}" _result1)
+assert_strequal("${_input1}" "${_result1}" "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f672e")
+
+set(_input2 "Hello world!")
+string(HEX "${_input2}" _result2)
+assert_strequal("${_input2}" "${_result2}" "48656c6c6f20776f726c6421")
+
+set(_input3 "Ash nazg durbatulûk\nAsh nazg gimbatul\nAsh nazg thrakatulûk\nAgh burzum-ishi krimpatul")
+string(HEX "${_input3}" _result3)
+assert_strequal("${_input3}" "${_result3}" "417368206e617a6720647572626174756cc3bb6b0a417368206e617a672067696d626174756c0a417368206e617a6720746872616b6174756cc3bb6b0a416768206275727a756d2d69736869206b72696d706174756c")
+
+string(HEX "" _result_empty)
+assert_strequal("" "${_result_empty}" "")