diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-09-07 11:04:41 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-09-07 11:04:41 (GMT) |
commit | be8da9c9906571698fe218da9e218ece500d5239 (patch) | |
tree | 266a4c850eecabfe37873825cd5414c034e98769 /Lib/test/test_array.py | |
parent | 799520c91ef6f2d1016e1f05790779a9cb7624d9 (diff) | |
download | cpython-be8da9c9906571698fe218da9e218ece500d5239.zip cpython-be8da9c9906571698fe218da9e218ece500d5239.tar.gz cpython-be8da9c9906571698fe218da9e218ece500d5239.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.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 482526e..2a21e74 100644 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -38,14 +38,24 @@ typecodes = "ubBhHiIlLfd" if have_long_long: typecodes += 'qQ' -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') self.assertRaises(ValueError, array.array, 'x') + 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) + # Machine format codes. # |