From b67b919394993b8c467c7c1bbd836fc75cfbe9ba Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 10 Jul 2021 06:32:41 +0200 Subject: [PATCH] Additional utility tests --- tests/utility_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/utility_test.cpp b/tests/utility_test.cpp index 1c26bcf..1739c28 100644 --- a/tests/utility_test.cpp +++ b/tests/utility_test.cpp @@ -143,4 +143,19 @@ int main() { g_assert(!starts_with(empty, 0, test)); g_assert(!ends_with(empty, test.c_str())); g_assert(!ends_with(empty, test)); + + { + g_assert(escape("", {}) == ""); + std::string test("^t'e\"st$"); + g_assert(escape(test, {'\"'}) == "^t'e\\\"st$"); + g_assert(escape(test, {'\''}) == "^t\\'e\"st$"); + g_assert(escape(test, {'\'', '"', '$'}) == "^t\\'e\\\"st\\$"); + g_assert(escape(test, {'^', '$'}) == "\\^t'e\"st\\$"); + } + { + g_assert(to_hex_string("") == ""); + g_assert(to_hex_string("\n") == "0a"); + g_assert(to_hex_string("\n!") == "0a21"); + g_assert(to_hex_string("\n!z") == "0a217a"); + } } \ No newline at end of file