예제 #1
0
        public void TestSimpleRange()
        {
            var range1 = new PortRange(0, 100);
            var range2 = new PortRange(100, 0);

            Assert.Equal(101, range1.Count);
            Assert.Equal(range1, range2);
            Assert.False(range1 != range2);
            Assert.True(range1 == range2);
            Assert.True(range1.Overlaps(range2));
            Assert.True(range1.Contains(0));
            Assert.True(range1.Contains(100));
            Assert.True(range1.Contains(6));
        }
예제 #2
0
        public void TestFullRange()
        {
            using (var ctx = new Context())
            {
                var range = new PortRange
                {
                    Low  = 0,
                    High = ushort.MaxValue
                };

                string     portVariableName = "port";
                BitVecExpr variable         = ctx.MkConst(portVariableName, ctx.MkBitVecSort(16)) as BitVecExpr;
                Solver     s = ctx.MkSolver();
                s.Assert(ctx.MkNot(range.Contains(ctx, variable)));
                Status result = s.Check();
                Assert.AreEqual(Status.UNSATISFIABLE, result);
            }
        }
예제 #3
0
        public void TestSingle()
        {
            using (var ctx = new Context())
            {
                int single = 64;
                var range  = new PortRange
                {
                    Low  = single,
                    High = single
                };

                string     portVariableName = "port";
                BitVecExpr variable         = ctx.MkConst(portVariableName, ctx.MkBitVecSort(16)) as BitVecExpr;
                Solver     s = ctx.MkSolver();
                s.Assert(range.Contains(ctx, variable));
                Status result = s.Check();
                Assert.AreEqual(Status.SATISFIABLE, result);
                int binding;
                Assert.IsTrue(RetrieveModelValue.TryRetrieveInteger(portVariableName, s.Model, out binding));
                Assert.AreEqual(single, binding);
            }
        }