def test_binConversions2(self): val = unitConverters.binStrToInt("0000000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, 0) val = unitConverters.binStrToInt("1111111111111111111111111111111111111111111111111111111111111111") self.assertEqual(val, -1) val = unitConverters.binStrToInt("1000000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, -9223372036854775808) val = unitConverters.binStrToInt("0111111111111111111111111111111111111111111111111111111111111111") self.assertEqual(val, 9223372036854775807) val = unitConverters.binStrToInt("1100000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, -4611686018427387904) val = unitConverters.binStrToInt("0100000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, 4611686018427387904) self.assertRaises(ValueError, b2i, "101")
def test_binConversions2(self): val = unitConverters.binStrToInt( "0000000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, 0) val = unitConverters.binStrToInt( "1111111111111111111111111111111111111111111111111111111111111111") self.assertEqual(val, -1) val = unitConverters.binStrToInt( "1000000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, -9223372036854775808) val = unitConverters.binStrToInt( "0111111111111111111111111111111111111111111111111111111111111111") self.assertEqual(val, 9223372036854775807) val = unitConverters.binStrToInt( "1100000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, -4611686018427387904) val = unitConverters.binStrToInt( "0100000000000000000000000000000000000000000000000000000000000000") self.assertEqual(val, 4611686018427387904) self.assertRaises(ValueError, b2i, "101")
def test_binConversions3(self): # Kinda brute-forcey random testing, but it'll work for the moment. for x in range(1000): test = ''.join([str(random.randrange(0, 2, 1)) for x in range(64)]) self.assertEqual(b2i(test), unitConverters.binStrToInt(test))