Skip to content

Commit cb1e165

Browse files
Add unit test for BDD
This adds a test case to check there are no mistakes in the BDD to expr conversions. This test can fail without the previous fix.
1 parent 6406fdf commit cb1e165

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

unit/solvers/prop/bdd_expr.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,23 @@ SCENARIO("bdd_expr", "[core][solver][prop][bdd_expr]")
4444
REQUIRE(bdd.as_expr() == bdd2.as_expr());
4545
}
4646
}
47+
48+
GIVEN("A bdd for (a&!b)")
49+
{
50+
const symbol_exprt a("a", bool_typet());
51+
const symbol_exprt b("b", bool_typet());
52+
53+
const bddt bdd = bdd_expr_converter.from_expr(and_exprt(a, not_exprt(b)));
54+
55+
WHEN("It is converted to an exprt")
56+
{
57+
const exprt result = bdd_expr_converter.as_expr(bdd);
58+
THEN("It is equal to the expression (a & !b) or (!b & a)")
59+
{
60+
const bool correct = result == and_exprt(a, not_exprt(b)) ||
61+
result == and_exprt(not_exprt(b), a);
62+
REQUIRE(correct);
63+
}
64+
}
65+
}
4766
}

0 commit comments

Comments
 (0)