diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-10 11:27:47 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-10 11:28:34 +0200 |
commit | f3ee629711783333005c41e21d66841268b80f70 (patch) | |
tree | ba8b7e109c433d85d4b3220be86309afbaa1caf6 /src/test/test-util.c | |
parent | 96406c1a278bfd1c1b69a248cc6c223755077f02 (diff) |
util: when unescaping C escape sequences support C++11 \u and \U unicode literals
We simply recode them in utf8.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r-- | src/test/test-util.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index f1403fa393..7af41bcb18 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -416,11 +416,10 @@ static void test_cescape(void) { static void test_cunescape(void) { _cleanup_free_ char *unescaped; - const char *x = "abc\\\"\b\f\a\n\r\t\v\003\177\234\313\\000\\x00"; assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", 0, &unescaped) < 0); assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", UNESCAPE_RELAX, &unescaped) >= 0); - assert_se(streq_ptr(unescaped, x)); + assert_se(streq_ptr(unescaped, "abc\\\"\b\f\a\n\r\t\v\003\177\234\313\\000\\x00")); free(unescaped); unescaped = NULL; @@ -452,6 +451,12 @@ static void test_cunescape(void) { assert_se(cunescape("\\1", 0, &unescaped) < 0); assert_se(cunescape("\\1", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\1")); + free(unescaped); + unescaped = NULL; + + assert_se(cunescape("\\u0000", 0, &unescaped) < 0); + assert_se(cunescape("\\u00DF\\U000000df\\u03a0\\U00000041", UNESCAPE_RELAX, &unescaped) >= 0); + assert_se(streq_ptr(unescaped, "ßßΠA")); } static void test_foreach_word(void) { |