use of com.google.common.truth.Fact in project compile-testing by google.
the class CompilationSubject method checkGeneratedFile.
private JavaFileObjectSubject checkGeneratedFile(Optional<JavaFileObject> generatedFile, Location location, String path) {
if (!generatedFile.isPresent()) {
// TODO(b/132162475): Use Facts if it becomes public API.
ImmutableList.Builder<Fact> facts = ImmutableList.builder();
facts.add(fact("in location", location.getName()));
facts.add(simpleFact("it generated:"));
for (JavaFileObject generated : actual.generatedFiles()) {
if (generated.toUri().getPath().contains(location.getName())) {
facts.add(simpleFact(" " + generated.toUri().getPath()));
}
}
failWithoutActual(fact("expected to generate file", "/" + path), facts.build().toArray(new Fact[0]));
return ignoreCheck().about(javaFileObjects()).that(ALREADY_FAILED);
}
return check("generatedFile(/%s)", path).about(javaFileObjects()).that(generatedFile.get());
}
use of com.google.common.truth.Fact in project java-smt by sosy-lab.
the class BooleanFormulaSubject method checkIsUnsat.
private void checkIsUnsat(final BooleanFormula subject, final Fact expected) throws SolverException, InterruptedException {
try (ProverEnvironment prover = context.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
prover.push(subject);
if (prover.isUnsat()) {
// success
return;
}
// get model for failure message
try (Model model = prover.getModel()) {
List<Fact> facts = new ArrayList<>();
facts.add(Fact.fact("but was", formulaUnderTest));
if (!subject.equals(formulaUnderTest)) {
facts.add(Fact.fact("checked formula was", subject));
}
facts.add(Fact.fact("which has model", model));
failWithoutActual(expected, facts.toArray(new Fact[0]));
}
}
}
Aggregations