Skip to content

Commit b08713f

Browse files
committed
Add test of null shared pointers emitted from C++
This tests nulls emitted as pointers and values of shared pointers, created from null, from references, and from default constructors.
1 parent 01995ec commit b08713f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Examples/test-suite/li_boost_shared_ptr.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ std::string nullsmartpointerpointertest(SwigBoost::shared_ptr<Klass>* k) {
242242
else
243243
return "also not null";
244244
}
245+
246+
SwigBoost::shared_ptr<Klass>* sp_pointer_null() { return NULL; }
247+
SwigBoost::shared_ptr<Klass>* null_sp_pointer() { static SwigBoost::shared_ptr<Klass> static_sp; return &static_sp; }
248+
SwigBoost::shared_ptr<Klass> sp_value_null() { return SwigBoost::shared_ptr<Klass>(); }
245249
// $owner
246250
Klass *pointerownertest() {
247251
return new Klass("pointerownertest");

Examples/test-suite/python/li_boost_shared_ptr_runme.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ def runtest(self):
168168
except ValueError:
169169
pass
170170

171+
# test null pointers emitted from C++
172+
k = li_boost_shared_ptr.sp_pointer_null()
173+
if (li_boost_shared_ptr.smartpointertest(k) != None):
174+
raise RuntimeError("return was not null")
175+
176+
k = li_boost_shared_ptr.null_sp_pointer()
177+
if (li_boost_shared_ptr.smartpointertest(k) != None):
178+
raise RuntimeError("return was not null")
179+
180+
k = li_boost_shared_ptr.sp_value_null()
181+
if (li_boost_shared_ptr.smartpointertest(k) != None):
182+
raise RuntimeError("return was not null")
183+
171184
# $owner
172185
k = li_boost_shared_ptr.pointerownertest()
173186
val = k.getValue()

0 commit comments

Comments
 (0)