Skip to content

Commit 9f5f619

Browse files
author
roman_yakovenko
committed
adding new test case
1 parent 0da2831 commit 9f5f619

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

pygccxml/declarations/type_traits.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ def get_declaration( self, type_ ):
331331
332332
Precondition: self.is_my_case( type ) == True
333333
"""
334-
assert self.is_my_case( type_ )
335334
return self.__apply_sequence( type_ )
336335

337336
enum_traits = declaration_xxx_traits( enumeration.enumeration_t )

unittests/type_traits_tester.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,48 @@ def test( self ):
271271
#~ declarations.print_declarations( [declarations.class_traits.get_declaration( x )] )
272272

273273

274+
class class_traits_tester_t(unittest.TestCase):
275+
def __init__(self, *args ):
276+
unittest.TestCase.__init__(self, *args)
277+
278+
def test(self):
279+
code = """
280+
namespace A{
281+
struct B{
282+
int c;
283+
};
284+
285+
template <class T>
286+
struct C: public T{
287+
int d;
288+
};
289+
290+
template <class T>
291+
struct D{
292+
int dD;
293+
};
294+
295+
typedef C<B> easy;
296+
typedef D<easy> Deasy;
297+
298+
inline void instantiate(){
299+
sizeof(easy);
300+
}
301+
302+
}
303+
"""
304+
305+
global_ns = parser.parse_string( code, autoconfig.cxx_parsers_cfg.gccxml)
306+
global_ns = declarations.get_global_namespace( global_ns )
307+
easy = global_ns.typedef( 'easy' )
308+
c_a = declarations.class_traits.get_declaration( easy ) #this works very well
309+
deasy = global_ns.typedef( 'Deasy' )
310+
d_a = declarations.class_traits.get_declaration( deasy )
311+
self.failUnless( isinstance( d_a, declarations.class_types ) )
312+
274313
def create_suite():
275314
suite = unittest.TestSuite()
276-
#~ suite.addTest( unittest.makeSuite(tester_diff_t))
315+
suite.addTest( unittest.makeSuite(class_traits_tester_t))
277316
suite.addTest( unittest.makeSuite(tester_t))
278317
suite.addTest( unittest.makeSuite(missing_decls_tester_t))
279318
return suite

0 commit comments

Comments
 (0)