diff options
author | Guido van Rossum <guido@python.org> | 2007-05-08 21:05:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-08 21:05:48 (GMT) |
commit | f9e91c9c58de72afdf51f2a6ebfe50e98beeaa78 (patch) | |
tree | f2dd45d9585bc92e27c45e345fae3e906e3f2204 /Lib/test/test_bytes.py | |
parent | 2b08b38deacc065b4fea8421528de1eed66d56b0 (diff) | |
download | cpython-f9e91c9c58de72afdf51f2a6ebfe50e98beeaa78.zip cpython-f9e91c9c58de72afdf51f2a6ebfe50e98beeaa78.tar.gz cpython-f9e91c9c58de72afdf51f2a6ebfe50e98beeaa78.tar.bz2 |
Given that ord() of a bytes object of length 1 is defined, it should
never return a negative number.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index ded0491..33a4b0d 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -671,6 +671,11 @@ class BytesTest(unittest.TestCase): self.assertEqual(b.rstrip(b'im'), b'mississipp') self.assertEqual(b.rstrip(b'pim'), b'mississ') + def test_ord(self): + b = b'\0A\x7f\x80\xff' + self.assertEqual([ord(b[i:i+1]) for i in range(len(b))], + [0, 65, 127, 128, 255]) + # Optimizations: # __iter__? (optimization) # __reversed__? (optimization) |