laforge has uploaded this change for review.
unittests/test_files: Pass to-be-encoded length to encoder functions
Some of the encoders can only generate valid output if they are told
the expected output size. This is due to variable-length fields that
depend on the size of the total record (or file). Let's always pass
the expected length to the encoder methods.
Change-Id: I88f957e49b0c88a121a266d3582e79822fa0e214
---
M tests/unittests/test_files.py
1 file changed, 5 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/76/41676/1
diff --git a/tests/unittests/test_files.py b/tests/unittests/test_files.py
index ab70771..5bbbddd 100755
--- a/tests/unittests/test_files.py
+++ b/tests/unittests/test_files.py
@@ -96,7 +96,7 @@
inst = c()
encoded, rec_num, decoded = self._parse_t(t)
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_record_hex(decoded, rec_num)
+ re_enc = inst.encode_record_hex(decoded, rec_num, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
def test_de_encode_record(self):
@@ -122,7 +122,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec, rec_num)
+ re_enc = inst.encode_record_hex(re_dec, rec_num, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
@@ -196,7 +196,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec)
+ re_enc = inst.encode_record_hex(re_dec, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
# there's no point in testing padded input, as TransRecEF have a fixed record
# size and we cannot ever receive more input data than that size.
@@ -256,7 +256,7 @@
encoded = t[0]
decoded = t[1]
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_hex(decoded)
+ re_enc = inst.encode_hex(decoded, len(encoded)//2)
self.assertEqual(encoded, re_enc)
def test_de_encode_file(self):
@@ -280,7 +280,7 @@
self.assertEqual(decoded, re_dec)
logging.debug("Testing re-encode of %s", name)
re_dec = inst.decode_hex(encoded)
- re_enc = inst.encode_hex(re_dec)
+ re_enc = inst.encode_hex(re_dec, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
To view, visit change 41676. To unsubscribe, or for help writing mail filters, visit settings.