diff options
author | Vladimir Matveev <v2matveev@outlook.com> | 2018-09-16 05:36:29 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-09-16 05:36:29 (GMT) |
commit | 7843caeb909bd907e903606414e238db4082315a (patch) | |
tree | 92d45753687dc2e26bea648ce2ba045e4e8e6c4a /Lib/ctypes/test | |
parent | 10a428b64b3f224e2ccd40ff2afb141b9b3425b1 (diff) | |
download | cpython-7843caeb909bd907e903606414e238db4082315a.zip cpython-7843caeb909bd907e903606414e238db4082315a.tar.gz cpython-7843caeb909bd907e903606414e238db4082315a.tar.bz2 |
bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258)
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_win32.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py index 5d85ad6..ee72270 100644 --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -55,6 +55,24 @@ class FunctionCallTestCase(unittest.TestCase): @unittest.skipUnless(sys.platform == "win32", 'Windows-specific test') +class ReturnStructSizesTestCase(unittest.TestCase): + def test_sizes(self): + dll = CDLL(_ctypes_test.__file__) + for i in range(1, 11): + fields = [ (f"f{f}", c_char) for f in range(1, i + 1)] + class S(Structure): + _fields_ = fields + f = getattr(dll, f"TestSize{i}") + f.restype = S + res = f() + for i, f in enumerate(fields): + value = getattr(res, f[0]) + expected = bytes([ord('a') + i]) + self.assertEquals(value, expected) + + + +@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test') class TestWintypes(unittest.TestCase): def test_HWND(self): from ctypes import wintypes |