Skip to content

Commit f25c60a

Browse files
author
roman_yakovenko
committed
adding new test case from Gustavo Carneiro
1 parent 1d3797d commit f25c60a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

unittests/data/remove_template_defaults.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ namespace maps{
7676
typedef std::map< int, double > m_i2d;
7777
typedef std::map< std::wstring, double > m_wstr2d;
7878
typedef std::map< const std::vector< int >, m_wstr2d > m_v_i2m_wstr2d;
79+
80+
inline std::map<std::string, int> f2(){}
81+
7982
}
8083

8184
namespace multimaps{

unittests/find_container_traits_tester.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,25 @@ def test_find_traits( self ):
6565
self.__cmp_traits( 'hmm_i2d', declarations.hash_multimap_traits, "hash_multimap< int, double >", 'int' )
6666

6767
def test_multimap( self ):
68-
mm = self.global_ns.classes( lambda decl: decl.name.startswith( 'multimap' ) )
69-
for m in mm:
70-
traits = declarations.find_container_traits( m )
71-
print m.partial_name
68+
m = self.global_ns.class_( lambda decl: decl.name.startswith( 'multimap' ) )
69+
traits = declarations.find_container_traits( m )
70+
self.failUness( m.partial_name == 'multimap< int, int >' )
7271

7372
def test_recursive_partial_name( self ):
7473
f1 = self.global_ns.free_fun( 'f1' )
7574
t1 = declarations.class_traits.get_declaration( f1.arguments[0].type )
7675
self.failUnless( 'type< std::set< std::vector< int > > >' == t1.partial_name )
7776

77+
def test_remove_defaults_partial_name_namespace( self ):
78+
f2 = self.global_ns.free_fun( 'f2' )
79+
type_info = f2.return_type
80+
traits = declarations.find_container_traits( type_info )
81+
cls = traits .class_declaration( type_info )
82+
decl_string = cls.partial_decl_string #traits.remove_defaults(type_info)
83+
key_type_string = traits.key_type(type_info).partial_decl_string
84+
self.assert_(decl_string.startswith('::std::'), "declaration string %r doesn't start with 'std::'" % decl_string)
85+
self.assert_(key_type_string.startswith('::std::'), "key type string %r doesn't start with 'std::'" % key_type_string)
86+
7887
def test_from_ogre( self ):
7988
x = 'map<std::string, bool (*)(std::string&, Ogre::MaterialScriptContext&), std::less<std::string>, std::allocator<std::pair<std::string const, bool (*)(std::string&, Ogre::MaterialScriptContext&)> > >'
8089
ct = declarations.find_container_traits( x )

0 commit comments

Comments
 (0)