summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/cpp11_std_array.i10
-rw-r--r--Examples/test-suite/li_std_carray.i8
-rw-r--r--Examples/test-suite/octave/li_std_carray_runme.m52
-rw-r--r--Examples/test-suite/python/Makefile.in1
-rw-r--r--Examples/test-suite/python/cpp11_std_array_runme.py26
-rw-r--r--Examples/test-suite/python/li_std_carray_runme.py39
-rw-r--r--Examples/test-suite/python/li_std_containers_int_runme.py6
-rw-r--r--Examples/test-suite/python/li_std_set_runme.py10
8 files changed, 52 insertions, 100 deletions
diff --git a/Examples/test-suite/cpp11_std_array.i b/Examples/test-suite/cpp11_std_array.i
index 9dc11ce9e..ce87db75a 100644
--- a/Examples/test-suite/cpp11_std_array.i
+++ b/Examples/test-suite/cpp11_std_array.i
@@ -57,6 +57,16 @@ void arrayInPtr(std::array<int, 6> * myarray) {
val *= 10;
}
}
+
+std::array<int, 6> overloadFunc(std::array<int, 6> myarray) {
+ std::array<int, 6> newarray(myarray);
+ for (auto& val : newarray) {
+ val *= 100;
+ }
+ return newarray;
+}
+void overloadFunc(int i, int j) {
+}
%}
#endif
diff --git a/Examples/test-suite/li_std_carray.i b/Examples/test-suite/li_std_carray.i
deleted file mode 100644
index b38e0e441..000000000
--- a/Examples/test-suite/li_std_carray.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module li_std_carray
-
-%include <std_carray.i>
-
-%template(Vector3) std::carray<double, 3>;
-
-%template(Matrix3) std::carray<std::carray<double, 3>, 3>;
-
diff --git a/Examples/test-suite/octave/li_std_carray_runme.m b/Examples/test-suite/octave/li_std_carray_runme.m
deleted file mode 100644
index f7212dc9a..000000000
--- a/Examples/test-suite/octave/li_std_carray_runme.m
+++ /dev/null
@@ -1,52 +0,0 @@
-li_std_carray
-
-
-v3 = Vector3();
-for i=0:len(v3),
- v3(i) = i;
-endfor
-
-i = 0;
-for d in v3,
- if (d != i)
- error("failed");
- endif
- i = i + 1;
-endfor
-
-
-m3 = Matrix3();
-
-for i=0:len(m3),
- v3 = m3(i);
- for j=0:len(v3),
- v3(j) = i + j;
- endfor
-endfor
-
-i = 0;
-for v3 in m3,
- j = 0;
- for d in v3,
- if (d != i + j)
- error("failed");
- endif
- j = j + 1;
- endfor
- i = i + 1
-endfor
-
-for i=0:len(m3),
- for j=0:len(m3),
- if (m3(i,j) != i + j)
- error("failed");
- endif
- endfor
-endfor
-
-da = Vector3([1,2,3]);
-ma = Matrix3({[1,2,3],[4,5,6],[7,8,9]});
-
-
-
-
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index baa89859a..46e23dbe5 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -73,7 +73,6 @@ CPP_TEST_CASES += \
swigobject \
template_matrix \
-# li_std_carray
# director_profile
CPP11_TEST_CASES = \
diff --git a/Examples/test-suite/python/cpp11_std_array_runme.py b/Examples/test-suite/python/cpp11_std_array_runme.py
index 9e11a3e5b..dbf9bcee3 100644
--- a/Examples/test-suite/python/cpp11_std_array_runme.py
+++ b/Examples/test-suite/python/cpp11_std_array_runme.py
@@ -56,6 +56,14 @@ def setslice_exception(swigarray, newval):
# print("exception: {}".format(e))
pass
+def overload_type_exception(pythonlist):
+ try:
+ overloadFunc(pythonlist)
+ raise RuntimeError("overloadFunc({}) missed raising TypeError exception".format(pythonlist))
+ except TypeError as e:
+# print("exception: {}".format(e))
+ pass
+
# Check std::array has similar behaviour to a Python list
# except it is not resizable
@@ -161,3 +169,21 @@ compare_containers(ai, [90, 80, 70, 60, 50, 40])
# fill
ai.fill(111)
compare_containers(ai, [111, 111, 111, 111, 111, 111])
+
+# Overloading
+newarray = overloadFunc([9, 8, 7, 6, 5, 4])
+compare_containers(newarray, [900, 800, 700, 600, 500, 400])
+
+ai = ArrayInt6([9, 8, 7, 6, 5, 4])
+newarray = overloadFunc([9, 8, 7, 6, 5, 4])
+compare_containers(newarray, [900, 800, 700, 600, 500, 400])
+
+overloadFunc(1, 2)
+overload_type_exception([1, 2, 3, 4, 5, "6"])
+overload_type_exception([1, 2, 3, 4, 5])
+overload_type_exception([1, 2, 3, 4, 5, 6, 7])
+
+# Construct from Python set
+myset = {11, 12, 13, 14, 15, 16}
+ai = ArrayInt6(myset)
+compare_containers(ai, list(myset))
diff --git a/Examples/test-suite/python/li_std_carray_runme.py b/Examples/test-suite/python/li_std_carray_runme.py
deleted file mode 100644
index 36eeaf173..000000000
--- a/Examples/test-suite/python/li_std_carray_runme.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from li_std_carray import *
-
-
-v3 = Vector3()
-for i in range(0, len(v3)):
- v3[i] = i
-
-i = 0
-for d in v3:
- if d != i:
- raise RuntimeError
- i = i + 1
-
-
-m3 = Matrix3()
-
-for i in range(0, len(m3)):
- v3 = m3[i]
- for j in range(0, len(v3)):
- v3[j] = i + j
-
-i = 0
-for v3 in m3:
- j = 0
- for d in v3:
- if d != i + j:
- raise RuntimeError
- j = j + 1
- pass
- i = i + 1
- pass
-
-for i in range(0, len(m3)):
- for j in range(0, len(m3)):
- if m3[i][j] != i + j:
- raise RuntimeError
-
-da = Vector3((1, 2, 3))
-ma = Matrix3(((1, 2, 3), (4, 5, 6), (7, 8, 9)))
diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py
index f346de220..13c76d3aa 100644
--- a/Examples/test-suite/python/li_std_containers_int_runme.py
+++ b/Examples/test-suite/python/li_std_containers_int_runme.py
@@ -279,3 +279,9 @@ try:
raise RuntimeError("Zero step not caught")
except ValueError:
pass
+
+# Construct from set (Iterator protocol, not Sequence protocol)
+ps = {11, 22, 33}
+iv = vector_int(ps)
+il = vector_int(ps)
+compare_containers(list(ps), iv, il)
diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py
index 34a1eb19c..7618f7dc8 100644
--- a/Examples/test-suite/python/li_std_set_runme.py
+++ b/Examples/test-suite/python/li_std_set_runme.py
@@ -92,3 +92,13 @@ for i in s:
if (len(sum) != 3 or (not 1 in sum) or (not "hello" in sum) or (not (1, 2) in sum)):
raise RuntimeError
+
+# Create from Python set
+s = set_string({"x", "y", "z"})
+sum = ""
+for i in s:
+ sum = sum + i
+
+if sum != "xyz":
+ raise RuntimeError
+