Skip to content

Commit 4112c48

Browse files
committed
Update tests
1 parent 633414b commit 4112c48

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bits_coder/tests.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22

3-
from fields import Int, Uint, Float, Ufloat, Bool, Unicode
43
from coder import BitsCoder
4+
from fields import Int, Uint, Float, Ufloat, Bool, Unicode
55

66

77
class TestFileds(unittest.TestCase):
@@ -100,6 +100,18 @@ def test_encoder(self):
100100
proper_value = 0b01101_00001001_1101_0000000.to_bytes(3, 'big')
101101
self.assertEqual(enc, proper_value)
102102

103+
coder = BitsCoder(
104+
[
105+
Int(6, name='temperature', value=21),
106+
Bool(1, name='is_nice', value=True),
107+
Float(18, 3, name='lat', value=78.234),
108+
Float(18, 3, name='lon', value=-33.111)
109+
]
110+
)
111+
enc = coder.encode()
112+
proper_value = 0b010101_1_010011000110011010_110111111010101001_00000
113+
self.assertEqual(enc, proper_value.to_bytes(6, 'big'))
114+
103115
def test_decoder(self):
104116
proper_map = {'a': -12, 'b': 2.11, 'c': True, 'd': 12, '___1': 0}
105117
pld = 'e9a7003000'

0 commit comments

Comments
 (0)