1212import static com .google .common .truth .Truth .assert_ ;
1313
1414import com .google .common .base .Joiner ;
15+ import com .google .common .collect .FluentIterable ;
1516import com .google .common .truth .Fact ;
1617import com .google .common .truth .FailureMetadata ;
1718import com .google .common .truth .SimpleSubjectBuilder ;
@@ -69,9 +70,12 @@ public static SimpleSubjectBuilder<BooleanFormulaSubject, BooleanFormula> assert
6970 return assert_ ().about (booleanFormulasOf (context ));
7071 }
7172
72- private void checkIsUnsat (final BooleanFormula subject , final Fact expected )
73+ private void checkIsUnsat (
74+ final BooleanFormula subject , final Fact expected , ProverOptions ... options )
7375 throws SolverException , InterruptedException {
74- try (ProverEnvironment prover = context .newProverEnvironment (ProverOptions .GENERATE_MODELS )) {
76+ options =
77+ FluentIterable .of (ProverOptions .GENERATE_MODELS , options ).toArray (ProverOptions .class );
78+ try (ProverEnvironment prover = context .newProverEnvironment (options )) {
7579
7680 prover .push (subject );
7781 if (prover .isUnsat ()) {
@@ -94,19 +98,20 @@ private void checkIsUnsat(final BooleanFormula subject, final Fact expected)
9498 /**
9599 * Check that the subject is unsatisfiable. Will show a model (satisfying assignment) on failure.
96100 */
97- public void isUnsatisfiable () throws SolverException , InterruptedException {
101+ public void isUnsatisfiable (ProverOptions ... options )
102+ throws SolverException , InterruptedException {
98103 if (context .getFormulaManager ().getBooleanFormulaManager ().isTrue (formulaUnderTest )) {
99104 failWithoutActual (
100105 Fact .fact ("expected to be" , "unsatisfiable" ),
101106 Fact .fact ("but was" , "trivially satisfiable" ));
102107 return ;
103108 }
104109
105- checkIsUnsat (formulaUnderTest , Fact .simpleFact ("expected to be unsatisfiable" ));
110+ checkIsUnsat (formulaUnderTest , Fact .simpleFact ("expected to be unsatisfiable" ), options );
106111 }
107112
108113 /** Check that the subject is satisfiable. Will show an unsat core on failure. */
109- public void isSatisfiable () throws SolverException , InterruptedException {
114+ public void isSatisfiable (ProverOptions ... options ) throws SolverException , InterruptedException {
110115 final BooleanFormulaManager bmgr = context .getFormulaManager ().getBooleanFormulaManager ();
111116 if (bmgr .isFalse (formulaUnderTest )) {
112117 failWithoutActual (
@@ -115,14 +120,14 @@ public void isSatisfiable() throws SolverException, InterruptedException {
115120 return ;
116121 }
117122
118- try (ProverEnvironment prover = context .newProverEnvironment ()) {
123+ try (ProverEnvironment prover = context .newProverEnvironment (options )) {
119124 prover .push (formulaUnderTest );
120125 if (!prover .isUnsat ()) {
121126 return ; // success
122127 }
123128 }
124129
125- reportUnsatCoreForUnexpectedUnsatisfiableFormula ();
130+ reportUnsatCoreForUnexpectedUnsatisfiableFormula (options );
126131 }
127132
128133 /**
@@ -160,10 +165,11 @@ void isSatisfiableAndHasModel(int maxSizeOfModel) throws SolverException, Interr
160165 reportUnsatCoreForUnexpectedUnsatisfiableFormula ();
161166 }
162167
163- private void reportUnsatCoreForUnexpectedUnsatisfiableFormula ()
168+ private void reportUnsatCoreForUnexpectedUnsatisfiableFormula (ProverOptions ... options )
164169 throws InterruptedException , SolverException , AssertionError {
165- try (ProverEnvironment prover =
166- context .newProverEnvironment (ProverOptions .GENERATE_UNSAT_CORE )) {
170+ options =
171+ FluentIterable .of (ProverOptions .GENERATE_UNSAT_CORE , options ).toArray (ProverOptions .class );
172+ try (ProverEnvironment prover = context .newProverEnvironment (options )) {
167173 // Try to report unsat core for failure message if the solver supports it.
168174 for (BooleanFormula part :
169175 context
@@ -199,7 +205,8 @@ private void reportUnsatCoreForUnexpectedUnsatisfiableFormula()
199205 * satisfiability of the subject and unsatisfiability of the negated subject in two steps to
200206 * improve error messages.
201207 */
202- public void isTautological () throws SolverException , InterruptedException {
208+ public void isTautological (ProverOptions ... options )
209+ throws SolverException , InterruptedException {
203210 if (context .getFormulaManager ().getBooleanFormulaManager ().isFalse (formulaUnderTest )) {
204211 failWithoutActual (
205212 Fact .fact ("expected to be" , "tautological" ),
@@ -208,7 +215,8 @@ public void isTautological() throws SolverException, InterruptedException {
208215 }
209216 checkIsUnsat (
210217 context .getFormulaManager ().getBooleanFormulaManager ().not (formulaUnderTest ),
211- Fact .fact ("expected to be" , "tautological" ));
218+ Fact .fact ("expected to be" , "tautological" ),
219+ options );
212220 }
213221
214222 /**
0 commit comments