Ejemplo n.º 1
0
 def testSanity(self):
     """EncodeIp(DecodeIp(n))==n for all n"""
     for rp1v1, rp1v2, rp1k, rp2v1, rp2v2, rp2k, ip1, ip2, ip3 in self.knownValues:
         ((rp1v1b, rp1v2b, rp1kb), (rp2v1b, rp2v2b, rp2kb),
          (rp3v1b, rp3v2b, rp3kb)) = Fstdc.DecodeIp((ip1, ip2, ip3))
         (ip1b, ip2b, ip3b) = Fstdc.EncodeIp([(rp1v1b, rp1v2b, rp1kb),
                                              (rp2v1b, rp2v2b, rp2kb),
                                              (rp3v1b, rp3v2b, rp3kb)])
         self.assertEqual((ip1b, ip2b, ip3b), (ip1, ip2, ip3))
Ejemplo n.º 2
0
 def testDecodeIpKnownValues(self):
     """DecodeIp should give known result with known input"""
     for rp1v1,rp1v2,rp1k,rp2v1,rp2v2,rp2k,ip1,ip2,ip3 in self.knownValues:
         ((rp1v1b,rp1v2b,rp1kb),(rp2v1b,rp2v2b,rp2kb),(rp3v1b,rp3v2b,rp3kb)) = Fstdc.DecodeIp((ip1,ip2,ip3))
         self.assertEqual(rp1kb,rp1k)
         self.assertEqual(rp2kb,rp2k)
         self.assertAlmostEqual(rp1v1b,rp1v1,6)
         self.assertAlmostEqual(rp1v2b,rp1v2,6)
         self.assertAlmostEqual(rp2v1b,rp2v1,6)
         self.assertAlmostEqual(rp2v2b,rp2v2,6)