[pygccxml-commit] SF.net SVN: pygccxml: [480] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-08-28 09:16:12
|
Revision: 480 Author: roman_yakovenko Date: 2006-08-28 02:16:02 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=480&view=rev Log Message: ----------- adding new unit tests Modified Paths: -------------- pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/no_init_to_be_exported.hpp pyplusplus_dev/unittests/no_init_tester.py Added: pyplusplus_dev/unittests/data/no_init_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/no_init_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/no_init_to_be_exported.hpp 2006-08-28 09:16:02 UTC (rev 480) @@ -0,0 +1,32 @@ +// 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 __no_init_to_be_exported_hpp__ +#define __no_init_to_be_exported_hpp__ + +#include "boost/shared_ptr.hpp" + +namespace no_init_ns{ + +class controller_i{ +public: + virtual ~controller_i() { } + virtual bool get_value(void) const = 0; + virtual void set_value(bool value) = 0; +}; + +inline int +get_value( const boost::shared_ptr< controller_i >& controller ){ + if( controller ){ + return controller->get_value() ? 1 : 0; + } + else{ + return -1; + } +} + +} + +#endif//__no_init_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/no_init_tester.py =================================================================== --- pyplusplus_dev/unittests/no_init_tester.py (rev 0) +++ pyplusplus_dev/unittests/no_init_tester.py 2006-08-28 09:16:02 UTC (rev 480) @@ -0,0 +1,49 @@ +# 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 + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'no_init' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def create_py_controller( self, module ): + class py_controller_t( module.controller_i ): + def __init__( self ): + module.controller_i.__init__( self ) + self.value = True + + def get_value(self): + return self.value + + def set_value( self, v ): + self.value = v + return py_controller_t() + + def run_tests(self, module): + controller = self.create_py_controller( module ) + self.failUnless( 1 == module.get_value( controller ) ) + controller.set_value( False ) + self.failUnless( 0 == module.get_value( controller ) ) + self.failUnless( -1 == module.get_value( None ) ) + +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: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2006-08-27 20:45:41 UTC (rev 479) +++ pyplusplus_dev/unittests/test_all.py 2006-08-28 09:16:02 UTC (rev 480) @@ -21,7 +21,7 @@ import call_policies_tester import pointer_to_function_as_argument import operators_tester -import abstract_tester +import abstract_tester import statics_tester import regression1_tester import casting_tester @@ -59,9 +59,10 @@ import default_args_tester import unnamed_classes_tester import cppexceptions_tester +import no_init_tester -def create_suite(times): - testers = [ +def create_suite(times): + testers = [ algorithms_tester , module_body_tester , enums_tester @@ -114,9 +115,10 @@ , indexing_suites2_tester , unnamed_classes_tester , cppexceptions_tester + , no_init_tester ] - - main_suite = unittest.TestSuite() + + main_suite = unittest.TestSuite() for i in range( times ): for tester in testers: main_suite.addTest( tester.create_suite() ) @@ -134,5 +136,5 @@ except Exception, error: print str( error ) print 'first argument should be integer, it says how many times to run tests.' - - run_suite(times) \ No newline at end of file + + run_suite(times) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |