Skip to content

Commit

Permalink
Add some simplification test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdrake committed Feb 27, 2015
1 parent ea7d3af commit 140010c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 1 addition & 6 deletions extension/boolexpr/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,7 @@ _eq_simplify(BoolExpr *op)
static BoolExpr *
_not_simplify(BoolExpr *op)
{
BoolExpr *x = op->data.xs->items[0];
BoolExpr *y;

CHECK_NULL(y, Not(x));

return y;
return Not(op->data.xs->items[0]);
}


Expand Down
20 changes: 20 additions & 0 deletions extension/boolexpr/test/test_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ TEST_F(BoolExprSimpleTest, EqualCases)
}


TEST_F(BoolExprSimpleTest, NotCases)
{
ops[0] = NorN(3, xs[0], &One, xs[1]);
ops[1] = BoolExpr_Simplify(ops[0]);
EXPECT_EQ(ops[1], &Zero);

ops[2] = NandN(3, xs[0], xs[1], xs[2]);
ops[3] = BoolExpr_Simplify(ops[2]);
EXPECT_TRUE(Similar(ops[2], ops[3]));
}


TEST_F(BoolExprSimpleTest, ImpliesCases)
{
ops[0] = Implies(&Zero, xs[0]);
Expand All @@ -390,6 +402,10 @@ TEST_F(BoolExprSimpleTest, ImpliesCases)
ops[10] = Implies(xns[0], xs[0]);
ops[11] = BoolExpr_Simplify(ops[10]);
EXPECT_EQ(ops[11], xs[0]);

ops[12] = Implies(xs[1], xs[2]);
ops[13] = BoolExpr_Simplify(ops[12]);
EXPECT_TRUE(Similar(ops[12], ops[13]));
}


Expand Down Expand Up @@ -455,5 +471,9 @@ TEST_F(BoolExprSimpleTest, ITECases)
ops[21] = BoolExpr_Simplify(ops[20]);
exps[5] = AndN(2, xs[0], xs[1]);
EXPECT_TRUE(Similar(ops[21], exps[5]));

ops[22] = ITE(xs[0], xs[1], xs[2]);
ops[23] = BoolExpr_Simplify(ops[22]);
EXPECT_TRUE(Similar(ops[22], ops[23]));
}

0 comments on commit 140010c

Please sign in to comment.