def test_expressions(self): """ Test that the function behaves properly when no subnet bit is provided. """ self.assertEqual(is_ip_in_subnet('129.133.1.125', '*'), True) self.assertEqual(is_ip_in_subnet('129.133.1.125', '129.133.1.126'), False)
def test_range(self): """ Test that the subnet bit, when provided, is handled correctly. """ self.assertEqual(is_ip_in_subnet('0.0.0.0', '0.0.0.0/8'), True) self.assertEqual(is_ip_in_subnet('0.255.255.255', '0.0.0.0/8'), True) self.assertEqual(is_ip_in_subnet('1.0.0.0', '0.0.0.0/8'), False) self.assertEqual(is_ip_in_subnet('129.255.255.255', '128.0.0.0/7'), True) self.assertEqual(is_ip_in_subnet('130.0.0.0', '128.0.0.0/7'), False) self.assertEqual(is_ip_in_subnet('127.255.255.255', '128.0.0.0/7'), False)