[pygccxml-commit] SF.net SVN: pygccxml:[1448] pygccxml_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2008-11-01 08:09:27
|
Revision: 1448 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1448&view=rev Author: roman_yakovenko Date: 2008-11-01 08:09:25 +0000 (Sat, 01 Nov 2008) Log Message: ----------- adding new tester Modified Paths: -------------- pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/data/classes.hpp pygccxml_dev/unittests/declaration_matcher_tester.py Added: pygccxml_dev/unittests/data/classes.hpp =================================================================== --- pygccxml_dev/unittests/data/classes.hpp (rev 0) +++ pygccxml_dev/unittests/data/classes.hpp 2008-11-01 08:09:25 UTC (rev 1448) @@ -0,0 +1,17 @@ +// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __classes_hpp__ +#define __classes_hpp__ + +struct cls{}; + +namespace ns{ + + struct nested_cls{}; + +} + +#endif//__classes_hpp__ Added: pygccxml_dev/unittests/declaration_matcher_tester.py =================================================================== --- pygccxml_dev/unittests/declaration_matcher_tester.py (rev 0) +++ pygccxml_dev/unittests/declaration_matcher_tester.py 2008-11-01 08:09:25 UTC (rev 1448) @@ -0,0 +1,56 @@ +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + global_ns = None + COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'classes.hpp' + self.global_ns = None + + def setUp(self): + if not tester_t.global_ns: + decls = parser.parse( [self.header], self.config ) + tester_t.global_ns = declarations.get_global_namespace( decls ) + tester_t.global_ns.init_optimizer() + self.global_ns = tester_t.global_ns + + def test_global( self ): + gns = self.global_ns + gns.class_( 'cls' ) + gns.class_( '::cls' ) + + def test_ns1( self ): + gns = self.global_ns + ns1 = gns.namespace( 'ns' ) + + gns.class_( 'nested_cls' ) + self.failUnlessRaises( Exception, lambda: gns.class_( 'ns::nested_cls' ) ) + gns.class_( '::ns::nested_cls' ) + + self.failUnlessRaises( Exception, lambda: ns1.class_( '::nested_cls' ) ) + ns1.class_( 'nested_cls' ) + ns1.class_( '::ns::nested_cls' ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2008-10-26 13:00:57 UTC (rev 1447) +++ pygccxml_dev/unittests/test_all.py 2008-11-01 08:09:25 UTC (rev 1448) @@ -51,6 +51,7 @@ import plain_c_tester import function_traits_tester import better_templates_matcher_tester +import declaration_matcher_tester testers = [ decl_string_tester @@ -98,6 +99,7 @@ , plain_c_tester , function_traits_tester , better_templates_matcher_tester + , declaration_matcher_tester ] def create_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |