Skip to content

Commit

Permalink
tests: add test for trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed Aug 30, 2019
1 parent bc8b454 commit 93b9fc5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_trim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/python


"""
test for trimming under Python 3
"""

from __future__ import absolute_import, print_function
import unittest
import os
import pkg_resources
import sys
from pymavlink import mavutil

class PayLoadTrimZeros(unittest.TestCase):
'''Trivial test for trimming zeros from end of messages'''

def test_dump_length(self):
mavutil.mavlink.WIRE_PROTOCOL_VERSION = 2
mav = mavutil.mavudp(":12345")

ts = [ ((1, 1), 10),
((1, 0), 9),
((0, 0), 9)
]
for t in ts:
((sysid, compid), result) = t
m = mavutil.mavlink.MAVLink_param_request_list_message(sysid, compid)
packed = m.pack(mav.mav)
print("(%u/%u should be %u" % (sysid,compid, result))
self.assertEqual(len(packed), result)

if __name__ == '__main__':
unittest.main()

0 comments on commit 93b9fc5

Please sign in to comment.