@@ -17,40 +17,93 @@ def __init__(self, *args):
1717 parser_test_case .parser_test_case_t .__init__ (self , * args )
1818 self .header = "test_smart_pointer.hpp"
1919 self .config .cflags = "-std=c++11"
20+ self .global_ns = None
2021
21- def test_smart_pointer (self ):
22+ def setUp (self ):
23+ if self .config .xml_generator == "gccxml" :
24+ return
25+ decls = parser .parse ([self .header ], self .config )
26+ self .global_ns = declarations .get_global_namespace (decls )
27+
28+ def test_is_smart_pointer (self ):
2229 """
23- Test code in the smart_pointer_traits module .
30+ Test smart_pointer_traits.is_smart_pointer method .
2431
2532 """
2633
2734 if self .config .xml_generator == "gccxml" :
2835 return
2936
30- decls = parser .parse ([self .header ], self .config )
31- global_ns = declarations .get_global_namespace (decls )
32-
3337 criteria = declarations .declaration_matcher (name = "yes1" )
34- decls = declarations .matcher .find (criteria , global_ns )
38+ decls = declarations .matcher .find (criteria , self . global_ns )
3539 self .assertTrue (
3640 declarations .smart_pointer_traits .is_smart_pointer (
3741 decls [0 ].decl_type ))
3842
43+ criteria = declarations .declaration_matcher (name = "no1" )
44+ decls = declarations .matcher .find (criteria , self .global_ns )
45+ self .assertFalse (
46+ declarations .smart_pointer_traits .is_smart_pointer (
47+ decls [0 ].decl_type ))
48+
49+ criteria = declarations .declaration_matcher (name = "no2" )
50+ decls = declarations .matcher .find (criteria , self .global_ns )
51+ self .assertFalse (
52+ declarations .smart_pointer_traits .is_smart_pointer (
53+ decls [0 ].decl_type ))
54+
55+ def test_is_auto_pointer (self ):
56+ """
57+ Test auto_ptr_traits.is_smart_pointer method.
58+
59+ """
60+
61+ if self .config .xml_generator == "gccxml" :
62+ return
63+
3964 criteria = declarations .declaration_matcher (name = "yes2" )
40- decls = declarations .matcher .find (criteria , global_ns )
65+ decls = declarations .matcher .find (criteria , self . global_ns )
4166 self .assertTrue (
4267 declarations .auto_ptr_traits .is_smart_pointer (decls [0 ].decl_type ))
4368
4469 criteria = declarations .declaration_matcher (name = "no1" )
45- decls = declarations .matcher .find (criteria , global_ns )
70+ decls = declarations .matcher .find (criteria , self . global_ns )
4671 self .assertFalse (
4772 declarations .auto_ptr_traits .is_smart_pointer (decls [0 ].decl_type ))
4873
4974 criteria = declarations .declaration_matcher (name = "no2" )
50- decls = declarations .matcher .find (criteria , global_ns )
75+ decls = declarations .matcher .find (criteria , self . global_ns )
5176 self .assertFalse (
5277 declarations .auto_ptr_traits .is_smart_pointer (decls [0 ].decl_type ))
5378
79+ def test_smart_pointer_value_type (self ):
80+ """
81+ Test smart_pointer_traits.value_type method.
82+
83+ """
84+
85+ if self .config .xml_generator == "gccxml" :
86+ return
87+
88+ criteria = declarations .declaration_matcher (name = "yes1" )
89+ decls = declarations .matcher .find (criteria , self .global_ns )
90+ vt = declarations .smart_pointer_traits .value_type (decls [0 ].decl_type )
91+ self .assertIsInstance (vt , declarations .int_t )
92+
93+ def test_auto_pointer_value_type (self ):
94+ """
95+ Test auto_pointer_traits.value_type method.
96+
97+ """
98+
99+ if self .config .xml_generator == "gccxml" :
100+ return
101+
102+ criteria = declarations .declaration_matcher (name = "yes2" )
103+ decls = declarations .matcher .find (criteria , self .global_ns )
104+ vt = declarations .auto_ptr_traits .value_type (decls [0 ].decl_type )
105+ self .assertIsInstance (vt , declarations .double_t )
106+
54107
55108def create_suite ():
56109 suite = unittest .TestSuite ()
0 commit comments