use of org.batfish.z3.expr.IfThenElse in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitAclIpSpace.
@Test
public void testVisitAclIpSpace() {
AclIpSpace ipSpace = AclIpSpace.builder().thenRejecting(UniverseIpSpace.INSTANCE).thenPermitting(EmptyIpSpace.INSTANCE).build();
BooleanExpr expr = ipSpace.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(expr, equalTo(new IfThenElse(// Matches UniverseIpSpace
TrueExpr.INSTANCE, // Reject
FalseExpr.INSTANCE, new IfThenElse(// Matches EmptyIpSpace
FalseExpr.INSTANCE, // Accept
TrueExpr.INSTANCE, // Matches nothing so reject
FalseExpr.INSTANCE))));
}
use of org.batfish.z3.expr.IfThenElse in project batfish by batfish.
the class IpSpaceBooleanExprTransformer method visitAclIpSpace.
@Override
public BooleanExpr visitAclIpSpace(AclIpSpace aclIpSpace) {
// right fold
BooleanExpr expr = FalseExpr.INSTANCE;
for (int i = aclIpSpace.getLines().size() - 1; i >= 0; i--) {
AclIpSpaceLine line = aclIpSpace.getLines().get(i);
expr = new IfThenElse(line.getIpSpace().accept(this), line.getAction() == LineAction.ACCEPT ? TrueExpr.INSTANCE : FalseExpr.INSTANCE, expr);
}
return expr;
}
Aggregations