summaryrefslogtreecommitdiff
path: root/gr-digital/python/digital
diff options
context:
space:
mode:
authorDaniel Estévez <daniel@destevez.net>2021-06-06 11:32:40 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-06-12 12:01:12 -0400
commit222d95124bdc86d0bcc8c3498ea731ce03ad7cf8 (patch)
tree3658809a56c407233735fc8dd9426e88d30d7283 /gr-digital/python/digital
parent51c504ebb1ca21c5f7071826c1af03e45e391a65 (diff)
digital: Clean up differential encoder QA test
There was a lot of repetition in the different test cases for different modulus. This commit removes the repetition by using subtests. Signed-off-by: Daniel Estévez <daniel@destevez.net>
Diffstat (limited to 'gr-digital/python/digital')
-rw-r--r--gr-digital/python/digital/qa_diff_encoder.py52
1 files changed, 12 insertions, 40 deletions
diff --git a/gr-digital/python/digital/qa_diff_encoder.py b/gr-digital/python/digital/qa_diff_encoder.py
index 7ffc331b47..56ba5e9e93 100644
--- a/gr-digital/python/digital/qa_diff_encoder.py
+++ b/gr-digital/python/digital/qa_diff_encoder.py
@@ -31,46 +31,18 @@ class test_diff_encoder(gr_unittest.TestCase):
self.tb = None
def test_diff_encdec_000(self):
- random.seed(0)
- modulus = 2
- src_data = make_random_int_list(1000, 0, modulus - 1)
- expected_result = src_data
- src = blocks.vector_source_b(src_data)
- enc = digital.diff_encoder_bb(modulus)
- dec = digital.diff_decoder_bb(modulus)
- dst = blocks.vector_sink_b()
- self.tb.connect(src, enc, dec, dst)
- self.tb.run() # run the graph and wait for it to finish
- actual_result = dst.data() # fetch the contents of the sink
- self.assertEqual(expected_result, actual_result)
-
- def test_diff_encdec_001(self):
- random.seed(0)
- modulus = 4
- src_data = make_random_int_list(1000, 0, modulus - 1)
- expected_result = src_data
- src = blocks.vector_source_b(src_data)
- enc = digital.diff_encoder_bb(modulus)
- dec = digital.diff_decoder_bb(modulus)
- dst = blocks.vector_sink_b()
- self.tb.connect(src, enc, dec, dst)
- self.tb.run() # run the graph and wait for it to finish
- actual_result = dst.data() # fetch the contents of the sink
- self.assertEqual(expected_result, actual_result)
-
- def test_diff_encdec_002(self):
- random.seed(0)
- modulus = 8
- src_data = make_random_int_list(40000, 0, modulus - 1)
- expected_result = src_data
- src = blocks.vector_source_b(src_data)
- enc = digital.diff_encoder_bb(modulus)
- dec = digital.diff_decoder_bb(modulus)
- dst = blocks.vector_sink_b()
- self.tb.connect(src, enc, dec, dst)
- self.tb.run() # run the graph and wait for it to finish
- actual_result = dst.data() # fetch the contents of the sink
- self.assertEqual(expected_result, actual_result)
+ for modulus in (2, 4, 8):
+ with self.subTest(modulus=modulus):
+ src_data = make_random_int_list(40000, 0, modulus - 1)
+ expected_result = src_data
+ src = blocks.vector_source_b(src_data)
+ enc = digital.diff_encoder_bb(modulus)
+ dec = digital.diff_decoder_bb(modulus)
+ dst = blocks.vector_sink_b()
+ self.tb.connect(src, enc, dec, dst)
+ self.tb.run() # run the graph and wait for it to finish
+ actual_result = dst.data() # fetch the contents of the sink
+ self.assertEqual(expected_result, actual_result)
if __name__ == '__main__':