Beispiel #1
0
	def test_ensureInt(self):
		self.assertEqual(0, objcheck.ensureInt(0))
		self.assertEqual(-1, objcheck.ensureInt(-1))
		self.assertEqual(-1, objcheck.ensureInt(-1.0))
		self.assertTrue(isinstance(objcheck.ensureInt(-1.0), int))
		self.assertEqual(0, objcheck.ensureInt(-0.0))
		self.assertTrue(isinstance(objcheck.ensureInt(-0.0), int))
		self.assertEqual(2, objcheck.ensureInt(2.0))
		self.assertTrue(isinstance(objcheck.ensureInt(2.0), int))
		self.assertEqual(200000000000000000000000000, objcheck.ensureInt(200000000000000000000000000))
Beispiel #2
0
	def test_ensureIntExceptions(self):
		self.assertRaises(ValueError, lambda: objcheck.ensureInt("0"))
		self.assertRaises(ValueError, lambda: objcheck.ensureInt("-0"))
		self.assertRaises(TypeError, lambda: objcheck.ensureInt({}))
		self.assertRaises(TypeError, lambda: objcheck.ensureInt([]))
		self.assertRaises(TypeError, lambda: objcheck.ensureInt(True))
		self.assertRaises(TypeError, lambda: objcheck.ensureInt(False))