[pypy-svn] r52829 - pypy/dist/pypy/lib/app_test/ctypes
pedronis at codespeak.net
pedronis at codespeak.net
Sat Mar 22 15:45:14 CET 2008
Author: pedronis
Date: Sat Mar 22 15:45:13 2008
New Revision: 52829
Modified:
pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py
Log:
callback stuff that ought to work and exist somewhere else as a test in limbo
Modified: pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py (original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py Sat Mar 22 15:45:13 2008
@@ -161,3 +161,34 @@
proto = CFUNCTYPE(RECT, c_int)
raises(TypeError, proto, lambda r: 0)
+
+
+ def test_qsort(self):
+ py.test.skip("WIP")
+ import conftest
+ _ctypes_test = str(conftest.sofile)
+ dll = CDLL(_ctypes_test)
+
+ PI = POINTER(c_int)
+ A = c_int*5
+ a = A()
+ for i in range(5):
+ a[i] = 5-i
+
+ assert a[0] == 5 # sanity
+
+ def comp(a, b):
+ print a,b
+ a = a.contents.value
+ b = b.contents.value
+ return cmp(a,b)
+ qs = dll.my_qsort
+ qs.restype = None
+ CMP = CFUNCTYPE(c_int, PI, PI)
+ qs.argtypes = (PI, c_size_t, c_size_t, CMP)
+
+ qs(cast(a, PI), 5, sizeof(c_int), CMP(comp))
+
+ res = list(a)
+
+ assert res == [1,2,3,4,5]
More information about the Pypy-commit
mailing list