Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boost/printers.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def to_string(self):

def children(self):
if self.value['px'] != 0:
yield 'value', self.value['px'].dereference()
yield 'value', self.value['px'].cast(self.value['px'].dynamic_type).dereference()


@add_printer
Expand Down
13 changes: 11 additions & 2 deletions tests/testsuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,20 @@ void test_intrusive_ptr()
struct S: public boost::intrusive_ref_counter<S>
{
int i;
virtual ~S() = default;
};

struct T: public S
{
int j;
};

boost::intrusive_ptr<S> intrusive_empty;
boost::intrusive_ptr<S> intrusive(new S);
intrusive->i = 42;
boost::intrusive_ptr<S> intrusive_base(new S);
boost::intrusive_ptr<S> intrusive_derived(new T);
intrusive_base->i = 42;
intrusive_derived->i = 6;
static_cast<T*>(intrusive_derived.get())->j = 9;
#endif
break_here:
dummy_function();
Expand Down
12 changes: 10 additions & 2 deletions tests/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,22 @@ def test_intrusive_empty(self):
self.assertEqual(children, [])
self.assertIsNone(display_hint)

def test_intrusive(self):
string, children, display_hint = self.get_printer_result('intrusive')
def test_intrusive_base(self):
string, children, display_hint = self.get_printer_result('intrusive_base')
self.assertNotEqual(string, 'uninitialized')
children_as_struct = as_struct(children)
self.assertEqual(set(children_as_struct), {'value'})
self.assertEqual(children_as_struct['value']['i'], 42)
self.assertIsNone(display_hint)

def test_intrusive_derived(self):
string, children, display_hint = self.get_printer_result('intrusive_derived')
self.assertNotEqual(string, 'uninitialized')
children_as_struct = as_struct(children)
self.assertEqual(set(children_as_struct), {'value'})
self.assertEqual(children_as_struct['value']['j'], 9)
self.assertIsNone(display_hint)


class SharedPtrTest(PrettyPrinterTest):
"""Test for shared_ptr, shared_array and weak_ptr"""
Expand Down