|
| 1 | +# Copyright 2004-2008 Roman Yakovenko. |
| 2 | +# Distributed under the Boost Software License, Version 1.0. (See |
| 3 | +# accompanying file LICENSE_1_0.txt or copy at |
| 4 | +# http://www.boost.org/LICENSE_1_0.txt) |
| 5 | + |
| 6 | +import os |
| 7 | +import unittest |
| 8 | +import autoconfig |
| 9 | +import parser_test_case |
| 10 | + |
| 11 | +from pygccxml import utils |
| 12 | +from pygccxml import parser |
| 13 | +from pygccxml import declarations |
| 14 | + |
| 15 | + |
| 16 | +class tester_t( parser_test_case.parser_test_case_t ): |
| 17 | + def __init__(self, *args): |
| 18 | + parser_test_case.parser_test_case_t.__init__(self, *args) |
| 19 | + |
| 20 | + def test1(self): |
| 21 | + code = 'int aaaa[2][3][4][5];' |
| 22 | + src_reader = parser.source_reader_t( self.config ) |
| 23 | + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) |
| 24 | + aaaa_type = global_ns.var('aaaa').type |
| 25 | + self.failUnless( 'int[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) |
| 26 | + |
| 27 | + def test2(self): |
| 28 | + code = 'int* aaaa[2][3][4][5];' |
| 29 | + src_reader = parser.source_reader_t( self.config ) |
| 30 | + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) |
| 31 | + aaaa_type = global_ns.var('aaaa').type |
| 32 | + self.failUnless( 'int *[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) |
| 33 | + |
| 34 | + def test3(self): |
| 35 | + code = 'int aaaa[2];' |
| 36 | + src_reader = parser.source_reader_t( self.config ) |
| 37 | + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) |
| 38 | + aaaa_type = global_ns.var('aaaa').type |
| 39 | + self.failUnless( 'int[2]' == aaaa_type.decl_string, aaaa_type.decl_string ) |
| 40 | + |
| 41 | + def test4(self): |
| 42 | + code = 'struct xyz{}; xyz aaaa[2][3];' |
| 43 | + src_reader = parser.source_reader_t( self.config ) |
| 44 | + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) |
| 45 | + aaaa_type = global_ns.var('aaaa').type |
| 46 | + self.failUnless( '::xyz[2][3]' == aaaa_type.decl_string, aaaa_type.decl_string ) |
| 47 | + |
| 48 | + |
| 49 | +def create_suite(): |
| 50 | + suite = unittest.TestSuite() |
| 51 | + suite.addTest( unittest.makeSuite(tester_t)) |
| 52 | + return suite |
| 53 | + |
| 54 | +def run_suite(): |
| 55 | + unittest.TextTestRunner(verbosity=2).run( create_suite() ) |
| 56 | + |
| 57 | +if __name__ == "__main__": |
| 58 | + run_suite() |
0 commit comments