add inplace test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5857 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b0ca61077e
commit
74eb5b7dc3
3 changed files with 50 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ CPP_TEST_CASES += \
|
||||||
complextest \
|
complextest \
|
||||||
director_stl \
|
director_stl \
|
||||||
implicittest \
|
implicittest \
|
||||||
|
inplaceadd \
|
||||||
lib_std_vectora \
|
lib_std_vectora \
|
||||||
lib_std_map \
|
lib_std_map \
|
||||||
lib_std_wstring \
|
lib_std_wstring \
|
||||||
|
|
|
||||||
31
SWIG/Examples/test-suite/python/inplaceadd.i
Normal file
31
SWIG/Examples/test-suite/python/inplaceadd.i
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
%module inplaceadd
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
int val;
|
||||||
|
|
||||||
|
A(int v): val(v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
A& operator+=(int v)
|
||||||
|
{
|
||||||
|
val += v;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
A& operator-=(int v)
|
||||||
|
{
|
||||||
|
val -= v;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
A& operator*=(int v)
|
||||||
|
{
|
||||||
|
val *= v;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
%}
|
||||||
18
SWIG/Examples/test-suite/python/inplaceadd_runme.py
Normal file
18
SWIG/Examples/test-suite/python/inplaceadd_runme.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import inplaceadd
|
||||||
|
a = inplaceadd.A(7)
|
||||||
|
|
||||||
|
a += 5
|
||||||
|
if a.val != 12:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if a.thisown != 1:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
a -= 5
|
||||||
|
if a.val != 7:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
a *= 2
|
||||||
|
|
||||||
|
if a.val != 14:
|
||||||
|
raise RuntimeError
|
||||||
Loading…
Add table
Add a link
Reference in a new issue