From b3ebcbb8ad74a538170c37f8b68f55df1a197c2a Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 19 Feb 2010 12:00:56 -0800 Subject: [PATCH] More complicated template tests. --- tests/run/cpp_templates.pyx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/run/cpp_templates.pyx b/tests/run/cpp_templates.pyx index 118dfa08..11944a53 100644 --- a/tests/run/cpp_templates.pyx +++ b/tests/run/cpp_templates.pyx @@ -61,4 +61,33 @@ def test_pair(int i, double x): finally: del pair +def test_ptr(int i): + """ + >>> test_ptr(3) + 3 + >>> test_ptr(5) + 5 + """ + cdef Wrap[int*] *w + try: + w = new Wrap[int*](&i) + return deref(w.get()) + finally: + del w + +cdef double f(double x): + return x*x +def test_func_ptr(double x): + """ + >>> test_func_ptr(3) + 9.0 + >>> test_func_ptr(-1.5) + 2.25 + """ + cdef Wrap[double (*)(double)] *w + try: + w = new Wrap[double (*)(double)](&f) + return w.get()(x) + finally: + del w -- 2.26.2