Tests for checking an encoded message has a proper length.
@@ -566,6 +566,21 @@ class CanToolsTest(unittest.TestCase):
self.assertEqual(outside_temp.choices, None)
self.assertEqual(outside_temp.comment, 'Outside temperature.')
+ def test_the_homer_encode_length(self):
+ filename = os.path.join('tests', 'files', 'the_homer.kcd')
+ db = cantools.db.load_file(filename)
+
+ frame_id = 0x400
+ data = {
+ 'MIL': 0,
+ 'Enginespeed': 127,
+ 'NoxSensor': 127,
+ }
+
+ encoded = db.encode_message(frame_id, data)
+ self.assertEqual(len(encoded), 5)
+ self.assertEqual(encoded, b'\x00?\x80?\x80')
+
def test_load_bad_format(self):
with self.assertRaises(cantools.db.UnsupportedDatabaseFormat):
cantools.db.load(StringIO(''))
