From 119e64362551d014c44f805900c494ba7b93c139 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 16 Oct 2023 21:26:10 +0200 Subject: [PATCH] test the error case as well --- tests/cfdp/pdus/test_file_data.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/cfdp/pdus/test_file_data.py b/tests/cfdp/pdus/test_file_data.py index a3ac30e..f28db40 100644 --- a/tests/cfdp/pdus/test_file_data.py +++ b/tests/cfdp/pdus/test_file_data.py @@ -45,6 +45,16 @@ def test_max_file_seg_calculator_2(self): fd_pdu = FileDataPdu(pdu_conf, FileDataParams(bytes(), 0)) self.assertEqual(fd_pdu.get_max_file_seg_len_for_max_packet_len(64), 49) + def test_max_file_seg_calculator_error(self): + pdu_conf = PduConfig.default() + file_seg_len = get_max_file_seg_len_for_max_packet_len_and_pdu_cfg(pdu_conf, 11) + self.assertEqual(file_seg_len, 0) + with self.assertRaises(ValueError): + file_seg_len = get_max_file_seg_len_for_max_packet_len_and_pdu_cfg(pdu_conf, 10) + fd_pdu = FileDataPdu(pdu_conf, FileDataParams(bytes(), 0)) + with self.assertRaises(ValueError): + fd_pdu.get_max_file_seg_len_for_max_packet_len(10) + def test_state(self): self.assertEqual(self.pdu.pdu_header.header_len, 7) # 15: 'hello world' encoded + 4 bytes offset