示例#1
0
        public void TestSub()
        {
            Random r = new Random();
            int num1 = r.Next(-100, 100);
            int num2 = r.Next(-100, 100);

            Number n1 = new DecimalNumber(num1.ToString());
            Number n2 = new DecimalNumber(num2.ToString());
            Number sub = n1.SubFromCurrent(n2);
            Number sub2 = n2.SubFromCurrent(n1);

            Assert.AreEqual((num1 - num2).ToString(), con.Sub(n1, n2));
            Assert.AreEqual((num2 - num1).ToString(), con.Sub(n2, n1));

            Number n3 = n1.ToAnotherSystem(Bases.Binary);
            Number n4 = n2.ToAnotherSystem(Bases.Binary);

            string s = sub.ToAnotherSystem(Bases.Binary).ToString();
            Assert.AreEqual(n3.SubFromCurrent(n4).ToAnotherSystem(Bases.Binary).ToString(), s);
            s = sub2.ToAnotherSystem(Bases.Binary).ToString();
            Assert.AreEqual(n4.SubFromCurrent(n3).ToAnotherSystem(Bases.Binary).ToString(), s);
        }
示例#2
0
 public void TestSubDec()
 {
     int expected = 1;
     DecimalNumber DN1 = new DecimalNumber("5");
     DecimalNumber DN2 = new DecimalNumber("4");
     string correct = DN1.SubFromCurrent(DN2).ToString();
     Assert.AreEqual(expected.ToString(), correct, "Minus 2 decimal are correctly");
 }