Yesudeep Mangalapilly | fd1ec36 | 2011-08-11 01:47:46 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
Roy Kokkelkoren | 0659aac | 2015-10-25 16:12:11 +0100 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu> |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Yesudeep Mangalapilly | fd1ec36 | 2011-08-11 01:47:46 +0530 | [diff] [blame] | 16 | |
Sybren A. Stüvel | ed1c81d | 2016-01-14 12:23:32 +0100 | [diff] [blame] | 17 | import unittest |
Yesudeep Mangalapilly | fd1ec36 | 2011-08-11 01:47:46 +0530 | [diff] [blame] | 18 | import struct |
| 19 | |
| 20 | from rsa._compat import is_bytes, byte |
| 21 | |
Sybren A. Stüvel | ed1c81d | 2016-01-14 12:23:32 +0100 | [diff] [blame] | 22 | class Test_byte(unittest.TestCase): |
Yesudeep Mangalapilly | fd1ec36 | 2011-08-11 01:47:46 +0530 | [diff] [blame] | 23 | def test_byte(self): |
| 24 | for i in range(256): |
| 25 | byt = byte(i) |
| 26 | self.assertTrue(is_bytes(byt)) |
| 27 | self.assertEqual(ord(byt), i) |
| 28 | |
| 29 | def test_raises_StructError_on_overflow(self): |
| 30 | self.assertRaises(struct.error, byte, 256) |
| 31 | self.assertRaises(struct.error, byte, -1) |