public override bool Equals(object o)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            MathContextCodegenField that = (MathContextCodegenField) o;

            return mathContext != null ? mathContext.Equals(that.mathContext) : that.mathContext == null;
        }
Beispiel #2
0
        public void MathContextConstruction()
        {
            String a = "-12380945E+61";
            BigDecimal aNumber = BigDecimal.Parse(a);
            int precision = 6;
            RoundingMode rm = RoundingMode.HalfDown;
            MathContext mcIntRm = new MathContext(precision, rm);
            MathContext mcStr = MathContext.Parse("precision=6 roundingMode=HALFDOWN");
            MathContext mcInt = new MathContext(precision);
            BigDecimal res = aNumber.Abs(mcInt);
            Assert.AreEqual(res, BigDecimal.Parse("1.23809E+68"), "MathContext Constructor with int precision failed");

            Assert.AreEqual(mcIntRm, mcStr, "Equal MathContexts are not Equal ");

            Assert.AreEqual(mcInt.Equals(mcStr), false, "Different MathContext are reported as Equal ");

            Assert.AreEqual(mcIntRm.GetHashCode(), mcStr.GetHashCode(), "Equal MathContexts have different hashcodes ");

            Assert.AreEqual(mcIntRm.ToString(), "precision=6 roundingMode=HalfDown",
                            "MathContext.ToString() returning incorrect value");
        }