File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,6 +223,25 @@ def test_array_of_half_words(self):
223223 cobsr .decode (array_encoded_string )
224224
225225
226+ class UtilTests (unittest .TestCase ):
227+
228+ def test_encoded_len_calc (self ):
229+ self .assertEqual (cobs .encoding_overhead (5 ), 1 )
230+ self .assertEqual (cobs .max_encoded_length (5 ), 6 )
231+
232+ def test_encoded_len_calc_empty_packet (self ):
233+ self .assertEqual (cobs .encoding_overhead (0 ), 1 )
234+ self .assertEqual (cobs .max_encoded_length (0 ), 1 )
235+
236+ def test_encoded_len_calc_still_one_byte_overhead (self ):
237+ self .assertEqual (cobs .encoding_overhead (254 ), 1 )
238+ self .assertEqual (cobs .max_encoded_length (254 ), 255 )
239+
240+ def test_encoded_len_calc_two_byte_overhead (self ):
241+ self .assertEqual (cobs .encoding_overhead (255 ), 2 )
242+ self .assertEqual (cobs .max_encoded_length (255 ), 257 )
243+
244+
226245def runtests ():
227246 unittest .main ()
228247
You can’t perform that action at this time.
0 commit comments