diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-05-22 13:15:31 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-05-22 13:15:31 (GMT) |
commit | cf99b0afb6e6572508582438a6609c6923a6f275 (patch) | |
tree | 9c3a4625309f7174521f3d75595508242949698b | |
parent | e41195fab62fa7eb695166ad6e84e351bcd8b6d1 (diff) | |
download | cpython-cf99b0afb6e6572508582438a6609c6923a6f275.zip cpython-cf99b0afb6e6572508582438a6609c6923a6f275.tar.gz cpython-cf99b0afb6e6572508582438a6609c6923a6f275.tar.bz2 |
test_byteswap() fails on alphas, because treating the byte swapped bit
patterns as floats/doubles results in floating point exceptions.
Fix this by implementing a separate test_byteswap() for the floating
point tests. This new test compares the tostring() values of both arrays
instead of the arrays themselves.
Discovered by Neal Norwitz.
-rwxr-xr-x | Lib/test/test_array.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 98589a5..6dff37c 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -847,6 +847,23 @@ class FPTest(NumberTest): class FloatTest(FPTest): typecode = 'f' minitemsize = 4 + + def test_byteswap(self): + a = array.array(self.typecode, self.example) + self.assertRaises(TypeError, a.byteswap, 42) + if a.itemsize in (1, 2, 4, 8): + b = array.array(self.typecode, self.example) + b.byteswap() + if a.itemsize==1: + self.assertEqual(a, b) + else: + # On alphas treating the byte swapped bit patters as + # floats/doubles results in floating point exceptions + # => compare the 8bit string values instead + self.assertNotEqual(a.tostring(), b.tostring()) + b.byteswap() + self.assertEqual(a, b) + tests.append(FloatTest) class DoubleTest(FPTest): |