def test_get_constraints(self): var1 = SMTVar('var1', z3.IntSort()) var2 = SMTVar('var1', z3.IntSort()) const = var1.var + var2.var > 10 name = 'cosnt1' ctx = SolverContext(z3.Context()) ctx.register_constraint(const, name) self.assertIsNotNone(ctx.get_constraint(name)) self.assertIsNotNone(ctx.get_constraints_info(name)) with self.assertRaises(ValueError): ctx.get_constraint('NotRegistered') with self.assertRaises(ValueError): ctx.get_constraints_info('NotRegistered')
def test_register_const(self): # Arrange var1 = SMTVar('var1', z3.IntSort()) var2 = SMTVar('var1', z3.IntSort()) const = var1.var + var2.var > 10 # Act ctx = SolverContext(z3.Context()) name = ctx.register_constraint(const) with self.assertRaises(ValueError): ctx.register_constraint(const, name) constraints = list(ctx.constraints_itr()) # Assert self.assertIsNotNone(ctx.get_constraint(name)) self.assertIsNotNone(ctx.get_constraints_info(name)) self.assertEquals(len(constraints), 1) self.assertEquals(constraints[0][0], name) self.assertEquals(constraints[0][1], const)