mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
test: Test STRLEN for C11 string literals
This commit is contained in:
parent
ec5e113f09
commit
d17c93a72b
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user