Skip to content

Commit

Permalink
Fix smart_pointer_traits.value_type method
Browse files Browse the repository at this point in the history
and add tests for smart_pointer_traits.value_type and auto_pointer_traits.value_type
  • Loading branch information
iMichka committed Aug 13, 2017
1 parent 3e73d65 commit 6a0bf82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pygccxml/declarations/smart_pointer_traits.py
Expand Up @@ -18,7 +18,7 @@ class internal_type_traits(object):
@staticmethod
def get_by_name(type_, name):
if class_traits.is_my_case(type_):
cls = class_traits.declaration_class(type_)
cls = class_traits.get_declaration(type_)
return type_traits.remove_declarated(
cls.typedef(name, recursive=False).decl_type)
elif class_declaration_traits.is_my_case(type_):
Expand Down Expand Up @@ -72,7 +72,7 @@ def value_type(type_):
'Type "%s" is not an instantiation of \
boost::shared_ptr or std::shared_ptr' %
type_.decl_string)
return internal_type_traits.get_by_name(type_, "value_type")
return internal_type_traits.get_by_name(type_, "element_type")


class auto_ptr_traits(object):
Expand Down
28 changes: 28 additions & 0 deletions unittests/test_smart_pointer.py
Expand Up @@ -76,6 +76,34 @@ def test_is_auto_pointer(self):
self.assertFalse(
declarations.auto_ptr_traits.is_smart_pointer(decls[0].decl_type))

def test_smart_pointer_value_type(self):
"""
Test smart_pointer_traits.value_type method.
"""

if self.config.xml_generator == "gccxml":
return

criteria = declarations.declaration_matcher(name="yes1")
decls = declarations.matcher.find(criteria, self.global_ns)
vt = declarations.smart_pointer_traits.value_type(decls[0].decl_type)
self.assertIsInstance(vt, declarations.int_t)

def test_auto_pointer_value_type(self):
"""
Test auto_pointer_traits.value_type method.
"""

if self.config.xml_generator == "gccxml":
return

criteria = declarations.declaration_matcher(name="yes2")
decls = declarations.matcher.find(criteria, self.global_ns)
vt = declarations.auto_ptr_traits.value_type(decls[0].decl_type)
self.assertIsInstance(vt, declarations.double_t)


def create_suite():
suite = unittest.TestSuite()
Expand Down

0 comments on commit 6a0bf82

Please sign in to comment.