summaryrefslogtreecommitdiff
path: root/tests/run/cpp_stl_numeric_ops_cpp20.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/cpp_stl_numeric_ops_cpp20.pyx')
-rw-r--r--tests/run/cpp_stl_numeric_ops_cpp20.pyx23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/run/cpp_stl_numeric_ops_cpp20.pyx b/tests/run/cpp_stl_numeric_ops_cpp20.pyx
new file mode 100644
index 000000000..e3a8c01df
--- /dev/null
+++ b/tests/run/cpp_stl_numeric_ops_cpp20.pyx
@@ -0,0 +1,23 @@
+# mode: run
+# tag: cpp, werror, cpp20
+
+from libcpp.numeric cimport midpoint
+
+def test_midpoint_integer(int a, int b):
+ """
+ Test midpoint for integer types
+ >>> test_midpoint_integer(2, 6)
+ 4
+ """
+ cdef int res = midpoint[int](a, b)
+ return res
+
+
+def test_midpoint_float(float a, float b):
+ """
+ Test midpoint for float
+ >>> test_midpoint_float(2, 6)
+ 4.0
+ """
+ cdef float res = midpoint[float](a, b)
+ return res