2010-03-06 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Sat, 6 Mar 2010 17:34:58 +0000 (17:34 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Sat, 6 Mar 2010 17:34:58 +0000 (17:34 -0000)
* BigIntegerTest.cs: Tests for GreatestCommonDivisor.

svn path=/trunk/mcs/; revision=153191

mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs
mcs/class/System.Numerics/Test/System.Numerics/ChangeLog

index f5d1432430fe3ffb249a639335c9cda669c51c0a..5a1c0bf2c2a9aa68c18ca6798b79687e398c1e3c 100644 (file)
@@ -109,7 +109,6 @@ namespace MonoTests.System.Numerics
                        Assert.AreEqual (59049, (int)BigInteger.Pow (3, 10), "#4");
                        Assert.AreEqual (177147, (int)BigInteger.Pow (3, 11), "#5");
                        Assert.AreEqual (-177147, (int)BigInteger.Pow (-3, 11), "#6");
-
                }
 
                [Test]
@@ -129,6 +128,29 @@ namespace MonoTests.System.Numerics
                        Assert.AreEqual (-24L, (long)BigInteger.ModPow (-555, 11, 71), "#3");
                }
 
+               [Test]
+               public void GCD () {    
+                       Assert.AreEqual (999999, (int)BigInteger.GreatestCommonDivisor (999999, 0), "#1");
+                       Assert.AreEqual (999999, (int)BigInteger.GreatestCommonDivisor (0, 999999), "#2");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (999999, 1), "#3");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (1, 999999), "#4");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (1, 0), "#5");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (0, 1), "#6");
+
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (999999, -1), "#7");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (-1, 999999), "#8");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (-1, 0), "#9");
+                       Assert.AreEqual (1, (int)BigInteger.GreatestCommonDivisor (0, -1), "#10");
+
+                       Assert.AreEqual (2, (int)BigInteger.GreatestCommonDivisor (12345678, 8765432), "#11");
+                       Assert.AreEqual (2, (int)BigInteger.GreatestCommonDivisor (-12345678, 8765432), "#12");
+                       Assert.AreEqual (2, (int)BigInteger.GreatestCommonDivisor (12345678, -8765432), "#13");
+                       Assert.AreEqual (2, (int)BigInteger.GreatestCommonDivisor (-12345678, -8765432), "#14");
+
+                       Assert.AreEqual (40, (int)BigInteger.GreatestCommonDivisor (5581 * 40, 6671 * 40), "#15");
+
+               }
+
                [Test]
                public void DivRemByZero () {
                        try {
index 9d4d4a91487e140895942867139576559ae5f641..32714ab03785c4606f98c6e7c475200a8f005b04 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-06 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * BigIntegerTest.cs: Tests for GreatestCommonDivisor.
+
 2010-03-06 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * BigIntegerTest.cs: Tests for ModPow.