From 1b548a9d634dff96c5cba1950f0e5f9bb2ca81ca Mon Sep 17 00:00:00 2001 From: La Min Ko Date: Thu, 22 Oct 2020 10:56:16 +0630 Subject: [PATCH] close #16 --- tests/test_madmac.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_madmac.py b/tests/test_madmac.py index 53e4031..1cb0efc 100644 --- a/tests/test_madmac.py +++ b/tests/test_madmac.py @@ -97,3 +97,29 @@ def test_validate_MAC_TypeError(self): def test_validate_MAC_ValueError(self): self.assertFalse(madmac.validate_mac(None)) + + def test_mac_generator_prepare_stop_address(self): + mc = MacGenerator() + mc._prepare_stop_address() + self.assertIs(int, type(mc.i_stop)) + + def test_mac_generator_prepare_stop_address_user(self): + mc = MacGenerator(start="000005", stop="000010") + mc._prepare_stop_address() + self.assertEqual(16, mc.i_stop) + + def test_mac_generator_prepare_stop_address_ValueError(self): + mc = MacGenerator(stop="-10") + self.assertRaises(ValueError, mc._prepare_stop_address) + + def test_mac_generator_prepare_stop_address_user_total(self): + mc = MacGenerator(total="") + self.assertRaises(ValueError, mc._prepare_stop_address) + + def test_mac_generator_prepare_stop_address_UnsupportedOperation(self): + mc = MacGenerator(total="X") + self.assertRaises(UnsupportedOperation, mc._prepare_stop_address) + + def test_mac_generator_prepare_stop_address_InvalidEndingAddress(self): + mc = MacGenerator(start="000005", stop="00001G") + self.assertRaises(ValueError, mc._prepare_stop_address)