Test ability to manipulate a daughter class from its base class wrapper
Even in the case of just creating a `DerivedClass` this test says: ``` swig/python detected a memory leak of type 'DerivedClass *', no destructor found. ``` even though the destructor is defined in the base class.
This commit is contained in:
parent
fb0cddfd2b
commit
0da8a9bb44
3 changed files with 36 additions and 0 deletions
20
Examples/test-suite/abstract_basecast.i
Normal file
20
Examples/test-suite/abstract_basecast.i
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
%module abstract_basecast
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
class BaseClass {
|
||||||
|
public:
|
||||||
|
virtual ~BaseClass() { }
|
||||||
|
|
||||||
|
virtual void g() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DerivedClass : public BaseClass {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void g() { }
|
||||||
|
|
||||||
|
BaseClass& f() {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
@ -102,6 +102,7 @@ C_TEST_BROKEN += \
|
||||||
# C++ test cases. (Can be run individually using: make testcase.cpptest)
|
# C++ test cases. (Can be run individually using: make testcase.cpptest)
|
||||||
CPP_TEST_CASES += \
|
CPP_TEST_CASES += \
|
||||||
abstract_access \
|
abstract_access \
|
||||||
|
abstract_basecast \
|
||||||
abstract_inherit \
|
abstract_inherit \
|
||||||
abstract_inherit_ok \
|
abstract_inherit_ok \
|
||||||
abstract_signature \
|
abstract_signature \
|
||||||
|
|
|
||||||
15
Examples/test-suite/python/abstract_basecast_runme.py
Normal file
15
Examples/test-suite/python/abstract_basecast_runme.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from abstract_basecast import *
|
||||||
|
|
||||||
|
def check(flag):
|
||||||
|
if not flag:
|
||||||
|
raise RuntimeError("Test failed")
|
||||||
|
|
||||||
|
derived = DerivedClass()
|
||||||
|
derived.g()
|
||||||
|
check(isinstance(derived, BaseClass))
|
||||||
|
check(isinstance(derived, DerivedClass))
|
||||||
|
|
||||||
|
base = derived.f()
|
||||||
|
base.g()
|
||||||
|
check(isinstance(base, BaseClass))
|
||||||
|
check(not isinstance(base, DerivedClass))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue