Administrative updates
[breadcrumb.git] / tests / crumbify_tests.py
blobb774241dde5286cf8794f817c89f415b5376f6bd
1 # -*- coding: utf-8 -*-
2 """ Tests for crumbify.py, the Breadcrumb protocol serializer. """
4 # Copyright (C) 2008 Laurens Van Houtven <lvh at laurensvh.be>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import testing
19 import unittest
20 import breadcrumb.client.crumbify as crumbify
22 class CrumbifyTest(unittest.TestCase):
23 def setUp(self):
24 pass
26 def testpackbools_autopadding(self):
27 """Testing if automatical False padding when packing booleans works.
29 This was a small problem with the original implementation. The new way
30 of doing it doesn't actually do any padding, so this shouldn't be a
31 problem anymore."""
33 unpadded = [True]
34 padded = unpadded + [False] * (8-len(unpadded)) # 8 bits per byte
35 self.assertEqual(
36 crumbify.packbools(unpadded),
37 crumbify.packbools(padded),
38 "False padding doesn't affect boolean packing."
41 def testpackbools_toomany(self):
42 """Testing what happens when we provide too many bools for a byte."""
43 self.assertRaises(RuntimeError, crumbify.packbools, [False] * 10)
45 if __name__ == "__main__":
46 unittest.main()