summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2010-06-21 15:01:18 (GMT)
committerThomas Heller <theller@ctypes.org>2010-06-21 15:01:18 (GMT)
commita45e6d5791b6ba845beaa0dde2a297e810982741 (patch)
tree83183176cf4f11b5932996333330c200c1215e0e
parentf180099ec619325d28c6a76a38df5419ef69651e (diff)
downloadcpython-a45e6d5791b6ba845beaa0dde2a297e810982741.zip
cpython-a45e6d5791b6ba845beaa0dde2a297e810982741.tar.gz
cpython-a45e6d5791b6ba845beaa0dde2a297e810982741.tar.bz2
Add tests for problems reported in issue 8959.
-rw-r--r--Lib/ctypes/test/test_callbacks.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index 513a2a0..8e070a5 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -172,6 +172,41 @@ class SampleCallbacksTestCase(unittest.TestCase):
self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
+ def test_issue_8959_a(self):
+ from ctypes.util import find_library
+ libc_path = find_library("c")
+ if not libc_path:
+ return # cannot test
+ libc = CDLL(libc_path)
+
+ @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
+ def cmp_func(a, b):
+ return a[0] - b[0]
+
+ array = (c_int * 5)(5, 1, 99, 7, 33)
+
+ libc.qsort(array, len(array), sizeof(c_int), cmp_func)
+ self.assertEqual(array[:], [1, 5, 7, 33, 99])
+
+ try:
+ WINFUNCTYPE
+ except NameError:
+ pass
+ else:
+ def test_issue_8959_b(self):
+ from ctypes.wintypes import BOOL, HWND, LPARAM
+ global windowCount
+ windowCount = 0
+
+ @WINFUNCTYPE(BOOL, HWND, LPARAM)
+ def EnumWindowsCallbackFunc(hwnd, lParam):
+ global windowCount
+ windowCount += 1
+ return True #Allow windows to keep enumerating
+
+ windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0)
+ self.assertFalse(windowCount == 0)
+
################################################################
if __name__ == '__main__':