From 7d9a6d96af0828892bc296aedbf35bc81482e8ac Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 28 Aug 2021 08:01:32 -0700 Subject: Add thornier tests for nested pointers with qualifiers in declarations --- tests/test_c_parser.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py index 4688c3b..11717a5 100755 --- a/tests/test_c_parser.py +++ b/tests/test_c_parser.py @@ -348,6 +348,11 @@ class TestCParser_fundamentals(TestCParser_base): ['PtrDecl', ['PtrDecl', ['const'], ['TypeDecl', ['IdentifierType', ['char']]]]]]) + self.assertEqual(self.get_decl('const char* const* p;'), + ['Decl', ['const'], 'p', + ['PtrDecl', ['PtrDecl', ['const'], + ['TypeDecl', ['IdentifierType', ['char']]]]]]) + self.assertEqual(self.get_decl('char* * const p;'), ['Decl', 'p', ['PtrDecl', ['const'], ['PtrDecl', @@ -761,6 +766,19 @@ class TestCParser_fundamentals(TestCParser_base): self.assertEqual(expand_decl(ps5.ext[0]), ['Typedef', 'Hash', ['TypeDecl', ['Struct', 'tagHash', []]]]) + s6 = '''typedef int (* const * const T)(void);''' + ps6 = self.parse(s6) + self.assertEqual(expand_decl(ps6.ext[0]), + ['Typedef', + 'T', + ['PtrDecl', + ['const'], + ['PtrDecl', + ['const'], + ['FuncDecl', + [['Typename', ['TypeDecl', ['IdentifierType', ['void']]]]], + ['TypeDecl', ['IdentifierType', ['int']]]]]]]) + def test_struct_union(self): s1 = """ struct { -- cgit v1.2.1