コード例 #1
0
        public void TestMatchAny()
        {
            using (var ctx = new Context())
            {
                var networkProtocol = new NetworkProtocol
                {
                    Any = true
                };

                string     protocolVariableName = "protocol";
                BitVecExpr protocolVariable     = ctx.MkConst(protocolVariableName, ctx.MkBitVecSort(8)) as BitVecExpr;
                Solver     s = ctx.MkSolver();
                s.Assert(ctx.MkNot(networkProtocol.Matches(ctx, protocolVariable)));
                Status result = s.Check();
                Assert.AreEqual(Status.UNSATISFIABLE, result);
            }
        }
コード例 #2
0
        public void TestMatchesUnsatisfiable()
        {
            using (var ctx = new Context())
            {
                int protocolNumber  = 6;
                var networkProtocol = new NetworkProtocol
                {
                    Any            = false,
                    ProtocolNumber = protocolNumber
                };

                string     protocolVariableName = "protocol";
                BitVecExpr protocolVariable     = ctx.MkConst(protocolVariableName, ctx.MkBitVecSort(8)) as BitVecExpr;
                Solver     s = ctx.MkSolver();
                s.Assert(ctx.MkNot(networkProtocol.Matches(ctx, protocolVariable)));
                Status result = s.Check();
                Assert.AreEqual(Status.SATISFIABLE, result);
                int binding;
                Assert.IsTrue(RetrieveModelValue.TryRetrieveInteger(protocolVariableName, s.Model, out binding));
                Assert.AreNotEqual(protocolNumber, binding);
            }
        }