blob: 2ab7fd2820f2d0e4e6d14020420d1c3153ba1886 [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
Sybren A. Stüveled1c81d2016-01-14 12:23:32 +010017import unittest
Yesudeep Mangalapillyfd1ec362011-08-11 01:47:46 +053018import struct
19
20from rsa._compat import is_bytes, byte
21
Sybren A. Stüveled1c81d2016-01-14 12:23:32 +010022class Test_byte(unittest.TestCase):
Yesudeep Mangalapillyfd1ec362011-08-11 01:47:46 +053023 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)