示例#1
0
 public void BigIntSum()
 {
     int maxValue = 100;
     for (int i = 0; i < maxValue; i++)
     {
         for (int j = 0; j < maxValue; j++)
         {
             BigInt.BigInt first = new BigInt.BigInt(i.ToString());
             BigInt.BigInt second = new BigInt.BigInt(j.ToString());
             BigInt.BigInt resultSum = first + second;
             uint result = (uint) (i + j);
             Assert.AreEqual(result.ToString(), resultSum.Value);
         }
     }
 }
示例#2
0
        public void TestBigValue()
        {
            // ------------------------------------------
            Stopwatch sw = Stopwatch.StartNew();
            string firstString = "1234567891234567891234567893216549872222222222222222222222222222222222222222222222222222222233333333333333333333333333333" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "99999999999999999999999999999999999999999999999999999" +
                                 "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
            string secondString = "555555555555555555555555555555555555555555555777777777777777777777772222222222222222222222222222222222222225465465465464654654646" +
                                  "555555555555555555555555555555555555555555555543242324444444444444444444444444444444444499999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999" +
                                  "";

            BigInteger bigIntegerFirst = BigInteger.Parse(firstString);
            BigInteger bigIntegerSecond = BigInteger.Parse(secondString);
            BigInteger expected = bigIntegerFirst + bigIntegerSecond;

            BigInt.BigInt firstBigINt = new BigInt.BigInt(firstString);
            BigInt.BigInt secondBigINt = new BigInt.BigInt(secondString);

            var result = firstBigINt + secondBigINt;

            sw.Stop();

            Assert.AreEqual(expected.ToString(), result.Value);

            //            Debug.WriteLine("{0} + {1}.  Time taken: {2}ms", i, j, sw.Elapsed.TotalMilliseconds);
        }
示例#3
0
 public void BigIntConstructorSuccessTest()
 {
     string correctBigInt = "123456789111444444444444444444444444444444444";
     BigInt.BigInt bigInt = new BigInt.BigInt(correctBigInt);
 }
示例#4
0
 public void BigIntConstructorFailTest()
 {
     string correctBigInt = "123456789fsf111'";
     BigInt.BigInt bigInt = new BigInt.BigInt(correctBigInt);
 }