def testSanity(self): """levels_to_ip1(ip1_to_levels(n))==n for all n""" for lvlnew,lvlold,ipnew,ipold,kind in self.knownValues: (lvl2,kind2) = rpnstd.ip1_to_levels([ipnew])[0] (ipnew2,ipold2) = rpnstd.levels_to_ip1([lvl2],kind2)[0] self.assertEqual(ipnew2,ipnew) (lvl2,kind2) = rpnstd.ip1_to_levels([ipold])[0] (ipnew2,ipold2) = rpnstd.levels_to_ip1([lvl2],kind2)[0] self.assertEqual(ipold2,ipold)
def testip1_to_levelsKnownValues(self): """ip1_to_levels should give known result with known input""" for lvlnew,lvlold,ipnew,ipold,kind in self.knownValues: (lvl2,kind2) = rpnstd.ip1_to_levels([ipnew])[0] self.assertEqual(kind2,kind) self.assertAlmostEqual(lvlnew,lvl2,6) (lvl2,kind2) = rpnstd.ip1_to_levels([ipold])[0] self.assertEqual(kind2,kind) self.assertAlmostEqual(lvlold,lvl2,6)