Skip to content

Commit

Permalink
Add thornier tests for nested pointers with qualifiers in declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Aug 28, 2021
1 parent cd50d04 commit 7d9a6d9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_c_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ def test_nested_decls(self): # the fun begins
['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',
Expand Down Expand Up @@ -761,6 +766,19 @@ def test_typedef(self):
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 {
Expand Down

0 comments on commit 7d9a6d9

Please sign in to comment.