From ebd61e9999fe2685fe99a4b11b5950e3b07df822 Mon Sep 17 00:00:00 2001 From: kumpera Date: Sat, 6 Mar 2010 17:34:58 +0000 Subject: [PATCH] 2010-03-06 Rodrigo Kumpera * BigIntegerTest.cs: Tests for GreatestCommonDivisor. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@153191 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- .../Test/System.Numerics/BigIntegerTest.cs | 24 +++++++++++++++++++++- .../System.Numerics/Test/System.Numerics/ChangeLog | 4 ++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs b/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs index f5d1432430..5a1c0bf2c2 100644 --- a/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs +++ b/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs @@ -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] @@ -130,6 +129,29 @@ namespace MonoTests.System.Numerics } [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 { BigInteger c, d; diff --git a/class/System.Numerics/Test/System.Numerics/ChangeLog b/class/System.Numerics/Test/System.Numerics/ChangeLog index 9d4d4a9148..32714ab037 100644 --- a/class/System.Numerics/Test/System.Numerics/ChangeLog +++ b/class/System.Numerics/Test/System.Numerics/ChangeLog @@ -1,5 +1,9 @@ 2010-03-06 Rodrigo Kumpera + * BigIntegerTest.cs: Tests for GreatestCommonDivisor. + +2010-03-06 Rodrigo Kumpera + * BigIntegerTest.cs: Tests for ModPow. 2010-03-06 Rodrigo Kumpera -- 2.11.4.GIT