summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-05-29 19:42:34 (GMT)
committerThomas Heller <theller@ctypes.org>2008-05-29 19:42:34 (GMT)
commit9287acf83df56a11aaa001657df652ed6804b105 (patch)
tree616f535ee369132b23cd26fad0b16a31d1257f5e /Lib/ctypes/test
parenta52b244cc10a7644d86c4f09b761b3611a65378d (diff)
downloadcpython-9287acf83df56a11aaa001657df652ed6804b105.zip
cpython-9287acf83df56a11aaa001657df652ed6804b105.tar.gz
cpython-9287acf83df56a11aaa001657df652ed6804b105.tar.bz2
ctypes NULL function pointers have a boolean False value now.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/test_pointers.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index 586655a..fd42c80 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -175,5 +175,13 @@ class PointersTestCase(unittest.TestCase):
self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
self.assertRaises(TypeError, c_void_p, object()) # nor other objects
+ def test_pointers_bool(self):
+ # NULL pointers have a boolean False value, non-NULL pointers True.
+ self.failUnlessEqual(bool(POINTER(c_int)()), False)
+ self.failUnlessEqual(bool(pointer(c_int())), True)
+
+ self.failUnlessEqual(bool(CFUNCTYPE(None)(0)), False)
+ self.failUnlessEqual(bool(CFUNCTYPE(None)(42)), True)
+
if __name__ == '__main__':
unittest.main()