summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/test_arrays.py2
-rw-r--r--Lib/ctypes/test/test_callbacks.py4
-rw-r--r--Lib/ctypes/test/test_cfuncs.py12
-rw-r--r--Lib/ctypes/test/test_functions.py12
-rw-r--r--Lib/ctypes/test/test_repr.py2
5 files changed, 30 insertions, 2 deletions
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index f487013..f8bce5a 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -4,7 +4,7 @@ from ctypes import *
formats = "bBhHiIlLqQfd"
formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
- c_long, c_ulonglong, c_float, c_double
+ c_long, c_ulonglong, c_float, c_double, c_longdouble
class ArrayTestCase(unittest.TestCase):
def test_simple(self):
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index 9b2ea8c..d870eb4 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -77,6 +77,10 @@ class Callbacks(unittest.TestCase):
self.check_type(c_double, 3.14)
self.check_type(c_double, -3.14)
+ def test_longdouble(self):
+ self.check_type(c_longdouble, 3.14)
+ self.check_type(c_longdouble, -3.14)
+
def test_char(self):
self.check_type(c_char, b"x")
self.check_type(c_char, b"a")
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index 63564a8..8f97fc4 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -158,6 +158,18 @@ class CFunctions(unittest.TestCase):
self.failUnlessEqual(self._dll.tf_bd(0, 42.), 14.)
self.failUnlessEqual(self.S(), 42)
+ def test_longdouble(self):
+ self._dll.tf_D.restype = c_longdouble
+ self._dll.tf_D.argtypes = (c_longdouble,)
+ self.failUnlessEqual(self._dll.tf_D(42.), 14.)
+ self.failUnlessEqual(self.S(), 42)
+
+ def test_longdouble_plus(self):
+ self._dll.tf_bD.restype = c_longdouble
+ self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
+ self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
+ self.failUnlessEqual(self.S(), 42)
+
def test_callwithresult(self):
def process_result(result):
return result * 2
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index d7a3edf..3af11cc 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -143,6 +143,18 @@ class FunctionTestCase(unittest.TestCase):
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
+ def test_longdoubleresult(self):
+ f = dll._testfunc_D_bhilfD
+ f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
+ f.restype = c_longdouble
+ result = f(1, 2, 3, 4, 5.0, 6.0)
+ self.failUnlessEqual(result, 21)
+ self.failUnlessEqual(type(result), float)
+
+ result = f(-1, -2, -3, -4, -5.0, -6.0)
+ self.failUnlessEqual(result, -21)
+ self.failUnlessEqual(type(result), float)
+
def test_longlongresult(self):
try:
c_longlong
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/ctypes/test/test_repr.py
index 8e69444..3f1e819 100644
--- a/Lib/ctypes/test/test_repr.py
+++ b/Lib/ctypes/test/test_repr.py
@@ -4,7 +4,7 @@ import unittest
subclasses = []
for base in [c_byte, c_short, c_int, c_long, c_longlong,
c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
- c_float, c_double, c_bool]:
+ c_float, c_double, c_longdouble, c_bool]:
class X(base):
pass
subclasses.append(X)