[pygccxml-commit] SF.net SVN: pygccxml: [37] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-05-02 04:31:12
|
Revision: 37 Author: roman_yakovenko Date: 2006-05-01 21:31:00 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=37&view=rev Log Message: ----------- adding new tester for protected functions Modified Paths: -------------- pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/protected_to_be_exported.hpp pyplusplus_dev/unittests/protected_tester.py Added: pyplusplus_dev/unittests/data/protected_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/protected_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/protected_to_be_exported.hpp 2006-05-02 04:31:00 UTC (rev 37) @@ -0,0 +1,34 @@ +// Copyright 2004 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 __protected_to_be_exported_hpp__ +#define __protected_to_be_exported_hpp__ + +namespace protected_{ + +struct protected_t{ +protected: + int get_1(){ return 1; } +}; + +struct protected_s_t{ +protected: + static int get_2(){ return 2; } +}; + + +struct protected_v_t{ +protected: + virtual int get_i(){ return 10; } +}; + +struct protected_v_derived_t : public protected_v_t{ +}; + +} + +#endif//__protected_to_be_exported_hpp__ + + Added: pyplusplus_dev/unittests/protected_tester.py =================================================================== --- pyplusplus_dev/unittests/protected_tester.py (rev 0) +++ pyplusplus_dev/unittests/protected_tester.py 2006-05-02 04:31:00 UTC (rev 37) @@ -0,0 +1,74 @@ +# Copyright 2004 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 sys +import unittest +import fundamental_tester_base +from pygccxml import declarations + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'protected' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize(self, mb ): + mb.classes().always_expose_using_scope = True + mb.calldefs().create_with_signature = True + + def create_protected_s_derived_no_override( self, module ): + class derived(module.protected_v_t): + def __init__( self ): + module.protected_v_t.__init__( self ) + return derived() + + def create_protected_s_derived( self, module ): + class derived(module.protected_v_t): + def __init__( self ): + module.protected_v_t.__init__( self ) + + def get_i(self): + return 20 + #todo: fix it + #return super( derived, self ).get_i() * 2 + + return derived() + + + def run_tests(self, module): + protected = module.protected_t() + self.failUnless( protected.get_1() == 1 ) + + protected_s = module.protected_s_t() + self.failUnless( protected_s.get_2() == 2 ) + self.failUnless( module.protected_s_t.get_2() == 2 ) + + protected_v = module.protected_v_t() + self.failUnless( protected_v.get_i() == 10 ) + + protected_v_no_override = self.create_protected_s_derived_no_override( module ) + self.failUnless( protected_v_no_override.get_i() == 10 ) + + protected_v_override = self.create_protected_s_derived( module ) + self.failUnless( protected_v_override.get_i() == 20 ) + + protected_v_d = module.protected_v_derived_t() + self.failUnless( protected_v_d.get_i() == 10 ) + + +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() \ No newline at end of file Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2006-05-02 04:29:42 UTC (rev 36) +++ pyplusplus_dev/unittests/test_all.py 2006-05-02 04:31:00 UTC (rev 37) @@ -49,6 +49,7 @@ import pointer_as_arg_tester import factory_tester import private_assign_tester +import protected_tester def create_suite(times): testers = [ @@ -94,7 +95,8 @@ , optional_bug_tester , pointer_as_arg_tester , factory_tester - , private_assign_tester + , private_assign_tester + , protected_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |