Skip to content

Commit e1fb6b7

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 e1fb6b7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

unit/solvers/prop/bdd_expr.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,25 @@ 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+
bdd_exprt bdd{ns};
54+
bdd.from_expr(and_exprt(a, not_exprt(b)));
55+
56+
WHEN("It is converted to an exprt")
57+
{
58+
const exprt result = bdd.as_expr();
59+
THEN("It is equal to the expression (a & !b) or (!b & a)")
60+
{
61+
REQUIRE(result.id() == ID_and);
62+
REQUIRE(result.operands().size() == 2);
63+
REQUIRE((result.op0() == a || result.op1() == a));
64+
REQUIRE((result.op0() == not_exprt(b) || result.op1() == not_exprt(b)));
65+
}
66+
}
67+
}
4768
}

0 commit comments

Comments
 (0)