From b08713f09f0e1b041f8f3e8493d06fdb99cbf47d Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Sat, 12 Feb 2022 19:39:35 -0500 Subject: [PATCH] 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. --- Examples/test-suite/li_boost_shared_ptr.i | 4 ++++ .../test-suite/python/li_boost_shared_ptr_runme.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index b64197be1..001eacb78 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -242,6 +242,10 @@ std::string nullsmartpointerpointertest(SwigBoost::shared_ptr* k) { else return "also not null"; } + +SwigBoost::shared_ptr* sp_pointer_null() { return NULL; } +SwigBoost::shared_ptr* null_sp_pointer() { static SwigBoost::shared_ptr static_sp; return &static_sp; } +SwigBoost::shared_ptr sp_value_null() { return SwigBoost::shared_ptr(); } // $owner Klass *pointerownertest() { return new Klass("pointerownertest"); diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index 2e241d590..bde79fd61 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -168,6 +168,19 @@ class li_boost_shared_ptr_runme: except ValueError: pass + # test null pointers emitted from C++ + k = li_boost_shared_ptr.sp_pointer_null() + if (li_boost_shared_ptr.smartpointertest(k) != None): + raise RuntimeError("return was not null") + + k = li_boost_shared_ptr.null_sp_pointer() + if (li_boost_shared_ptr.smartpointertest(k) != None): + raise RuntimeError("return was not null") + + k = li_boost_shared_ptr.sp_value_null() + if (li_boost_shared_ptr.smartpointertest(k) != None): + raise RuntimeError("return was not null") + # $owner k = li_boost_shared_ptr.pointerownertest() val = k.getValue()