def test_length(self): arguments = (0, 1, 2, 40, 50, 255, 256, 1000) results = (0, 1, 1, 1, 1, 1, 2, 2) for argument, result in zip(arguments, results): self.assertEqual( coap.UintOption(0, argument)._length(), result, 'wrong length for option value : ' + str(argument))
def test_decode(self): arguments = ("", chr(1), chr(2), chr(40), chr(50), chr(255), chr(1) + chr(0), chr(3) + chr(232)) results = (0, 1, 2, 40, 50, 255, 256, 1000) for argument, result in zip(arguments, results): self.assertEqual( coap.UintOption(0).decode(argument).value, result, 'wrong decode operation for rawdata : ' + str(argument))
def test_encode(self): arguments = (0, 1, 2, 40, 50, 255, 256, 1000) results = ("", chr(1), chr(2), chr(40), chr(50), chr(255), chr(1) + chr(0), chr(3) + chr(232)) for argument, result in zip(arguments, results): self.assertEqual( coap.UintOption(0, argument).encode(), result, 'wrong encode operation for option value : ' + str(argument))