Commit b3ebcbb8 authored by Robert Bradshaw's avatar Robert Bradshaw

More complicated template tests.

parent 15577be1
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment