diff options
author | Vitaly Cheptsov <4348897+vit9696@users.noreply.github.com> | 2021-10-05 15:36:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-05 05:36:06 -0700 |
commit | 277c6066c8b76f084a238d28bd6193871eb0b74f (patch) | |
tree | ef4b91364f5606437e38ba2da7b6ad704492cc8c /tests | |
parent | d4c2922407c486da1ba9c6cd769990cc64308be6 (diff) | |
download | pycparser-277c6066c8b76f084a238d28bd6193871eb0b74f.tar.gz |
Implement u8, u, and U strings from C11 (#439)
* Implement u8, u, and U strings from C11
* Also add u8, u, and U chars from C11 and C23
Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/c_files/c11.c | 11 | ||||
-rw-r--r-- | tests/test_c_lexer.py | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/c_files/c11.c b/tests/c_files/c11.c index 4f97a87..1c7ec08 100644 --- a/tests/c_files/c11.c +++ b/tests/c_files/c11.c @@ -5,6 +5,7 @@ #include <assert.h> #include <stdatomic.h> #include <stdalign.h> +#include <wchar.h> /* C11 thread locals */ _Thread_local int flag; @@ -38,6 +39,16 @@ int main() static_assert(_Alignof(int) == sizeof(int), "Unexpected int alignment"); static_assert(alignof(int) == sizeof(int), "Unexpected int alignment"); + wchar_t *w = L"12345"; + char16_t *c16 = u"12345"; + char32_t *c32 = U"12345"; + char *u8 = u8"12345"; + + wchar_t wc = L'1'; + char16_t c16c = u'1'; + char32_t c32c = U'1'; + char u8c = u8'1'; + printf("Flag: %d\n", flag); printf("Flag2: %d\n", flag2); func(); diff --git a/tests/test_c_lexer.py b/tests/test_c_lexer.py index 1d3c39b..03fd838 100644 --- a/tests/test_c_lexer.py +++ b/tests/test_c_lexer.py @@ -122,6 +122,9 @@ class TestCLexerNoErrors(unittest.TestCase): def test_char_constants(self): self.assertTokensTypes(r"""'x'""", ['CHAR_CONST']) self.assertTokensTypes(r"""L'x'""", ['WCHAR_CONST']) + self.assertTokensTypes(r"""u8'x'""", ['U8CHAR_CONST']) + self.assertTokensTypes(r"""u'x'""", ['U16CHAR_CONST']) + self.assertTokensTypes(r"""U'x'""", ['U32CHAR_CONST']) self.assertTokensTypes(r"""'\t'""", ['CHAR_CONST']) self.assertTokensTypes(r"""'\''""", ['CHAR_CONST']) self.assertTokensTypes(r"""'\?'""", ['CHAR_CONST']) @@ -147,6 +150,9 @@ class TestCLexerNoErrors(unittest.TestCase): def test_string_literal(self): self.assertTokensTypes('"a string"', ['STRING_LITERAL']) self.assertTokensTypes('L"ing"', ['WSTRING_LITERAL']) + self.assertTokensTypes('u8"ing"', ['U8STRING_LITERAL']) + self.assertTokensTypes('u"ing"', ['U16STRING_LITERAL']) + self.assertTokensTypes('U"ing"', ['U32STRING_LITERAL']) self.assertTokensTypes( '"i am a string too \t"', ['STRING_LITERAL']) |