Search in sources :

Example 6 with BooleanExpr

use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.

the class BoolExprTransformerTest method testVisitPrefixMatchExpr.

@Test
public void testVisitPrefixMatchExpr() {
    BooleanExpr expr = new PrefixMatchExpr(BasicHeaderField.SRC_IP, Prefix.parse("1.2.3.4/5"));
    assertThat(toBoolExpr(expr, _input, _nodContext), instanceOf(BoolExpr.class));
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) BoolExprTransformer.toBoolExpr(org.batfish.z3.expr.visitors.BoolExprTransformer.toBoolExpr) PrefixMatchExpr(org.batfish.z3.expr.PrefixMatchExpr) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Test(org.junit.Test)

Example 7 with BooleanExpr

use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.

the class BoolExprTransformerTest method testVisitOrExpr.

@Test
public void testVisitOrExpr() {
    BooleanExpr p1Batfish = newBooleanAtom();
    BooleanExpr p2Batfish = newBooleanAtom();
    BoolExpr p1Z3 = toBoolExpr(p1Batfish, _input, _nodContext);
    BoolExpr p2Z3 = toBoolExpr(p2Batfish, _input, _nodContext);
    assertThat(toBoolExpr(new OrExpr(of(p1Batfish, p2Batfish)), _input, _nodContext), equalTo(_ctx.mkOr(p1Z3, p2Z3)));
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) BoolExprTransformer.toBoolExpr(org.batfish.z3.expr.visitors.BoolExprTransformer.toBoolExpr) BooleanExpr(org.batfish.z3.expr.BooleanExpr) OrExpr(org.batfish.z3.expr.OrExpr) Test(org.junit.Test)

Example 8 with BooleanExpr

use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.

the class IpSpaceBooleanExprTransformerTest method testVisitIpWildcard.

@Test
public void testVisitIpWildcard() {
    IpWildcard wildcard = new IpWildcard(new Ip("1.2.0.4"), new Ip(0x0000FF00L));
    BooleanExpr matchExpr = wildcard.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
    assertThat(matchExpr, equalTo(HeaderSpaceMatchExpr.matchSrcIp(ImmutableSet.of(wildcard))));
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) Ip(org.batfish.datamodel.Ip) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Test(org.junit.Test)

Example 9 with BooleanExpr

use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.

the class IpSpaceBooleanExprTransformerTest method testVisitUniverseIpSpace.

@Test
public void testVisitUniverseIpSpace() {
    BooleanExpr expr = UniverseIpSpace.INSTANCE.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
    assertThat(expr, equalTo(TrueExpr.INSTANCE));
}
Also used : BooleanExpr(org.batfish.z3.expr.BooleanExpr) Test(org.junit.Test)

Example 10 with BooleanExpr

use of org.batfish.z3.expr.BooleanExpr 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))));
}
Also used : AclIpSpace(org.batfish.datamodel.AclIpSpace) IfThenElse(org.batfish.z3.expr.IfThenElse) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Test(org.junit.Test)

Aggregations

BooleanExpr (org.batfish.z3.expr.BooleanExpr)43 Test (org.junit.Test)27 AndExpr (org.batfish.z3.expr.AndExpr)14 NotExpr (org.batfish.z3.expr.NotExpr)13 Simplifier.simplifyBooleanExpr (org.batfish.z3.expr.visitors.Simplifier.simplifyBooleanExpr)13 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)10 ImmutableList (com.google.common.collect.ImmutableList)9 HeaderSpaceMatchExpr (org.batfish.z3.expr.HeaderSpaceMatchExpr)8 BoolExpr (com.microsoft.z3.BoolExpr)7 IfExpr (org.batfish.z3.expr.IfExpr)7 VarIntExpr (org.batfish.z3.expr.VarIntExpr)7 BoolExprTransformer.toBoolExpr (org.batfish.z3.expr.visitors.BoolExprTransformer.toBoolExpr)7 List (java.util.List)6 IpWildcard (org.batfish.datamodel.IpWildcard)6 EqExpr (org.batfish.z3.expr.EqExpr)6 OrExpr (org.batfish.z3.expr.OrExpr)6 QueryStatement (org.batfish.z3.expr.QueryStatement)6 RuleStatement (org.batfish.z3.expr.RuleStatement)6 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)6 Ip (org.batfish.datamodel.Ip)5