summaryrefslogtreecommitdiff
path: root/Examples/test-suite/python
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/python')
-rw-r--r--Examples/test-suite/python/Makefile.in2
-rw-r--r--Examples/test-suite/python/char_binary_runme.py36
-rw-r--r--Examples/test-suite/python/director_alternating_runme.py5
-rw-r--r--Examples/test-suite/python/director_protected_runme.py43
-rw-r--r--Examples/test-suite/python/global_namespace_runme.py40
-rw-r--r--Examples/test-suite/python/pointer_reference_runme.py16
-rw-r--r--Examples/test-suite/python/preproc_defined_runme.py11
-rw-r--r--Examples/test-suite/python/preproc_include_runme.py11
-rw-r--r--Examples/test-suite/python/primitive_types_runme.py11
-rw-r--r--Examples/test-suite/python/rename_pcre_encoder_runme.py13
-rw-r--r--Examples/test-suite/python/smart_pointer_const_overload_runme.py123
-rw-r--r--Examples/test-suite/python/typemap_arrays_runme.py5
12 files changed, 303 insertions, 13 deletions
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 4938ddc27..a05542b70 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -117,7 +117,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
-run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
new file mode 100644
index 000000000..b6d9c81c8
--- /dev/null
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -0,0 +1,36 @@
+from char_binary import *
+
+t = Test()
+if t.strlen('hile') != 4:
+ print t.strlen('hile')
+ raise RuntimeError, "bad multi-arg typemap"
+
+if t.strlen('hil\0') != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+
+if t.strlen(pc) != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+cvar.var_pchar = pc
+if cvar.var_pchar != "hola":
+ print cvar.var_pchar
+ raise RuntimeError, "bad pointer case"
+
+cvar.var_namet = pc
+#if cvar.var_namet != "hola\0":
+if cvar.var_namet != "hola":
+ raise RuntimeError, "bad pointer case"
+
+delete_pchar(pc)
+
diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py
new file mode 100644
index 000000000..a92ae1c5c
--- /dev/null
+++ b/Examples/test-suite/python/director_alternating_runme.py
@@ -0,0 +1,5 @@
+from director_alternating import *
+
+id = getBar().id()
+if id != idFromGetBar():
+ raise RuntimeError, "Got wrong id: " + str(id)
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index 9d565a1b4..fd3c868a1 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
+class FooBar3(Bar):
+ def cheer(self):
+ return "FooBar3::cheer();"
+
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
+fb3 = FooBar3()
try:
@@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError,"Boo::ping is protected"
+ raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
+
+
+protected=1
+try:
+ b.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Bar::cheer is protected"
+
+protected=1
+try:
+ f.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Foo::cheer is protected"
+
+if fb3.cheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3::cheer"
+
+if fb2.callping() != "FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callping"
+
+if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callcheer"
+
+if fb3.callping() != "Bar::ping();":
+ raise RuntimeError, "bad fb3.callping"
+
+if fb3.callcheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3.callcheer"
+
+
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
new file mode 100644
index 000000000..b64e75ca1
--- /dev/null
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -0,0 +1,40 @@
+from global_namespace import *
+
+k1 = Klass1()
+k2 = Klass2()
+k3 = Klass3()
+k4 = Klass4()
+k5 = Klass5()
+k6 = Klass6()
+k7 = Klass7()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1A()
+k2 = getKlass2A()
+k3 = getKlass3A()
+k4 = getKlass4A()
+k5 = getKlass5A()
+k6 = getKlass6A()
+k7 = getKlass7A()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1B()
+k2 = getKlass2B()
+k3 = getKlass3B()
+k4 = getKlass4B()
+k5 = getKlass5B()
+k6 = getKlass6B()
+k7 = getKlass7B()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py
new file mode 100644
index 000000000..e1a1a1f4b
--- /dev/null
+++ b/Examples/test-suite/python/pointer_reference_runme.py
@@ -0,0 +1,16 @@
+import pointer_reference
+
+s = pointer_reference.get()
+if s.value != 10:
+ raise RuntimeError, "get test failed"
+
+ss = pointer_reference.Struct(20)
+pointer_reference.set(ss)
+if pointer_reference.cvar.Struct_instance.value != 20:
+ raise RuntimeError, "set test failed"
+
+if pointer_reference.overloading(1) != 111:
+ raise RuntimeError, "overload test 1 failed"
+
+if pointer_reference.overloading(ss) != 222:
+ raise RuntimeError, "overload test 2 failed"
diff --git a/Examples/test-suite/python/preproc_defined_runme.py b/Examples/test-suite/python/preproc_defined_runme.py
new file mode 100644
index 000000000..9a295533a
--- /dev/null
+++ b/Examples/test-suite/python/preproc_defined_runme.py
@@ -0,0 +1,11 @@
+import preproc_defined
+
+if preproc_defined.call_checking() != 1:
+ raise RuntimeError
+
+d = preproc_defined.Defined()
+d.defined = 10
+
+preproc_defined.thing(10)
+preproc_defined.stuff(10)
+preproc_defined.bumpf(10)
diff --git a/Examples/test-suite/python/preproc_include_runme.py b/Examples/test-suite/python/preproc_include_runme.py
new file mode 100644
index 000000000..e15606581
--- /dev/null
+++ b/Examples/test-suite/python/preproc_include_runme.py
@@ -0,0 +1,11 @@
+import preproc_include
+
+if preproc_include.multiply10(10) != 100:
+ raise RuntimeError
+
+if preproc_include.multiply20(10) != 200:
+ raise RuntimeError
+
+if preproc_include.multiply30(10) != 300:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index 02cc21763..2495cd60d 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -188,14 +188,6 @@ if t.var_namet != 'hol':
raise RuntimeError
-if t.strlen('hile') != 4:
- print t.strlen('hile')
- raise RuntimeError, "bad string typemap"
-
-if t.strlen('hil\0') != 4:
- raise RuntimeError, "bad string typemap"
-
-
cvar.var_char = '\0'
if cvar.var_char != '\0':
raise RuntimeError, "bad char '0' case"
@@ -244,9 +236,6 @@ pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
-if t.strlen(pc) != 4:
- raise RuntimeError, "bad string typemap"
-
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py
new file mode 100644
index 000000000..1186703a0
--- /dev/null
+++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py
@@ -0,0 +1,13 @@
+from rename_pcre_encoder import *
+
+s = SomeWidget()
+s.putBorderWidth(3)
+if s.getBorderWidth() != 3:
+ raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),))
+
+s.putSize(4, 5)
+a = AnotherWidget()
+a.DoSomething()
+
+evt = wxEVTSomeEvent()
+t = xUnchangedName()
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
new file mode 100644
index 000000000..f1be315a5
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -0,0 +1,123 @@
+from smart_pointer_const_overload import *
+
+CONST_ACCESS = 1
+MUTABLE_ACCESS = 2
+
+def test(b, f):
+ if f.x != 0:
+ raise RuntimeError
+
+ # Test member variable get
+ if b.x != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test member variable set
+ b.x = 1
+
+ if f.x != 1:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test const method
+ if b.getx() != 1:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test mutable method
+ b.setx(2)
+
+ if f.x != 2:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test extended const method
+ if b.getx2() != 2:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test extended mutable method
+ b.setx2(3)
+
+ if f.x != 3:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test static method
+ b.stat()
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test const member
+ f.access = MUTABLE_ACCESS
+
+ if b.y != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through mutable pointer to const member
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.yp) != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through const pointer to mutable member
+ f.x = 4
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.xp) != 4:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set through const pointer to mutable member
+ f.access = MUTABLE_ACCESS
+ set_int(b.xp, 5)
+
+ if f.x != 5:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set pointer to const member
+ b.yp = new_int(6)
+
+ if f.y != 0:
+ raise RuntimeError
+
+ if get_int(f.yp) != 6:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ delete_int(f.yp);
+
+f = Foo()
+b = Bar(f)
+
+f2 = Foo()
+b2 = Bar2(f2)
+
+test(b, f)
+test(b2, f2)
diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py
new file mode 100644
index 000000000..c23222c63
--- /dev/null
+++ b/Examples/test-suite/python/typemap_arrays_runme.py
@@ -0,0 +1,5 @@
+from typemap_arrays import *
+
+if sumA(None) != 60:
+ raise RuntimeError, "Sum is wrong"
+