aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/libsample/functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/tests/libsample/functions.cpp')
-rw-r--r--sources/shiboken2/tests/libsample/functions.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/libsample/functions.cpp b/sources/shiboken2/tests/libsample/functions.cpp
index 4a15cdae8..bf73d5ed7 100644
--- a/sources/shiboken2/tests/libsample/functions.cpp
+++ b/sources/shiboken2/tests/libsample/functions.cpp
@@ -28,7 +28,9 @@
#include "functions.h"
#include <string.h>
+#include <algorithm>
#include <iostream>
+#include <numeric>
using namespace std;
@@ -197,6 +199,45 @@ acceptOddBoolReference(OddBool& x)
return x;
}
+int sumIntArray(int array[4])
+{
+ return std::accumulate(array, array + 4, 0);
+}
+
+double sumDoubleArray(double array[4])
+{
+ return std::accumulate(array, array + 4, double(0));
+}
+
+int sumIntMatrix(int m[2][3])
+{
+ int result = 0;
+ for (int r = 0; r < 2; ++r) {
+ for (int c = 0; c < 3; ++c)
+ result += m[r][c];
+ }
+ return result;
+}
+
+double sumDoubleMatrix(double m[2][3])
+{
+ double result = 0;
+ for (int r = 0; r < 2; ++r) {
+ for (int c = 0; c < 3; ++c)
+ result += m[r][c];
+ }
+ return result;
+}
+
+ArrayModifyTest::ArrayModifyTest()
+{
+}
+
+int ArrayModifyTest::sumIntArray(int n, int *array)
+{
+ return std::accumulate(array, array + n, 0);
+}
+
ClassWithFunctionPointer::ClassWithFunctionPointer()
{
callFunctionPointer(0, &ClassWithFunctionPointer::doNothing);