Skip to content

Commit 5c60f2c

Browse files
committed
#351: add tests for option combinations with unsat-core.
1 parent 91b9524 commit 5c60f2c

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/org/sosy_lab/java_smt/test/ProverEnvironmentTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,41 @@ public void unsatCoreWithAssumptionsTest() throws SolverException, InterruptedEx
148148
assertThat(unsatCore).containsExactly(bmgr.not(selector));
149149
}
150150
}
151+
152+
@Test
153+
public void testSatWithUnsatUnsatCoreOptions() throws InterruptedException, SolverException {
154+
requireUnsatCore();
155+
try (ProverEnvironment prover = context.newProverEnvironment(GENERATE_UNSAT_CORE)) {
156+
checkSimpleQuery(prover);
157+
}
158+
159+
requireUnsatCoreOverAssumptions();
160+
try (ProverEnvironment prover =
161+
context.newProverEnvironment(GENERATE_UNSAT_CORE_OVER_ASSUMPTIONS)) {
162+
checkSimpleQuery(prover);
163+
}
164+
165+
try (ProverEnvironment prover =
166+
context.newProverEnvironment(GENERATE_UNSAT_CORE, GENERATE_UNSAT_CORE_OVER_ASSUMPTIONS)) {
167+
checkSimpleQuery(prover);
168+
}
169+
}
170+
171+
private void checkSimpleQuery(ProverEnvironment pProver)
172+
throws InterruptedException, SolverException {
173+
BooleanFormula constraint = bmgr.implication(bmgr.makeVariable("a"), bmgr.makeVariable("b"));
174+
175+
{
176+
pProver.push(constraint);
177+
assertThat(pProver.isUnsat()).isFalse();
178+
pProver.pop();
179+
}
180+
181+
{
182+
pProver.push();
183+
pProver.addConstraint(constraint); // Z3 crashed here
184+
assertThat(pProver.isUnsat()).isFalse();
185+
pProver.pop();
186+
}
187+
}
151188
}

src/org/sosy_lab/java_smt/test/SolverBasedTest0.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ protected void requireUnsatCore() {
335335
.isNoneOf(Solvers.BOOLECTOR, Solvers.OPENSMT);
336336
}
337337

338+
protected void requireUnsatCoreOverAssumptions() {
339+
assume()
340+
.withMessage("Solver %s does not support unsat core generation", solverToUse())
341+
.that(solverToUse())
342+
.isNotEqualTo(Solvers.PRINCESS);
343+
}
344+
338345
protected void requireSubstitution() {
339346
assume()
340347
.withMessage("Solver %s does not support formula substitution", solverToUse())

0 commit comments

Comments
 (0)