Add some test cases for better unit test code coverage. Fix bug found by new TestCom...
[python-rwhoisd.git] / test / TestCidr.py
index 37eac36..c177880 100644 (file)
@@ -86,6 +86,10 @@ class CreateCidrTest(unittest.TestCase):
             self.assertEquals(cidr.numaddr, value)
             self.assertEquals(cidr.mask, mask)
 
+    def testClone(self):
+        cidr1 = Cidr.new("127.0.0.0/32")
+        cidr2 = cidr1.clone()
+        self.assertEquals(cidr1, cidr2)
 
     known_bad_v4_cidr = [ ("24.261.119.0", 32), # 2nd octet too large
                           "",                   # empty string
@@ -255,6 +259,14 @@ class testNetblockConversion(unittest.TestCase):
             self.assertEquals(start, s)
             self.assertEquals(end, e)
 
+    def testBadnetblock(self):
+        res = Cidr.netblock_to_cidr("127.0.0.257", "127.0.0.10.0")
+        assert(res == None)
+        res = Cidr.netblock_to_cidr("127.0.0.1", "127.0.256.255")
+        assert(res == None)
+        res = Cidr.netblock_to_cidr("::1", "127.0.0.2")
+        assert(res == None)
+
 
 if __name__ == "__main__":
     unittest.main()