コード例 #1
0
        public void FromStringPositive()
        {
            var v = BigDec.FromString("1.5");

            Assert.AreEqual(-1, v.Exponent);
            Assert.AreEqual(new BigInteger(15.0), v.Mantissa);
        }
コード例 #2
0
ファイル: ExprEquality.cs プロジェクト: omaragb/tlp182
        public void LiteralReal()
        {
            var constant  = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real
            var constant2 = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real

            Assert.AreNotSame(constant, constant2);                                    // These are different references

            Assert.IsTrue(constant.Equals(constant2));                                 // These are "structurally equal"
            Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode());          // If the .Equals() is true then hash codes must be the same
        }
コード例 #3
0
        public void FromStringNegative()
        {
            // This tests for a Bug in Boogie that used to be present where BigDec
            // would not parse strings with negative numbers correctly
            //
            // If this bug is present this test will fail when checking the mantissa
            var v = BigDec.FromString("-1.5");

            Assert.AreEqual(-1, v.Exponent);
            Assert.AreEqual(new BigInteger(-15.0), v.Mantissa);
        }
コード例 #4
0
        public void FloorAndCeil(string value, int expectedFloor, int expectedCeiling)
        {
            var v = BigDec.FromString(value);

            if (value.StartsWith("-"))
            {
                Assert.IsTrue(v.IsNegative);
            }
            else
            {
                Assert.IsTrue(v.IsPositive || v.IsZero);
            }

            BigInteger floor   = 0;
            BigInteger ceiling = 0;

            v.FloorCeiling(out floor, out ceiling);
            Assert.AreEqual(new BigInteger(expectedFloor), floor);
            Assert.AreEqual(new BigInteger(expectedCeiling), ceiling);
        }
コード例 #5
0
 public override LiteralExpr ConstantReal(string value)
 {
     return(this.ConstantReal(BigDec.FromString(value)));
 }
コード例 #6
0
 public LiteralExpr ConstantReal(string value)
 {
     return(new LiteralExpr(Token.NoToken, BigDec.FromString(value), Immutable));
 }
コード例 #7
0
        public void testReal(bool useStringInterface)
        {
            var ccB = new ConstantCachingExprBuilder(this.GetSimpleBuilder());

            for (BigDec value = BigDec.FromInt(-20); value <= BigDec.FromInt(20); value += BigDec.FromString("0.1"))
            {
                var asString  = value.ToString();
                var realExpr  = useStringInterface ? ccB.ConstantReal(asString) : ccB.ConstantReal(value);
                var realExpr2 = useStringInterface ? ccB.ConstantReal(asString) : ccB.ConstantReal(value);
                Assert.AreSame(realExpr, realExpr2);
            }
        }