def test_operatorerrors(self): secfld = sectypes.SecFld() secint = sectypes.SecInt() a = secfld(0) b = secint(1) self.assertRaises(TypeError, operator.add, a, b) self.assertRaises(TypeError, operator.add, a, 3.14) self.assertRaises(TypeError, operator.sub, a, b) self.assertRaises(TypeError, operator.mul, a, b) self.assertRaises(TypeError, operator.mul, 3.14, b) self.assertRaises(TypeError, operator.truediv, a, b) self.assertRaises(TypeError, operator.truediv, a, b) self.assertRaises(TypeError, operator.mod, a, b) self.assertRaises(TypeError, operator.mod, b, a) self.assertRaises(TypeError, operator.floordiv, a, b) self.assertRaises(TypeError, divmod, a, b) self.assertRaises(TypeError, divmod, b, a) self.assertRaises(TypeError, operator.pow, b, 3.14) self.assertRaises(TypeError, operator.lshift, b, 3.14) self.assertRaises(TypeError, operator.lshift, 3.14, b) self.assertRaises(TypeError, operator.rshift, b, 3.14) self.assertRaises(TypeError, operator.rshift, 3.14, b)
def test_bool(self): self.assertRaises(TypeError, bool, sectypes.SecFld()(0)) self.assertRaises(TypeError, bool, sectypes.SecInt()(0)) self.assertRaises(TypeError, bool, sectypes.SecFxp()(0)) self.assertRaises(TypeError, bool, sectypes.SecFlt()(0))
def test_SecNum(self): sectypes.SecInt(p=2**89 - 1) self.assertRaises(ValueError, sectypes.SecInt, p=2**61 - 1) sectypes.SecFxp(p=2**89 - 1) self.assertRaises(ValueError, sectypes.SecFxp, f=58, p=2**89 - 1)