summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAmir Gonnen <amirgonnen@gmail.com>2019-03-26 14:53:19 +0200
committerEli Bendersky <eliben@users.noreply.github.com>2019-03-26 05:53:19 -0700
commit96059858252ea3673226a9a4d03a356bd51ba47e (patch)
treeb9372d42024d60bac15c6aa9a8aa66ca24498e5b /tests
parent992715f12aef69eb1351308f14fb5f1ff972ce57 (diff)
downloadpycparser-96059858252ea3673226a9a4d03a356bd51ba47e.tar.gz
Fix array type generation (#312) (#313)
* Fix array type generation (#312) Also added dim_quals handling to _generate_type Exmaple: >>> ast = parser.parse('int g(const int a[const 20]){}') >>> gen.visit(ast.ext[0].decl.type.args.params[0]) 'const int a[const 20]' >>> gen.visit(ast.ext[0].decl.type.args.params[0].type) 'int[const 20]' * Added TypeDecl generation. Added tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_c_generator.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_c_generator.py b/tests/test_c_generator.py
index 3727f91..e2f7bee 100644
--- a/tests/test_c_generator.py
+++ b/tests/test_c_generator.py
@@ -332,6 +332,12 @@ class TestCtoC(unittest.TestCase):
name='',
)
+ def test_array_decl(self):
+ self._assert_ctoc_correct('int g(const int a[const 20]){}')
+ ast = parse_to_ast('const int a[const 20];')
+ generator = c_generator.CGenerator()
+ self.assertEqual(generator.visit(ast.ext[0].type), 'const int[const 20]')
+ self.assertEqual(generator.visit(ast.ext[0].type.type), 'const int')
if __name__ == "__main__":
unittest.main()