blob: 1788ff0d76a44481ee1646d10f74ff5e0691a6b3 [file] [log] [blame]
Yesudeep Mangalapillyfd1ec362011-08-11 01:47:46 +05301# -*- coding: utf-8 -*-
Roy Kokkelkoren0659aac2015-10-25 16:12:11 +01002#
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 Mangalapillyfd1ec362011-08-11 01:47:46 +053016
17import unittest2
18import struct
19
20from rsa._compat import is_bytes, byte
21
22class Test_byte(unittest2.TestCase):
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)