[pygccxml-commit] SF.net SVN: pygccxml: [259] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-06-28 09:16:57
|
Revision: 259 Author: roman_yakovenko Date: 2006-06-28 02:16:40 -0700 (Wed, 28 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=259&view=rev Log Message: ----------- adding unit test for indexing suite 2 Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py pyplusplus_dev/pyplusplus/module_creator/types_database.py pyplusplus_dev/unittests/fundamental_tester_base.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp pyplusplus_dev/unittests/indexing_suites2_tester.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-06-28 08:45:46 UTC (rev 258) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-06-28 09:16:40 UTC (rev 259) @@ -58,6 +58,9 @@ def _get_container_traits( self ): return self._get_container_traits() container_traits = property( _get_container_traits ) + + def value_type( self ): + return self.__container_traits.value_type( self.container_class ) def _get_call_policies( self ): #TODO find out call policies Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-28 08:45:46 UTC (rev 258) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-28 09:16:40 UTC (rev 259) @@ -65,7 +65,7 @@ return False try: - #checking whether value_type could be extracted + #checking whether value_type could be extracted container_cls.indexing_suite.value_type() except RuntimeError, error: msg = 'WARNING: pyplusplus found "%s" instantiation declaration, ' % container_cls.name Added: pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp 2006-06-28 09:16:40 UTC (rev 259) @@ -0,0 +1,44 @@ +// 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 __indexing_suites2_to_be_exported_hpp__ +#define __indexing_suites2_to_be_exported_hpp__ + +#include <vector> + +namespace indexing_suites2 { + +//~ struct item_t{ + //~ item_t() : value( -1 ){} + + //~ bool operator==(item_t const& item) const { + //~ return value == item.value; + //~ } + + //~ bool operator!=(item_t const& item) const { + //~ return value != item.value; + //~ } + + //~ int value; +//~ }; + + +//~ typedef std::vector<item_t> items_t; + +//~ inline item_t get_value( const std::vector<item_t>& vec, unsigned int index ){ + //~ return vec.at(index); +//~ } + +//~ inline void set_value( std::vector<item_t>& vec, unsigned int index, item_t value ){ + //~ vec.at(index); + //~ vec[index] = value; +//~ } + +typedef std::vector<int> ivector; +ivector empty_ivector(){ return ivector(); } + +} + +#endif//__indexing_suites2_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2006-06-28 08:45:46 UTC (rev 258) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2006-06-28 09:16:40 UTC (rev 259) @@ -17,7 +17,7 @@ class fundamental_tester_base_t( unittest.TestCase ): SUFFIX_TO_BE_EXPORTED = '_to_be_exported.hpp' - def __init__(self, module_name, *args ): + def __init__(self, module_name, indexing_suite_version=1, *args ): unittest.TestCase.__init__(self, *args) self.__module_name = module_name self.__to_be_exported_header \ @@ -28,7 +28,8 @@ , self.__module_name + '.cpp' ) self.__generated_scons_file_name = os.path.join( autoconfig.build_dir , self.__module_name + '.scons' ) - + self.__indexing_suite_version = indexing_suite_version + def failIfRaisesAny(self, callableObj, *args, **kwargs): try: callableObj(*args, **kwargs) @@ -53,7 +54,8 @@ mb = module_builder.module_builder_t( [self.__to_be_exported_header] , gccxml_path=autoconfig.gccxml.executable , include_paths=[autoconfig.boost.include] - , undefine_symbols=['__MINGW32__'] ) + , undefine_symbols=['__MINGW32__'] + , indexing_suite_version=self.__indexing_suite_version) self.customize( mb ) if not mb.has_code_creator(): mb.build_code_creator( self.__module_name ) Added: pyplusplus_dev/unittests/indexing_suites2_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites2_tester.py (rev 0) +++ pyplusplus_dev/unittests/indexing_suites2_tester.py 2006-06-28 09:16:40 UTC (rev 259) @@ -0,0 +1,56 @@ +# 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 +from pyplusplus import module_builder + + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'indexing_suites2' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , 2 + , *args ) + + #~ @staticmethod + #~ def matcher( item, decl ): + #~ if not declarations.vector_traits.is_my_case( decl ): + #~ return False + #~ value_type = declarations.vector_traits.value_type(decl) + #~ if item is value_type: + #~ return True + #~ return False + + #~ def customize(self, generator): + #~ item = generator.class_( 'item_t' ) + #~ items = generator.class_( lambda decl: self.matcher( item, decl ) ) + #~ items.alias = "items_t" + + def run_tests( self, module): + iv = module.ivector() + #~ items = module.items_t() + #~ item = module.item_t() + #~ item.value = 1977 + #~ items.append( item ) + #~ self.failUnless( module.get_value( items, 0 ).value == 1977 ) + #~ self.failUnless( len( items ) == 1 ) + +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-06-28 08:45:46 UTC (rev 258) +++ pyplusplus_dev/unittests/test_all.py 2006-06-28 09:16:40 UTC (rev 259) @@ -52,7 +52,8 @@ import factory_tester import private_assign_tester import protected_tester -import indexing_suites_tester +import indexing_suites_tester +import indexing_suites2_tester import hierarchy3_tester import vector3_tester import default_args_tester @@ -109,6 +110,7 @@ , default_args_tester , abstract_classes_tester , classes_tester + , indexing_suites2_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |