diff options
author | Jan Janssen <medhefgo@web.de> | 2022-05-22 09:37:27 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-05-22 21:21:04 +0200 |
commit | d17c93a72b50b8cd56fb739e11385ad85b4a8df6 (patch) | |
tree | 4387f18fbd975d446f72eb12a55e21bb900ddbb4 /src/test/test-format-util.c | |
parent | NEWS: Fix some minor mistakes (diff) | |
download | systemd-d17c93a72b50b8cd56fb739e11385ad85b4a8df6.tar.xz systemd-d17c93a72b50b8cd56fb739e11385ad85b4a8df6.zip |
test: Test STRLEN for C11 string literals
Diffstat (limited to '')
-rw-r--r-- | src/test/test-format-util.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/test/test-format-util.c b/src/test/test-format-util.c index ee74d1c898..306350937a 100644 --- a/src/test/test-format-util.c +++ b/src/test/test-format-util.c @@ -4,12 +4,24 @@ #include "macro.h" #include "string-util.h" #include "tests.h" +#include "uchar.h" /* Do some basic checks on STRLEN() and DECIMAL_STR_MAX() */ -assert_cc(STRLEN("xxx") == 3); assert_cc(STRLEN("") == 0); -assert_cc(STRLEN(L"xxx") == 3 * sizeof(wchar_t)); +assert_cc(STRLEN("a") == 1); +assert_cc(STRLEN("123") == 3); +assert_cc(STRLEN(u8"") == 0); +assert_cc(STRLEN(u8"a") == 1); +assert_cc(STRLEN(u8"123") == 3); +assert_cc(STRLEN(u"") == 0); +assert_cc(STRLEN(u"a") == sizeof(char16_t)); +assert_cc(STRLEN(u"123") == 3 * sizeof(char16_t)); +assert_cc(STRLEN(U"") == 0); +assert_cc(STRLEN(U"a") == sizeof(char32_t)); +assert_cc(STRLEN(U"123") == 3 * sizeof(char32_t)); assert_cc(STRLEN(L"") == 0); +assert_cc(STRLEN(L"a") == sizeof(wchar_t)); +assert_cc(STRLEN(L"123") == 3 * sizeof(wchar_t)); assert_cc(DECIMAL_STR_MAX(uint8_t) == STRLEN("255")+1); assert_cc(DECIMAL_STR_MAX(int8_t) == STRLEN("-127")+1); assert_cc(DECIMAL_STR_MAX(uint64_t) == STRLEN("18446744073709551615")+1); |