summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-09-07 11:04:41 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-09-07 11:04:41 (GMT)
commit6eec87810fcf75249cb1060424f69ef5859e3fb1 (patch)
treea22e65c1c04d94dcc3de2f46c7dd4f26701182f4 /Lib/test/test_array.py
parent68b1f708bd27eb0551c26ae3dfcece71c12d2259 (diff)
downloadcpython-6eec87810fcf75249cb1060424f69ef5859e3fb1.zip
cpython-6eec87810fcf75249cb1060424f69ef5859e3fb1.tar.gz
cpython-6eec87810fcf75249cb1060424f69ef5859e3fb1.tar.bz2
Issue #27570: Avoid zero-length memcpy() calls with null source pointers
Diffstat (limited to 'Lib/test/test_array.py')
-rw-r--r--Lib/test/test_array.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 9f5c09d..0e6f515 100644
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -22,9 +22,9 @@ typecodes = "cbBhHiIlLfd"
if test_support.have_unicode:
typecodes += "u"
-class BadConstructorTest(unittest.TestCase):
+class MiscTest(unittest.TestCase):
- def test_constructor(self):
+ def test_bad_constructor(self):
self.assertRaises(TypeError, array.array)
self.assertRaises(TypeError, array.array, spam=42)
self.assertRaises(TypeError, array.array, 'xx')
@@ -40,7 +40,17 @@ class BadConstructorTest(unittest.TestCase):
self.assertRaises(ValueError, array.array, u'x')
self.assertRaises(ValueError, array.array, u'\x80')
-tests.append(BadConstructorTest)
+ def test_empty(self):
+ # Exercise code for handling zero-length arrays
+ a = array.array('B')
+ a[:] = a
+ self.assertEqual(len(a), 0)
+ self.assertEqual(len(a + a), 0)
+ self.assertEqual(len(a * 3), 0)
+ a += a
+ self.assertEqual(len(a), 0)
+
+tests.append(MiscTest)
class BaseTest(unittest.TestCase):
# Required class attributes (provided by subclasses