From: Robert Bradshaw Date: Fri, 19 Feb 2010 20:00:56 +0000 (-0800) Subject: More complicated template tests. X-Git-Tag: 0.13.beta0~343 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b3ebcbb8ad74a538170c37f8b68f55df1a197c2a;p=cython.git More complicated template tests. --- 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