Browse Source

* DirectoryTest.cs: Restore original CurrentCulture on teardown.
* FileSystemInfoTest.cs: Restore original CurrentCulture on teardown.
Removed stray tabs. Code formatting.
* FileTest.cs: Restore original CurrentCulture on teardown. Removed
stray tabs. Changes spaces to tabs.
* ThreadTest.cs: Added tests for bug #81930.
* CultureInfoTest.cs: Added exception tests when invoking NumberFormat
or DateTimeFormat on a neutral culture. Added tests for bug #81930.
No longer derive from deprecated Assertion class. Added tests for
GetCultureInfo (2.0).
* ArrayTest.cs: Added test for bug #81941.
* ByteTest.cs: Restore original CurrentCulture in teardown.
* DecimalFormatterTest.cs: Restore original CurrentCulture in teardown.
Code formatting.
* DecimalTest.cs: Code formatting.
* DoubleFormatterTest.cs: Test relies on specific culture, so set it
up here. This worked before since the CurrentCulture was set in another
TestFixture, and the original one was not restored.
* FloatingPointFormatterTest.cs: Same.
* NumberFormatterTest.cs: Same. Removed stray tabs and fixes code
formatting.
* SingleFormatterTest.cs: Restore original culture on teardown. Code
formatting.
* SingleTest.cs: Same.
* StringComparerTest.cs: Restore original culture on teardown.

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

Gert Driesen 18 years ago
parent
commit
e80c7764f2

+ 11 - 0
mcs/class/corlib/System.Globalization/ChangeLog

@@ -1,3 +1,14 @@
+2007-06-24  Gert Driesen  <[email protected]>
+
+	* CultureInfo.cs: Added new private ctors that takes value for 
+	read-only bit as argument. In ContructInvariant, clone invariant 
+	NumberFormatInfo and DateTimeFormatInfo when we're not creating a
+	read-only CultureInfo, since they also should not be read-only.
+	Changes are required to allow a writable invariant CultureInfo to be
+	constructed. In GetCultures, use clone of InvariantCulture since it 
+	must be not be read-only. In GetCultureInfo, always construct
+	read-only CultureInfo's. Fixes part of bug #81930.
+
 2007-06-01  Atsushi Enomoto  <[email protected]>
 
 	* Calendar.cs DateTimeFormatInfo.cs : 2.0 API fixes.

+ 44 - 44
mcs/class/corlib/System.Globalization/CultureInfo.cs

@@ -109,8 +109,7 @@ namespace System.Globalization
 
 		static CultureInfo ()
 		{
-			invariant_culture_info = new CultureInfo (InvariantCultureId, false);
-			invariant_culture_info.m_isReadOnly = true;
+			invariant_culture_info = new CultureInfo (InvariantCultureId, false, true);
 		}
 		
 		public static CultureInfo CreateSpecificCulture (string name)
@@ -308,9 +307,14 @@ namespace System.Globalization
 
 			CultureInfo [] infos = internal_get_cultures (neutral, specific, installed);
 			// The runtime returns a NULL in the first position of the array when
-			// 'neutral' is true. We fill it in with the InvariantCulture.
-			if (neutral && infos.Length > 0 && infos [0] == null)
-				infos [0] = InvariantCulture;
+			// 'neutral' is true. We fill it in with a clone of InvariantCulture
+			// since it must not be read-only
+			if (neutral && infos.Length > 0 && infos [0] == null) {
+				infos [0] = (CultureInfo) InvariantCulture.Clone ();
+#if ONLY_1_1
+				infos [0].m_useUserOverride = true;
+#endif
+			}
 
 			return infos;
 		}
@@ -370,7 +374,7 @@ namespace System.Globalization
 		public virtual bool IsNeutralCulture {
 			get {
 				if (!constructed) Construct ();
-				if (cultureID == 0x7f)
+				if (cultureID == InvariantCultureId)
 					return false;
 
 				return ((cultureID & 0xff00) == 0 || specific_lcid == 0);
@@ -528,18 +532,6 @@ namespace System.Globalization
 			return true;
 		}
 
-		static CultureInfo [] GetCultures (bool neutral, bool specific, bool installed)
-		{
-			CultureInfo [] cis = internal_get_cultures (neutral, specific, installed);
-
-			// The runtime returns a NULL in the first position of the array when
-			// 'neutral' is true. We fill it in with the InvariantCulture.
-			if (neutral && cis.Length > 0 && cis [0] == null)
-				cis [0] = InvariantCulture;
-
-			return cis;
-		}
-
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]
 		private extern bool construct_internal_locale_from_lcid (int lcid);
 
@@ -566,18 +558,20 @@ namespace System.Globalization
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]
 		private extern static bool internal_is_lcid_neutral (int lcid, out bool is_neutral);
 
-		private unsafe void ConstructInvariant (bool use_user_override)
+		private unsafe void ConstructInvariant (bool read_only)
 		{
-			m_isReadOnly=false;
 			cultureID = InvariantCultureId;
-			this.m_useUserOverride=use_user_override;
 
 			/* NumberFormatInfo defaults to the invariant data */
 			numInfo=NumberFormatInfo.InvariantInfo;
-			
 			/* DateTimeFormatInfo defaults to the invariant data */
 			dateTimeInfo=DateTimeFormatInfo.InvariantInfo;
 
+			if (!read_only) {
+				numInfo = (NumberFormatInfo) numInfo.Clone ();
+				dateTimeInfo = (DateTimeFormatInfo) dateTimeInfo.Clone ();
+			}
+
 			textInfo=new TextInfo (this, cultureID, this.textinfo_data);
 
 			m_name=String.Empty;
@@ -589,18 +583,25 @@ namespace System.Globalization
 			icu_name="en_US_POSIX";
 			win3lang="IVL";
 		}
-		
-		public CultureInfo (int culture, bool use_user_override)
+
+		public CultureInfo (int culture) : this (culture, true) {}
+
+		public CultureInfo (int culture, bool use_user_override) :
+			this (culture, use_user_override, false) {}
+
+		private CultureInfo (int culture, bool use_user_override, bool read_only)
 		{
 			if (culture < 0)
-				throw new ArgumentOutOfRangeException ("Positive number required.",
-						"culture");
+				throw new ArgumentOutOfRangeException ("culture", "Positive "
+					+ "number required.");
 
 			constructed = true;
-			
-			if(culture==0x007f) {
+			m_isReadOnly = read_only;
+			m_useUserOverride = use_user_override;
+
+			if (culture == InvariantCultureId) {
 				/* Short circuit the invariant culture */
-				ConstructInvariant (use_user_override);
+				ConstructInvariant (read_only);
 				return;
 			}
 
@@ -610,18 +611,23 @@ namespace System.Globalization
 							"supported culture.", culture), "culture");
 		}
 
-		public CultureInfo (int culture) : this (culture, false) {}
-		
-		public CultureInfo (string name, bool use_user_override)
+		public CultureInfo (string name) : this (name, true) {}
+
+		public CultureInfo (string name, bool use_user_override) :
+			this (name, use_user_override, false) {}
+
+		private CultureInfo (string name, bool use_user_override, bool read_only)
 		{
 			if (name == null)
-				throw new ArgumentNullException ();
+				throw new ArgumentNullException ("name");
 
 			constructed = true;
-			
-			if(name.Length==0) {
+			m_isReadOnly = read_only;
+			m_useUserOverride = use_user_override;
+
+			if (name.Length == 0) {
 				/* Short circuit the invariant culture */
-				ConstructInvariant (use_user_override);
+				ConstructInvariant (read_only);
 				return;
 			}
 
@@ -630,8 +636,6 @@ namespace System.Globalization
 						" is not supported.", "name");
 		}
 
-		public CultureInfo (string name) : this (name, true) {}
-
 		// This is used when creating by specific name and creating by
 		// current locale so we can initialize the object without
 		// doing any member initialization
@@ -660,9 +664,7 @@ namespace System.Globalization
 					if (c != null)
 						return (CultureInfo) c;
 				}
-				c = new CultureInfo (culture);
-				c.m_isReadOnly = true;
-
+				c = new CultureInfo (culture, false, true);
 				insert_into_shared_tables (c);
 				return c;
 			}
@@ -681,10 +683,8 @@ namespace System.Globalization
 					if (c != null)
 						return (CultureInfo) c;
 				}
-				c = new CultureInfo (name);
-				c.m_isReadOnly = true;
+				c = new CultureInfo (name, false, true);
 				insert_into_shared_tables (c);
-
 				return c;
 			}
 		}

+ 7 - 0
mcs/class/corlib/Test/System.Globalization/ChangeLog

@@ -1,3 +1,10 @@
+2007-06-24  Gert Driesen  <[email protected]>
+
+	* CultureInfoTest.cs: Added exception tests when invoking NumberFormat
+	or DateTimeFormat on a neutral culture. Added tests for bug #81930.
+	No longer derive from deprecated Assertion class. Added tests for
+	GetCultureInfo (2.0).
+
 2007-06-01  Atsushi Enomoto  <[email protected]>
 
 	* CalendarTest.cs : test for bug #81783 and AddYears() for leap year

+ 429 - 12
mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs

@@ -7,19 +7,160 @@
 // (c) 2005 Novell, Inc. (http://www.novell.com)
 //
 
-using NUnit.Framework;
-using System.IO;
 using System;
 using System.Globalization;
+using System.IO;
 using System.Threading;
 
+using NUnit.Framework;
+
 namespace MonoTests.System.Globalization
 {
 	[TestFixture]
-	public class CultureInfoTest : Assertion
+	public class CultureInfoTest
 	{
+		CultureInfo old_culture;
+
+		[SetUp]
+		public void Setup ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
+		[Test]
+		public void Constructor0 ()
+		{
+			CultureInfo ci = new CultureInfo (2067);
+			Assert.IsFalse (ci.IsReadOnly, "#1");
+			Assert.AreEqual (2067, ci.LCID, "#2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#3");
+			Assert.IsTrue (ci.UseUserOverride, "#4");
+		}
+
+		[Test]
+		public void Constructor0_Identifier_Negative ()
+		{
+			try {
+				new CultureInfo (-1);
+				Assert.Fail ("#1");
+			} catch (ArgumentOutOfRangeException ex) {
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("culture", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void Constructor1 ()
+		{
+			CultureInfo ci = new CultureInfo ("nl-BE");
+			Assert.IsFalse (ci.IsReadOnly, "#1");
+			Assert.AreEqual (2067, ci.LCID, "#2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#3");
+			Assert.IsTrue (ci.UseUserOverride, "#4");
+		}
+
+		[Test]
+		public void Constructor1_Name_Null ()
+		{
+			try {
+				new CultureInfo ((string) null);
+				Assert.Fail ("#1");
+			} catch (ArgumentNullException ex) {
+				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("name", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void Constructor2 ()
+		{
+			CultureInfo ci = new CultureInfo (2067, false);
+			Assert.IsFalse (ci.IsReadOnly, "#A1");
+			Assert.AreEqual (2067, ci.LCID, "#A2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#A3");
+			Assert.IsFalse (ci.UseUserOverride, "#A4");
+
+			ci = new CultureInfo (2067, true);
+			Assert.IsFalse (ci.IsReadOnly, "#B1");
+			Assert.AreEqual (2067, ci.LCID, "#B2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#B3");
+			Assert.IsTrue (ci.UseUserOverride, "#B4");
+		}
+
 		[Test]
-		public void GetAllCulturesInvariant () // bug #72081
+		public void Constructor2_Identifier_Negative ()
+		{
+			try {
+				new CultureInfo (-1, false);
+				Assert.Fail ("#1");
+			} catch (ArgumentOutOfRangeException ex) {
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("culture", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void Constructor3 ()
+		{
+			CultureInfo ci = new CultureInfo ("nl-BE", false);
+			Assert.IsFalse (ci.IsReadOnly, "#A1");
+			Assert.AreEqual (2067, ci.LCID, "#A2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#A3");
+			Assert.IsFalse (ci.UseUserOverride, "#A4");
+
+			ci = new CultureInfo ("nl-BE", true);
+			Assert.IsFalse (ci.IsReadOnly, "#B1");
+			Assert.AreEqual (2067, ci.LCID, "#B2");
+			Assert.AreEqual ("nl-BE", ci.Name, "#B3");
+			Assert.IsTrue (ci.UseUserOverride, "#B4");
+		}
+
+		[Test]
+		public void Constructor3_Name_Null ()
+		{
+			try {
+				new CultureInfo ((string) null, false);
+				Assert.Fail ("#1");
+			} catch (ArgumentNullException ex) {
+				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("name", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void DateTimeFormat_Neutral_Culture ()
+		{
+			CultureInfo ci = new CultureInfo ("nl");
+			try {
+				DateTimeFormatInfo dfi = ci.DateTimeFormat;
+				Assert.Fail ("#1:" + (dfi != null));
+			} catch (NotSupportedException ex) {
+				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+			}
+		}
+
+		[Test] // bug #72081
+		public void GetAllCulturesInvariant ()
 		{
 			CultureInfo invariant = CultureInfo.InvariantCulture;
 			CultureInfo [] infos = CultureInfo.GetCultures (CultureTypes.AllCultures);
@@ -28,7 +169,7 @@ namespace MonoTests.System.Globalization
 					return;
 			}
 
-			Assert ("InvariantCulture not found in the array from GetCultures()", false);
+			Assert.Fail ("InvariantCulture not found in the array from GetCultures()");
 		}
 
 		[Test]
@@ -45,25 +186,301 @@ namespace MonoTests.System.Globalization
 		{
 			foreach (CultureInfo ci in CultureInfo.GetCultures (
 				CultureTypes.AllCultures))
-				AssertNotNull (String.Format ("{0} {1}",
-					ci.LCID, ci.Name), ci.OptionalCalendars);
+				Assert.IsNotNull (ci.OptionalCalendars, String.Format ("{0} {1}",
+					ci.LCID, ci.Name));
 		}
 
-		[Test]
-		public void CloneNeutral () // bug #77347
+		[Test] // bug #77347
+		public void CloneNeutral ()
 		{
 			CultureInfo culture = new CultureInfo ("en");
 			CultureInfo cultureClone = culture.Clone () as CultureInfo;
-			Assert (culture.Equals (cultureClone));
+			Assert.IsTrue (culture.Equals (cultureClone));
+		}
+
+		[Test] // bug #81930
+		public void IsReadOnly ()
+		{
+			CultureInfo ci;
+
+			ci = new CultureInfo ("en-US");
+			Assert.IsFalse (ci.IsReadOnly, "#A1");
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#A2");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#A3");
+			ci.NumberFormat.NumberGroupSeparator = ",";
+			ci.NumberFormat = new NumberFormatInfo ();
+			ci.DateTimeFormat.DateSeparator = "/";
+			ci.DateTimeFormat = new DateTimeFormatInfo ();
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#A4");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#A5");
+
+			ci = new CultureInfo (CultureInfo.InvariantCulture.LCID);
+			Assert.IsFalse (ci.IsReadOnly, "#B1");
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#B2");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#B3");
+			ci.NumberFormat.NumberGroupSeparator = ",";
+			ci.NumberFormat = new NumberFormatInfo ();
+			ci.DateTimeFormat.DateSeparator = "/";
+			ci.DateTimeFormat = new DateTimeFormatInfo ();
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#B4");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#B5");
+
+			ci = CultureInfo.CurrentCulture;
+			Assert.IsTrue (ci.IsReadOnly, "#C1:" + ci.DisplayName);
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#C2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#C3");
+			try {
+				ci.NumberFormat.NumberGroupSeparator = ",";
+				Assert.Fail ("#C4");
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C5");
+				Assert.IsNull (ex.InnerException, "#C6");
+				Assert.IsNotNull (ex.Message, "#C7");
+			}
+
+			ci = CultureInfo.CurrentUICulture;
+			Assert.IsTrue (ci.IsReadOnly, "#D1");
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#D2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#D3");
+			try {
+				ci.NumberFormat.NumberGroupSeparator = ",";
+				Assert.Fail ("#D4");
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D5");
+				Assert.IsNull (ex.InnerException, "#D6");
+				Assert.IsNotNull (ex.Message, "#D7");
+			}
+
+			ci = CultureInfo.InvariantCulture;
+			Assert.IsTrue (ci.IsReadOnly, "#F1");
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#F2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#F3");
+			try {
+				ci.NumberFormat.NumberGroupSeparator = ",";
+				Assert.Fail ("#F4");
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F5");
+				Assert.IsNull (ex.InnerException, "#F6");
+				Assert.IsNotNull (ex.Message, "#F7");
+			}
+
+			ci = new CultureInfo (string.Empty);
+			Assert.IsFalse (ci.IsReadOnly, "#G1");
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#G2");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#G3");
+			ci.NumberFormat.NumberGroupSeparator = ",";
+			ci.NumberFormat = new NumberFormatInfo ();
+			ci.DateTimeFormat.DateSeparator = "/";
+			ci.DateTimeFormat = new DateTimeFormatInfo ();
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#G4");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#G5");
+		}
+
+		[Test]
+		public void IsReadOnly_GetCultures ()
+		{
+			foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
+				string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
+				Assert.IsFalse (ci.IsReadOnly, "#1:" + cultureMsg);
+				if (ci.IsNeutralCulture)
+					continue;
+				Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#2:" + cultureMsg);
+				Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#3:" + cultureMsg);
+			}
 		}
 
 		[Test]
-		public void Norwegian () // bug #69652
+		[Category ("NotWorking")]
+		public void IsReadOnly_InstalledUICulture ()
+		{
+			CultureInfo ci = CultureInfo.InstalledUICulture;
+			Assert.IsTrue (ci.IsReadOnly, "#1");
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#3");
+			try {
+				ci.NumberFormat.NumberGroupSeparator = ",";
+				Assert.Fail ("#4");
+			} catch (InvalidOperationException ex) {
+				Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#5");
+				Assert.IsNull (ex.InnerException, "#6");
+				Assert.IsNotNull (ex.Message, "#7");
+			}
+		}
+
+		[Test] // bug #69652
+		public void Norwegian ()
 		{
 			new CultureInfo ("no");
 			new CultureInfo ("nb-NO");
 			new CultureInfo ("nn-NO");
 		}
+
+		[Test]
+		public void NumberFormat_Neutral_Culture ()
+		{
+			CultureInfo ci = new CultureInfo ("nl");
+			try {
+				NumberFormatInfo nfi = ci.NumberFormat;
+				Assert.Fail ("#1:" + (nfi != null));
+			} catch (NotSupportedException ex) {
+				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+			}
+		}
+
+#if NET_2_0
+		[Test]
+		[Category ("NotDotNet")] // On MS, the NumberFormatInfo of the CultureInfo matching the current locale is not read-only
+		public void GetCultureInfo_Identifier ()
+		{
+			foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
+				string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
+				CultureInfo culture = CultureInfo.GetCultureInfo (ci.LCID);
+				Assert.IsTrue (culture.IsReadOnly, "#1:" + cultureMsg);
+				if (culture.IsNeutralCulture)
+					continue;
+				Assert.IsTrue (culture.NumberFormat.IsReadOnly, "#2:" + cultureMsg);
+				Assert.IsTrue (culture.DateTimeFormat.IsReadOnly, "#3:" + cultureMsg);
+			}
+		}
+
+		[Test]
+		public void GetCultureInfo_Identifier_Negative ()
+		{
+			try {
+				CultureInfo.GetCultureInfo (-1);
+				Assert.Fail ("#1");
+			} catch (ArgumentOutOfRangeException ex) {
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("culture", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void GetCultureInfo_Identifier_NotSupported ()
+		{
+			try {
+				CultureInfo.GetCultureInfo (666);
+				Assert.Fail ("#1");
+			} catch (ArgumentException ex) {
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("culture", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		[Category ("NotDotNet")] // On MS, the NumberFormatInfo of the CultureInfo matching the current locale is not read-only
+		public void GetCultureInfo_Name ()
+		{
+			foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
+				string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
+				CultureInfo culture = CultureInfo.GetCultureInfo (ci.Name);
+				Assert.IsTrue (culture.IsReadOnly, "#1:" + cultureMsg);
+				if (culture.IsNeutralCulture)
+					continue;
+				Assert.IsTrue (culture.NumberFormat.IsReadOnly, "#2:" + cultureMsg);
+				Assert.IsTrue (culture.DateTimeFormat.IsReadOnly, "#3:" + cultureMsg);
+			}
+		}
+
+		[Test]
+		public void GetCultureInfo_Name_NotSupported ()
+		{
+			try {
+				CultureInfo.GetCultureInfo ("666");
+				Assert.Fail ("#1");
+			} catch (ArgumentException ex) {
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("name", ex.ParamName, "#6");
+			}
+		}
+
+		[Test]
+		public void GetCultureInfo_Name_Null ()
+		{
+			try {
+				CultureInfo.GetCultureInfo ((string) null);
+				Assert.Fail ("#1");
+			} catch (ArgumentNullException ex) {
+				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsNotNull (ex.ParamName, "#5");
+				Assert.AreEqual ("name", ex.ParamName, "#6");
+			}
+		}
+#endif
+
+		[Test]
+		public void UseUserOverride_CurrentCulture ()
+		{
+			CultureInfo ci = CultureInfo.CurrentCulture;
+			Assert.IsTrue (ci.UseUserOverride, "#1");
+
+			ci = (CultureInfo) ci.Clone ();
+			Assert.IsTrue (ci.UseUserOverride, "#2");
+		}
+
+		[Test]
+		public void UseUserOverride_CurrentUICulture ()
+		{
+			CultureInfo ci = CultureInfo.CurrentCulture;
+			Assert.IsTrue (ci.UseUserOverride, "#1");
+
+			ci = (CultureInfo) ci.Clone ();
+			Assert.IsTrue (ci.UseUserOverride, "#2");
+		}
+
+#if NET_2_0
+		[Test]
+		public void UseUserOverride_GetCultureInfo ()
+		{
+			CultureInfo culture;
+
+			foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
+				string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
+				culture = CultureInfo.GetCultureInfo (ci.Name);
+				Assert.IsFalse (culture.UseUserOverride, "#1: " + cultureMsg);
+				culture = CultureInfo.GetCultureInfo (ci.LCID);
+				Assert.IsFalse (culture.UseUserOverride, "#2: " + cultureMsg);
+			}
+		}
+#endif
+
+		[Test]
+		public void UseUserOverride_GetCultures ()
+		{
+			foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
+				string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
+#if NET_2_0
+				if (ci.LCID == CultureInfo.InvariantCulture.LCID)
+					Assert.IsFalse (ci.UseUserOverride, cultureMsg);
+				else
+					Assert.IsTrue (ci.UseUserOverride, cultureMsg);
+#else
+				Assert.IsTrue (ci.UseUserOverride, cultureMsg);
+#endif
+			}
+		}
+
+		[Test]
+		public void UseUserOverride_InvariantCulture ()
+		{
+			CultureInfo ci = CultureInfo.InvariantCulture;
+			Assert.IsFalse (ci.UseUserOverride, "#21");
+
+			ci = (CultureInfo) ci.Clone ();
+			Assert.IsFalse (ci.UseUserOverride, "#2");
+		}
 	}
 }
-

+ 8 - 0
mcs/class/corlib/Test/System.IO/ChangeLog

@@ -1,3 +1,11 @@
+2007-06-24  Gert Driesen  <[email protected]>
+
+	* DirectoryTest.cs: Restore original CurrentCulture on teardown.
+	* FileSystemInfoTest.cs: Restore original CurrentCulture on teardown.
+	Removed stray tabs. Code formatting.
+	* FileTest.cs: Restore original CurrentCulture on teardown. Removed
+	stray tabs. Changes spaces to tabs.
+
 2007-06-22  Gert Driesen  <[email protected]>
 
 	* FileStreamTest.cs: Added test for bug #79250.

+ 4 - 2
mcs/class/corlib/Test/System.IO/DirectoryTest.cs

@@ -24,6 +24,7 @@ namespace MonoTests.System.IO
 [TestFixture]
 public class DirectoryTest
 {
+	CultureInfo old_culture;
 	string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
 	static readonly char DSC = Path.DirectorySeparatorChar;
 
@@ -32,14 +33,15 @@ public class DirectoryTest
 	{
 		if (!Directory.Exists (TempFolder))
 			Directory.CreateDirectory (TempFolder);
-
-		Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
+		old_culture = Thread.CurrentThread.CurrentCulture;
+		Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
 	}
 	
 	[TearDown]
 	public void TearDown () {
 		if (Directory.Exists (TempFolder))
 			Directory.Delete (TempFolder, true);
+		Thread.CurrentThread.CurrentCulture = old_culture;
 	}
 
 	[Test]

+ 22 - 18
mcs/class/corlib/Test/System.IO/FileSystemInfoTest.cs

@@ -5,34 +5,38 @@
 // (C) 2003 Ville Palo
 // 
 
-using NUnit.Framework;
 using System;
-using System.IO;
 using System.Globalization;
+using System.IO;
 using System.Threading;
 
+using NUnit.Framework;
 
 namespace MonoTests.System.IO
 {
 	[TestFixture]
-        public class FileSystemInfoTest : Assertion
+	public class FileSystemInfoTest : Assertion
 	{
+		CultureInfo old_culture;
 		string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
 		static readonly char DSC = Path.DirectorySeparatorChar;
 
 		[SetUp]
-		protected void SetUp() 
+		protected void SetUp()
 		{
 			if (Directory.Exists (TempFolder))
 				Directory.Delete (TempFolder, true);
 			Directory.CreateDirectory (TempFolder);
-			Thread.CurrentThread.CurrentCulture = new CultureInfo ("EN-us");
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
 		}
 
 		[TearDown]
-		protected void TearDown() {
+		protected void TearDown()
+		{
 			if (Directory.Exists (TempFolder))
 				Directory.Delete (TempFolder, true);
+			Thread.CurrentThread.CurrentCulture = old_culture;
 		}
 		
 		bool Windows
@@ -75,14 +79,14 @@ namespace MonoTests.System.IO
 			string path = TempFolder + DSC + "FSIT.CreationTime.Test";
 			DeleteFile (path);
 			if (Unix) {  // Unix doesn't support CreationTimes
-			  return;
+				return;
 			}
 			try {
 				File.Create (path).Close ();
 				FileSystemInfo info = new FileInfo (path);
 				info.CreationTime = new DateTime (1999, 12, 31, 11, 59, 59);
 
-				DateTime time = info.CreationTime;				
+				DateTime time = info.CreationTime;
 				AssertEquals ("test#01", 1999, time.Year);
 				AssertEquals ("test#02", 12, time.Month);
 				AssertEquals ("test#03", 31, time.Day);
@@ -90,7 +94,7 @@ namespace MonoTests.System.IO
 				AssertEquals ("test#05", 59, time.Minute);
 				AssertEquals ("test#06", 59, time.Second);
 				
-				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);	
+				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);
 				AssertEquals ("test#07", 1999, time.Year);
 				AssertEquals ("test#08", 12, time.Month);
 				AssertEquals ("test#09", 31, time.Day);
@@ -100,7 +104,7 @@ namespace MonoTests.System.IO
 				
 				info.CreationTimeUtc = new DateTime (1999, 12, 31, 11, 59, 59);
 
-				time = TimeZone.CurrentTimeZone.ToUniversalTime (info.CreationTime);				
+				time = TimeZone.CurrentTimeZone.ToUniversalTime (info.CreationTime);
 				AssertEquals ("test#13", 1999, time.Year);
 				AssertEquals ("test#14", 12, time.Month);
 				AssertEquals ("test#15", 31, time.Day);
@@ -108,7 +112,7 @@ namespace MonoTests.System.IO
 				AssertEquals ("test#17", 59, time.Minute);
 				AssertEquals ("test#18", 59, time.Second);
 
-				time = info.CreationTimeUtc;	
+				time = info.CreationTimeUtc;
 				AssertEquals ("test#19", 1999, time.Year);
 				AssertEquals ("test#20", 12, time.Month);
 				AssertEquals ("test#21", 31, time.Day);
@@ -128,19 +132,19 @@ namespace MonoTests.System.IO
 			string path = TempFolder + DSC + "FSIT.CreationTimeDirectory.Test";
 			DeleteDir (path);
 			if (Unix) {  // Unix doesn't support CreationTimes
-			  return;
+				return;
 			}
 			
-			try {				
+			try {
 				FileSystemInfo info = Directory.CreateDirectory (path);
 				info.CreationTime = new DateTime (1999, 12, 31, 11, 59, 59);
-				DateTime time = info.CreationTime;	
+				DateTime time = info.CreationTime;
 				
 				AssertEquals ("test#01", 1999, time.Year);
 				AssertEquals ("test#02", 12, time.Month);
 				AssertEquals ("test#03", 31, time.Day);
 				
-				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);	
+				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);
 				AssertEquals ("test#07", 1999, time.Year);
 				AssertEquals ("test#08", 12, time.Month);
 				AssertEquals ("test#09", 31, time.Day);
@@ -148,12 +152,12 @@ namespace MonoTests.System.IO
 				
 				info.CreationTimeUtc = new DateTime (1999, 12, 31, 11, 59, 59);
 				
-				time = TimeZone.CurrentTimeZone.ToUniversalTime (info.CreationTime);				
+				time = TimeZone.CurrentTimeZone.ToUniversalTime (info.CreationTime);
 				AssertEquals ("test#13", 1999, time.Year);
 				AssertEquals ("test#14", 12, time.Month);
 				AssertEquals ("test#15", 31, time.Day);
 				
-				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);	
+				time = TimeZone.CurrentTimeZone.ToLocalTime (info.CreationTimeUtc);
 				AssertEquals ("test#19", 1999, time.Year);
 				AssertEquals ("test#20", 12, time.Month);
 				AssertEquals ("test#21", 31, time.Day);
@@ -274,7 +278,7 @@ namespace MonoTests.System.IO
 				AssertEquals ("test#13", 2000, time.Year);
 				AssertEquals ("test#14", 1, time.Month);
 				AssertEquals ("test#15", 1, time.Day);
-				AssertEquals ("test#16", 1, time.Hour);				
+				AssertEquals ("test#16", 1, time.Hour);
 				
 			} finally {
 				DeleteFile (path);

+ 285 - 290
mcs/class/corlib/Test/System.IO/FileTest.cs

@@ -20,6 +20,7 @@ namespace MonoTests.System.IO
 	[TestFixture]
 	public class FileTest : Assertion
 	{
+		CultureInfo old_culture;
 		static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
 
 		[SetUp]
@@ -28,8 +29,8 @@ namespace MonoTests.System.IO
 			if (Directory.Exists (TempFolder))
 				Directory.Delete (TempFolder, true);
 			Directory.CreateDirectory (TempFolder);
-		
-                        Thread.CurrentThread.CurrentCulture = new CultureInfo ("EN-us");
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
 		}
 
 		[TearDown]
@@ -37,6 +38,7 @@ namespace MonoTests.System.IO
 		{
 			if (Directory.Exists (TempFolder))
 				Directory.Delete (TempFolder, true);
+			Thread.CurrentThread.CurrentCulture = old_culture;
 		}
 
 		[Test]
@@ -51,7 +53,7 @@ namespace MonoTests.System.IO
 				Assert ("empty filename should not exist", !File.Exists (""));
 				i++;
 				Assert ("whitespace filename should not exist", !File.Exists ("  \t\t  \t \n\t\n \n"));
-				i++;				
+				i++;
 				DeleteFile (path);
 				s = File.Create (path);
 				s.Close ();
@@ -83,28 +85,28 @@ namespace MonoTests.System.IO
 		[Test]
 		[ExpectedException(typeof (ArgumentNullException))]
 		public void CtorArgumentNullException1 ()
-		{	
+		{
 			FileStream stream = File.Create (null);
 		}
 
 		[Test]
 		[ExpectedException(typeof (ArgumentException))]
 		public void CtorArgumentException1 ()
-		{	
+		{
 			FileStream stream = File.Create ("");
 		}
 
 		[Test]
 		[ExpectedException(typeof (ArgumentException))]
 		public void CtorArgumentException2 ()
-		{	
+		{
 			FileStream stream = File.Create (" ");
 		}
 
 		[Test]
 		[ExpectedException(typeof (DirectoryNotFoundException))]
 		public void CtorDirectoryNotFoundException ()
-		{	
+		{
 			FileStream stream = null;
 			string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo";
 			
@@ -214,7 +216,7 @@ namespace MonoTests.System.IO
 				File.Copy (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", TempFolder + Path.DirectorySeparatorChar + "bar");
 			} finally {
 				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "bar");
-				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");				
+				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");
 			}
 		}
 
@@ -249,7 +251,7 @@ namespace MonoTests.System.IO
 			}finally {
 				DeleteFile (path1);
 				DeleteFile (path2);
-			}			
+			}
 		}
 
 		[Test]
@@ -280,7 +282,7 @@ namespace MonoTests.System.IO
 			string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo";
 			if (Directory.Exists (path))
 				Directory.Delete (path, true);
-			File.Delete (path);			
+			File.Delete (path);
 		}
 
 
@@ -292,14 +294,14 @@ namespace MonoTests.System.IO
 			try {
 				File.Create (foopath).Close ();
 
-                        	try {
-                                	File.Delete (foopath);
-	                       	} catch (Exception e) {
-        	                        Fail ("Unable to delete " + foopath + " e=" + e.ToString());
-                        	} 
+				try {
+					File.Delete (foopath);
+				} catch (Exception e) {
+					Fail ("Unable to delete " + foopath + " e=" + e.ToString());
+				} 
 				Assert ("File " + foopath + " should not exist after File.Delete", !File.Exists (foopath));
 			} finally {
-			        DeleteFile (foopath);
+				DeleteFile (foopath);
 			}
 		}
 
@@ -309,7 +311,7 @@ namespace MonoTests.System.IO
 		public void DeleteOpenStreamException ()
 		{
 			string path = TempFolder + Path.DirectorySeparatorChar + "DeleteOpenStreamException";
-			DeleteFile (path);			
+			DeleteFile (path);
 			FileStream stream = null;
 			try {
 				stream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
@@ -325,7 +327,7 @@ namespace MonoTests.System.IO
 		[ExpectedException(typeof (ArgumentNullException))]
 		public void MoveException1 ()
 		{
-	                File.Move (null, "b");
+			File.Move (null, "b");
 		}
 
 		[Test]
@@ -339,36 +341,36 @@ namespace MonoTests.System.IO
 		[ExpectedException(typeof (ArgumentException))]
 		public void MoveException3 ()
 		{
-                	File.Move ("", "b");
+			File.Move ("", "b");
 		}
 
 		[Test]
 		[ExpectedException(typeof (ArgumentException))]
 		public void MoveException4 ()
 		{
-                	File.Move ("a", "");
+			File.Move ("a", "");
 		}
 
 		[Test]
 		[ExpectedException(typeof (ArgumentException))]
 		public void MoveException5 ()
 		{
-                        File.Move (" ", "b");			
+			File.Move (" ", "b");
 		}
 
 		[Test]
 		[ExpectedException(typeof (ArgumentException))]
 		public void MoveException6 ()
 		{
-                	File.Move ("a", " ");
+			File.Move ("a", " ");
 		}
 
 		[Test]
 		[ExpectedException(typeof (FileNotFoundException))]
 		public void MoveException7 ()
 		{
-                       	DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist");			
-                        File.Move (TempFolder + Path.DirectorySeparatorChar + "doesnotexist", "b");
+			DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist");
+			File.Move (TempFolder + Path.DirectorySeparatorChar + "doesnotexist", "b");
 		}
 
 		[Test]
@@ -376,12 +378,12 @@ namespace MonoTests.System.IO
 		public void MoveException8 ()
 		{
 			string path = TempFolder + Path.DirectorySeparatorChar + "foo";
-                        DeleteFile (path);
+			DeleteFile (path);
 			try {
 				File.Create (TempFolder + Path.DirectorySeparatorChar + "AFile.txt").Close ();
-                        	File.Copy(TempFolder + Path.DirectorySeparatorChar + "AFile.txt", path, true);
-                        	DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
-                        	File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
+				File.Copy(TempFolder + Path.DirectorySeparatorChar + "AFile.txt", path, true);
+				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
+				File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
 			} finally {
 				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");
 				DeleteFile (path);
@@ -394,7 +396,7 @@ namespace MonoTests.System.IO
 		{
 			File.Create (TempFolder + Path.DirectorySeparatorChar + "foo").Close ();
 			try {
-                		File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder);		
+				File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder);
 			} finally {
 				DeleteFile (TempFolder + Path.DirectorySeparatorChar + "foo");
 			}
@@ -441,24 +443,24 @@ namespace MonoTests.System.IO
 		{
 			string path = "";
 			FileStream stream = null;
-                        try {
-                        	path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+			try {
+				path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
 				if (!File.Exists (path))
 					stream = File.Create (path);
-                        	stream.Close ();
-                                stream = File.Open (path, FileMode.Open);
 				stream.Close ();
-                        } catch (Exception e) {
-                                Fail ("Unable to open " + TempFolder + Path.DirectorySeparatorChar + "AFile.txt: e=" + e.ToString());
-                        } finally {
-                        	if (stream != null)
-                        		stream.Close ();
-                        	DeleteFile (path);
-                        }
+				stream = File.Open (path, FileMode.Open);
+				stream.Close ();
+			} catch (Exception e) {
+				Fail ("Unable to open " + TempFolder + Path.DirectorySeparatorChar + "AFile.txt: e=" + e.ToString());
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
 			
 			path = "";
 			stream = null;
-                        /* Exception tests */
+			/* Exception tests */
 			try {
 				path = TempFolder + Path.DirectorySeparatorChar + "filedoesnotexist";
 				stream = File.Open (path, FileMode.Open);
@@ -474,277 +476,271 @@ namespace MonoTests.System.IO
 			}
 		}
 
-                [Test]
-                public void Open () 
-                {
-                	string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+		[Test]
+		public void Open () 
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
 			if (!File.Exists (path))
 				File.Create (path).Close ();
 			FileStream stream = null;
-                	try {
-			
+			try {
 				stream = File.Open (path, FileMode.Open);
-                	
-                		Assertion.AssertEquals ("test#01", true, stream.CanRead);
-                		Assertion.AssertEquals ("test#02", true, stream.CanSeek);
-                		Assertion.AssertEquals ("test#03", true, stream.CanWrite);
-                		stream.Close ();
-                	
-                		stream = File.Open (path, FileMode.Open, FileAccess.Write);
-                		Assertion.AssertEquals ("test#04", false, stream.CanRead);
-                		Assertion.AssertEquals ("test#05", true, stream.CanSeek);
-                		Assertion.AssertEquals ("test#06", true, stream.CanWrite);
-                		stream.Close ();
-		                	
-                		stream = File.Open (path, FileMode.Open, FileAccess.Read);
-                		Assertion.AssertEquals ("test#04", true, stream.CanRead);
-                		Assertion.AssertEquals ("test#05", true, stream.CanSeek);
-                		Assertion.AssertEquals ("test#06", false, stream.CanWrite);
-                		stream.Close ();
-                		
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);
-                	}
-                }
-                
-                [Test]
-                [ExpectedException(typeof(ArgumentException))]
-                public void OpenException1 ()
-                {
-                	string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
-                	FileStream stream = null;
-                	// CreateNew + Read throws an exceptoin
-                	try {
-                		stream = File.Open (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", FileMode.CreateNew, FileAccess.Read);
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);
-                	}
-                }
-
-                [Test]
-                [ExpectedException(typeof(ArgumentException))]
-                public void OpenException2 ()
-                {
-                	string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
-                	FileStream s = null;
-                	// Append + Read throws an exceptoin
+				Assertion.AssertEquals ("test#01", true, stream.CanRead);
+				Assertion.AssertEquals ("test#02", true, stream.CanSeek);
+				Assertion.AssertEquals ("test#03", true, stream.CanWrite);
+				stream.Close ();
+
+				stream = File.Open (path, FileMode.Open, FileAccess.Write);
+				Assertion.AssertEquals ("test#04", false, stream.CanRead);
+				Assertion.AssertEquals ("test#05", true, stream.CanSeek);
+				Assertion.AssertEquals ("test#06", true, stream.CanWrite);
+				stream.Close ();
+
+				stream = File.Open (path, FileMode.Open, FileAccess.Read);
+				Assertion.AssertEquals ("test#04", true, stream.CanRead);
+				Assertion.AssertEquals ("test#05", true, stream.CanSeek);
+				Assertion.AssertEquals ("test#06", false, stream.CanWrite);
+				stream.Close ();
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		[ExpectedException(typeof(ArgumentException))]
+		public void OpenException1 ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+			FileStream stream = null;
+			// CreateNew + Read throws an exceptoin
+			try {
+				stream = File.Open (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", FileMode.CreateNew, FileAccess.Read);
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		[ExpectedException(typeof(ArgumentException))]
+		public void OpenException2 ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+			FileStream s = null;
+			// Append + Read throws an exceptoin
 			if (!File.Exists (path))
 				File.Create (path).Close ();
-                	try {
-                		s = File.Open (path, FileMode.Append, FileAccess.Read);
-                	} finally {
-                		if (s != null)
-                			s.Close ();
-                		DeleteFile (path);
-                	}
-                }
-                
-                [Test]
-                public void OpenRead ()
-                {
-                	string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+			try {
+				s = File.Open (path, FileMode.Append, FileAccess.Read);
+			} finally {
+				if (s != null)
+					s.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		public void OpenRead ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
 			if (!File.Exists (path))
 				File.Create (path).Close ();
-                	FileStream stream = null;
-                	
-                	try {
+			FileStream stream = null;
+			
+			try {
 				stream = File.OpenRead (path);
-                	
-                		Assertion.AssertEquals ("test#01", true, stream.CanRead);
-                		Assertion.AssertEquals ("test#02", true, stream.CanSeek);
-                		Assertion.AssertEquals ("test#03", false, stream.CanWrite);
-                		
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);
-                	}
-                }
-
-                [Test]
-                public void OpenWrite ()
-                {
-                	string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
+				Assertion.AssertEquals ("test#01", true, stream.CanRead);
+				Assertion.AssertEquals ("test#02", true, stream.CanSeek);
+				Assertion.AssertEquals ("test#03", false, stream.CanWrite);
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		public void OpenWrite ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
 			if (!File.Exists (path))
 				File.Create (path).Close ();
-                	FileStream stream = null;
-                	
-                	try {
+			FileStream stream = null;
+
+			try {
 				stream = File.OpenWrite (path);
-                		Assertion.AssertEquals ("test#01", false, stream.CanRead);
-                		Assertion.AssertEquals ("test#02", true, stream.CanSeek);
-                		Assertion.AssertEquals ("test#03", true, stream.CanWrite);
-                		stream.Close ();                				                	
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);
-                	}
-                }
+				Assertion.AssertEquals ("test#01", false, stream.CanRead);
+				Assertion.AssertEquals ("test#02", true, stream.CanSeek);
+				Assertion.AssertEquals ("test#03", true, stream.CanWrite);
+				stream.Close ();
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
 
 		[Test]
 		[Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
 		public void TestGetCreationTime ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "baz";
-                	DeleteFile (path);
-                	
-                	try {
+			string path = TempFolder + Path.DirectorySeparatorChar + "baz";
+			DeleteFile (path);
+
+			try {
 				File.Create (path).Close();
-                		DateTime time = File.GetCreationTime (path);
-                        	Assert ("GetCreationTime incorrect", (DateTime.Now - time).TotalSeconds < 10);
-                	} finally {
-                		DeleteFile (path);
-                	}
+				DateTime time = File.GetCreationTime (path);
+				Assert ("GetCreationTime incorrect", (DateTime.Now - time).TotalSeconds < 10);
+			} finally {
+				DeleteFile (path);
+			}
 		}
 
 		// Setting the creation time on Unix is not possible
-                [Test]
+		[Test]
 		[Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
-                public void CreationTime ()
-                {
+		public void CreationTime ()
+		{
 			int platform = (int) Environment.OSVersion.Platform;
 			if ((platform == 4) || (platform == 128))
 				return;
 
-                        string path = Path.GetTempFileName ();	
-                       	
-                       	try {
-                		File.SetCreationTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		DateTime time = File.GetCreationTime (path);
-                		Assertion.AssertEquals ("test#01", 2002, time.Year);
-                		Assertion.AssertEquals ("test#02", 4, time.Month);
-                		Assertion.AssertEquals ("test#03", 6, time.Day);
-                		Assertion.AssertEquals ("test#04", 4, time.Hour);
-                		Assertion.AssertEquals ("test#05", 4, time.Second);
-                	
-                		time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetCreationTimeUtc (path));
-                		Assertion.AssertEquals ("test#06", 2002, time.Year);
-                		Assertion.AssertEquals ("test#07", 4, time.Month);
-                		Assertion.AssertEquals ("test#08", 6, time.Day);
-                		Assertion.AssertEquals ("test#09", 4, time.Hour);
-                		Assertion.AssertEquals ("test#10", 4, time.Second);                	
-
-                		File.SetCreationTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		time = File.GetCreationTimeUtc (path);
-                		Assertion.AssertEquals ("test#11", 2002, time.Year);
-                		Assertion.AssertEquals ("test#12", 4, time.Month);
-                		Assertion.AssertEquals ("test#13", 6, time.Day);
-                		Assertion.AssertEquals ("test#14", 4, time.Hour);
-                		Assertion.AssertEquals ("test#15", 4, time.Second);
-                	
-                		time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetCreationTime (path));
-                		Assertion.AssertEquals ("test#16", 2002, time.Year);
-                		Assertion.AssertEquals ("test#17", 4, time.Month);
-                		Assertion.AssertEquals ("test#18", 6, time.Day);
-                		Assertion.AssertEquals ("test#19", 4, time.Hour);
-                		Assertion.AssertEquals ("test#20", 4, time.Second);
-                       	} finally {
-                       		DeleteFile (path);
-                       	}
-                }
-
-                [Test]
+			string path = Path.GetTempFileName ();
+			try {
+				File.SetCreationTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				DateTime time = File.GetCreationTime (path);
+				Assertion.AssertEquals ("test#01", 2002, time.Year);
+				Assertion.AssertEquals ("test#02", 4, time.Month);
+				Assertion.AssertEquals ("test#03", 6, time.Day);
+				Assertion.AssertEquals ("test#04", 4, time.Hour);
+				Assertion.AssertEquals ("test#05", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetCreationTimeUtc (path));
+				Assertion.AssertEquals ("test#06", 2002, time.Year);
+				Assertion.AssertEquals ("test#07", 4, time.Month);
+				Assertion.AssertEquals ("test#08", 6, time.Day);
+				Assertion.AssertEquals ("test#09", 4, time.Hour);
+				Assertion.AssertEquals ("test#10", 4, time.Second);
+
+				File.SetCreationTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				time = File.GetCreationTimeUtc (path);
+				Assertion.AssertEquals ("test#11", 2002, time.Year);
+				Assertion.AssertEquals ("test#12", 4, time.Month);
+				Assertion.AssertEquals ("test#13", 6, time.Day);
+				Assertion.AssertEquals ("test#14", 4, time.Hour);
+				Assertion.AssertEquals ("test#15", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetCreationTime (path));
+				Assertion.AssertEquals ("test#16", 2002, time.Year);
+				Assertion.AssertEquals ("test#17", 4, time.Month);
+				Assertion.AssertEquals ("test#18", 6, time.Day);
+				Assertion.AssertEquals ("test#19", 4, time.Hour);
+				Assertion.AssertEquals ("test#20", 4, time.Second);
+			} finally {
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
 		[Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
-                public void LastAccessTime ()
-                {
-                        string path = TempFolder + Path.DirectorySeparatorChar + "lastAccessTime";                	
-                        if (File.Exists (path))
-                        	File.Delete (path);
+		public void LastAccessTime ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "lastAccessTime";
+			if (File.Exists (path))
+				File.Delete (path);
 			FileStream stream = null;
-                	try {
-                       		stream = File.Create (path);
-                		stream.Close ();                	
-                	
-                		File.SetLastAccessTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		DateTime time = File.GetLastAccessTime (path);
-                		Assertion.AssertEquals ("test#01", 2002, time.Year);
-                		Assertion.AssertEquals ("test#02", 4, time.Month);
-                		Assertion.AssertEquals ("test#03", 6, time.Day);
-                		Assertion.AssertEquals ("test#04", 4, time.Hour);
-                		Assertion.AssertEquals ("test#05", 4, time.Second);
-                	
-                		time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastAccessTimeUtc (path));
-                		Assertion.AssertEquals ("test#06", 2002, time.Year);
-                		Assertion.AssertEquals ("test#07", 4, time.Month);
-                		Assertion.AssertEquals ("test#08", 6, time.Day);
-                		Assertion.AssertEquals ("test#09", 4, time.Hour);
-                		Assertion.AssertEquals ("test#10", 4, time.Second);                	
-	
-        	        	File.SetLastAccessTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		time = File.GetLastAccessTimeUtc (path);
-                		Assertion.AssertEquals ("test#11", 2002, time.Year);
-                		Assertion.AssertEquals ("test#12", 4, time.Month);
-                		Assertion.AssertEquals ("test#13", 6, time.Day);
-                		Assertion.AssertEquals ("test#14", 4, time.Hour);
-                		Assertion.AssertEquals ("test#15", 4, time.Second);
-                	
-	                	time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastAccessTime (path));
-                		Assertion.AssertEquals ("test#16", 2002, time.Year);
-                		Assertion.AssertEquals ("test#17", 4, time.Month);
-                		Assertion.AssertEquals ("test#18", 6, time.Day);
-                		Assertion.AssertEquals ("test#19", 4, time.Hour);
-                		Assertion.AssertEquals ("test#20", 4, time.Second);
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);                			
-                	}
-                }
-                
-                [Test]
-                public void LastWriteTime ()
-                {
-                        string path = TempFolder + Path.DirectorySeparatorChar + "lastWriteTime";                	
-                        if (File.Exists (path))
-                        	File.Delete (path);
-                    	FileStream stream = null;
-                	try {
-                       		stream = File.Create (path);
-                		stream.Close ();                	
-                	
-                		File.SetLastWriteTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		DateTime time = File.GetLastWriteTime (path);
-                		Assertion.AssertEquals ("test#01", 2002, time.Year);
-                		Assertion.AssertEquals ("test#02", 4, time.Month);
-                		Assertion.AssertEquals ("test#03", 6, time.Day);
-                		Assertion.AssertEquals ("test#04", 4, time.Hour);
-                		Assertion.AssertEquals ("test#05", 4, time.Second);
-	                	
-                		time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastWriteTimeUtc (path));
-                		Assertion.AssertEquals ("test#06", 2002, time.Year);
-                		Assertion.AssertEquals ("test#07", 4, time.Month);
-                		Assertion.AssertEquals ("test#08", 6, time.Day);
-                		Assertion.AssertEquals ("test#09", 4, time.Hour);
-                		Assertion.AssertEquals ("test#10", 4, time.Second);                	
-	
-                		File.SetLastWriteTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
-                		time = File.GetLastWriteTimeUtc (path);
-                		Assertion.AssertEquals ("test#11", 2002, time.Year);
-                		Assertion.AssertEquals ("test#12", 4, time.Month);
-                		Assertion.AssertEquals ("test#13", 6, time.Day);
-                		Assertion.AssertEquals ("test#14", 4, time.Hour);
-                		Assertion.AssertEquals ("test#15", 4, time.Second);
-	                	
-                		time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastWriteTime (path));
-                		Assertion.AssertEquals ("test#16", 2002, time.Year);
-                		Assertion.AssertEquals ("test#17", 4, time.Month);
-                		Assertion.AssertEquals ("test#18", 6, time.Day);
-                		Assertion.AssertEquals ("test#19", 4, time.Hour);
-                		Assertion.AssertEquals ("test#20", 4, time.Second);
-                	} finally {
-                		if (stream != null)
-                			stream.Close ();
-                		DeleteFile (path);
-                	}
-                }
-
-		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+			try {
+				stream = File.Create (path);
+				stream.Close ();
+
+				File.SetLastAccessTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				DateTime time = File.GetLastAccessTime (path);
+				Assertion.AssertEquals ("test#01", 2002, time.Year);
+				Assertion.AssertEquals ("test#02", 4, time.Month);
+				Assertion.AssertEquals ("test#03", 6, time.Day);
+				Assertion.AssertEquals ("test#04", 4, time.Hour);
+				Assertion.AssertEquals ("test#05", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastAccessTimeUtc (path));
+				Assertion.AssertEquals ("test#06", 2002, time.Year);
+				Assertion.AssertEquals ("test#07", 4, time.Month);
+				Assertion.AssertEquals ("test#08", 6, time.Day);
+				Assertion.AssertEquals ("test#09", 4, time.Hour);
+				Assertion.AssertEquals ("test#10", 4, time.Second);
+
+				File.SetLastAccessTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				time = File.GetLastAccessTimeUtc (path);
+				Assertion.AssertEquals ("test#11", 2002, time.Year);
+				Assertion.AssertEquals ("test#12", 4, time.Month);
+				Assertion.AssertEquals ("test#13", 6, time.Day);
+				Assertion.AssertEquals ("test#14", 4, time.Hour);
+				Assertion.AssertEquals ("test#15", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastAccessTime (path));
+				Assertion.AssertEquals ("test#16", 2002, time.Year);
+				Assertion.AssertEquals ("test#17", 4, time.Month);
+				Assertion.AssertEquals ("test#18", 6, time.Day);
+				Assertion.AssertEquals ("test#19", 4, time.Hour);
+				Assertion.AssertEquals ("test#20", 4, time.Second);
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		public void LastWriteTime ()
+		{
+			string path = TempFolder + Path.DirectorySeparatorChar + "lastWriteTime";
+			if (File.Exists (path))
+				File.Delete (path);
+			FileStream stream = null;
+			try {
+				stream = File.Create (path);
+				stream.Close ();
+
+				File.SetLastWriteTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				DateTime time = File.GetLastWriteTime (path);
+				Assertion.AssertEquals ("test#01", 2002, time.Year);
+				Assertion.AssertEquals ("test#02", 4, time.Month);
+				Assertion.AssertEquals ("test#03", 6, time.Day);
+				Assertion.AssertEquals ("test#04", 4, time.Hour);
+				Assertion.AssertEquals ("test#05", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastWriteTimeUtc (path));
+				Assertion.AssertEquals ("test#06", 2002, time.Year);
+				Assertion.AssertEquals ("test#07", 4, time.Month);
+				Assertion.AssertEquals ("test#08", 6, time.Day);
+				Assertion.AssertEquals ("test#09", 4, time.Hour);
+				Assertion.AssertEquals ("test#10", 4, time.Second);
+
+				File.SetLastWriteTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
+				time = File.GetLastWriteTimeUtc (path);
+				Assertion.AssertEquals ("test#11", 2002, time.Year);
+				Assertion.AssertEquals ("test#12", 4, time.Month);
+				Assertion.AssertEquals ("test#13", 6, time.Day);
+				Assertion.AssertEquals ("test#14", 4, time.Hour);
+				Assertion.AssertEquals ("test#15", 4, time.Second);
+
+				time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastWriteTime (path));
+				Assertion.AssertEquals ("test#16", 2002, time.Year);
+				Assertion.AssertEquals ("test#17", 4, time.Month);
+				Assertion.AssertEquals ("test#18", 6, time.Day);
+				Assertion.AssertEquals ("test#19", 4, time.Hour);
+				Assertion.AssertEquals ("test#20", 4, time.Second);
+			} finally {
+				if (stream != null)
+					stream.Close ();
+				DeleteFile (path);
+			}
+		}
+
+		[Test]
+		[ExpectedException(typeof(ArgumentNullException))]
 		[Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
 		public void GetCreationTimeException1 ()
 		{
@@ -752,7 +748,7 @@ namespace MonoTests.System.IO
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		[Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
 		public void GetCreationTimeException2 ()
 		{
@@ -1219,7 +1215,7 @@ namespace MonoTests.System.IO
 //			string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcArgumentOutOfRangeException1";
 //			DeleteFile (path);
 //			FileStream stream = null;
-//			try {				
+//			try {
 //				stream = File.Create (path);
 //				stream.Close ();
 //				File.SetCreationTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
@@ -1596,9 +1592,8 @@ namespace MonoTests.System.IO
 		public void OpenAppend ()
 		{
 			string fn = Path.GetTempFileName ();
-			using (FileStream s = File.Open (fn, FileMode.Append))
-				;
-			
+			using (FileStream s = File.Open (fn, FileMode.Append)) {
+			}
 			DeleteFile (fn);
 		}
 
@@ -1627,7 +1622,7 @@ namespace MonoTests.System.IO
 			TestRWAT ("\r\n");
 			TestRWAT ("a\r");
 			TestRWAT ("a\n");
-			TestRWAT ("a\r\n");	
+			TestRWAT ("a\r\n");
 			TestRWAT ("a\ra");
 			TestRWAT ("a\na");
 			TestRWAT ("a\r\na");

+ 4 - 0
mcs/class/corlib/Test/System.Threading/ChangeLog

@@ -1,3 +1,7 @@
+2007-06-24  Gert Driesen  <[email protected]>
+
+	* ThreadTest.cs: Added tests for bug #81930.
+
 2007-06-08  Gert Driesen  <[email protected]>
 
 	* ThreadTest.cs: Enabled test for bug #81720.

+ 60 - 2
mcs/class/corlib/Test/System.Threading/ThreadTest.cs

@@ -10,6 +10,7 @@
 //
 
 using System;
+using System.Globalization;
 using System.Security.Principal;
 using System.Threading;
 
@@ -596,7 +597,7 @@ namespace MonoTests.System.Threading
 			Assert.IsTrue (n < 200, "Timeout while waiting for abort");
 			
 			CheckIsNotRunning ("t6", t);
-		}		
+		}
 		
 		void CheckIsRunning (string s, Thread t)
 		{
@@ -788,7 +789,64 @@ namespace MonoTests.System.Threading
 			Assert.IsTrue (exception_occured, "Thread1 Started Invalid Exception Occured");
 		}
 	}
-	
+
+	[TestFixture]
+	public class ThreadCultureTest
+	{
+		CultureInfo old_culture;
+		CultureInfo old_ui_culture;
+
+		[SetUp]
+		public void Setup ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			old_ui_culture = Thread.CurrentThread.CurrentUICulture;
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+			Thread.CurrentThread.CurrentUICulture = old_ui_culture;
+		}
+
+		[Test] // bug #81930
+		public void CurrentCulture_IsReadOnly ()
+		{
+			CultureInfo ci;
+
+			ci = Thread.CurrentThread.CurrentCulture;
+			Assert.IsTrue (ci.IsReadOnly, "#A1");
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#A2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#A3");
+
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");
+
+			ci = Thread.CurrentThread.CurrentCulture;
+			Assert.IsFalse (ci.IsReadOnly, "#B1");
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#B2");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#B3");
+		}
+
+		[Test] // bug #81930
+		public void CurrentUICulture_IsReadOnly ()
+		{
+			CultureInfo ci;
+
+			ci = Thread.CurrentThread.CurrentUICulture;
+			Assert.IsTrue (ci.IsReadOnly, "#A1");
+			Assert.IsTrue (ci.NumberFormat.IsReadOnly, "#A2");
+			Assert.IsTrue (ci.DateTimeFormat.IsReadOnly, "#A3");
+
+			Thread.CurrentThread.CurrentUICulture = new CultureInfo ("nl-BE");
+
+			ci = Thread.CurrentThread.CurrentUICulture;
+			Assert.IsFalse (ci.IsReadOnly, "#B1");
+			Assert.IsFalse (ci.NumberFormat.IsReadOnly, "#B2");
+			Assert.IsFalse (ci.DateTimeFormat.IsReadOnly, "#B3");
+		}
+	}
+
 	public class TestUtil
 	{
 		public static void WaitForNotAlive (Thread t, string s)

+ 12 - 0
mcs/class/corlib/Test/System/ArrayTest.cs

@@ -2495,6 +2495,18 @@ public class ArrayTest : Assertion
 		Array.Sort (array, (IComparer) null);
 	}
 
+	[Test] // bug #81941
+	public void Sort ()
+	{
+		double [] a = new double [2] { 0.9, 0.3 };
+		uint [] b = new uint [2] { 4, 7 };
+		Array.Sort (a, b);
+		AssertEquals ("#1", 0.3, a [0]);
+		AssertEquals ("#2", 0.9, a [1]);
+		AssertEquals ("#3", 7, b [0]);
+		AssertEquals ("#4", 4, b [1]);
+	}
+
 	[Test]
 	public void ClearJaggedArray () 
 	{

+ 12 - 5
mcs/class/corlib/Test/System/ByteTest.cs

@@ -37,16 +37,17 @@ public class ByteTest : Assertion
 					"00255", "2.55000e+002", "255.00000",
 					"255", "255.00000", "25,500.00000 %", "000ff"};
 
+	private CultureInfo old_culture;
 	private NumberFormatInfo Nfi = NumberFormatInfo.InvariantInfo;
-	
-	public ByteTest() {}
 
 	[SetUp]
-	public void SetUp() 
+	public void SetUp ()
 	{
-                CultureInfo EnUs = new CultureInfo ("en-us", false);
+		old_culture = Thread.CurrentThread.CurrentCulture;
+
+		CultureInfo EnUs = new CultureInfo ("en-us", false);
 		EnUs.NumberFormat.NumberDecimalDigits = 2;
-                Thread.CurrentThread.CurrentCulture = EnUs;
+		Thread.CurrentThread.CurrentCulture = EnUs;
 
 		int cdd = NumberFormatInfo.CurrentInfo.CurrencyDecimalDigits;
 		string sep = NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator;
@@ -88,6 +89,12 @@ public class ByteTest : Assertion
 		Results2[6] = perPattern.Replace ("n","25" + gsep + "500" + sep + "00000");
 	}
 
+	[TearDown]
+	public void TearDown ()
+	{
+		Thread.CurrentThread.CurrentCulture = old_culture;
+	}
+
 	public void TestMinMax()
 	{
 		AssertEquals(Byte.MinValue, MyByte2);

+ 18 - 0
mcs/class/corlib/Test/System/ChangeLog

@@ -1,3 +1,21 @@
+2007-06-24  Gert Driesen  <[email protected]>
+
+	* ArrayTest.cs: Added test for bug #81941.
+	* ByteTest.cs: Restore original CurrentCulture in teardown.
+	* DecimalFormatterTest.cs: Restore original CurrentCulture in teardown.
+	Code formatting.
+	* DecimalTest.cs: Code formatting.
+	* DoubleFormatterTest.cs: Test relies on specific culture, so set it 
+	up here. This worked before since the CurrentCulture was set in another
+	TestFixture, and the original one was not restored.
+	* FloatingPointFormatterTest.cs: Same.
+	* NumberFormatterTest.cs: Same. Removed stray tabs and fixes code
+	formatting.
+	* SingleFormatterTest.cs: Restore original culture on teardown. Code
+	formatting.
+	* SingleTest.cs: Same.
+	* StringComparerTest.cs: Restore original culture on teardown.
+
 2007-06-06  Atsushi Enomoto  <[email protected]>
 
 	* ConvertTest.cs : another bogus DateTime test.

+ 355 - 351
mcs/class/corlib/Test/System/DecimalFormatterTest.cs

@@ -13,360 +13,364 @@ using System.Globalization;
 
 namespace MonoTests.System
 {
-        public class FormatString
-        {
-                private int testnumber;
-                private decimal number;
-                private string format;
-                private string expectedresult;
+	public class FormatString
+	{
+		private int testnumber;
+		private decimal number;
+		private string format;
+		private string expectedresult;
 
-                public FormatString(int TestNumber, decimal Number, string Format, string ExpectedResult)
-                {
-                        testnumber = TestNumber;
-                        number = Number;
-                        format = Format;
-                        expectedresult = ExpectedResult;
-                }
-                
-                public int TestNumber 
-                {
-                        get { return testnumber; }
-                        set { testnumber = value; }
-                }
+		public FormatString (int TestNumber, decimal Number, string Format, string ExpectedResult)
+		{
+			testnumber = TestNumber;
+			number = Number;
+			format = Format;
+			expectedresult = ExpectedResult;
+		}
 
-                public decimal Number 
-                {
-                        get { return number; }
-                        set { number = value; }
-                }
-                
-                public string Format
-                {
-                        get { return format; }
-                        set { format = value; }
-                }
-                
-                public string ExpectedResult
-                {
-                        get { return expectedresult; }
-                        set { expectedresult = value; }
-                }
-        }
+		public int TestNumber
+		{
+			get { return testnumber; }
+			set { testnumber = value; }
+		}
 
-        [TestFixture]
-        public class DecimalFormatterTest 
-        {
-                [SetUp]
-                public void GetReady() 
-                {
-                        CultureInfo EnUs = new CultureInfo ("en-us");
-                        EnUs.NumberFormat.CurrencyNegativePattern = 0; // -1 = (1)
-                        EnUs.NumberFormat.CurrencyDecimalSeparator = ".";
-                        EnUs.NumberFormat.NumberGroupSeparator = ",";
-                        EnUs.NumberFormat.NumberNegativePattern = 1; // -1 = -1
-                        
-                        //Set this culture for the current thread.
-                        Thread.CurrentThread.CurrentCulture = EnUs;
-                }
-                
-                [TearDown]
-                public void Clean() {}
-                
-                [Test]
-                public void TestFormatStrings()
-                {
-                        // Test all the formatstrings in the FormatTest array. 
-                        // If a test fails the "DecF #" equals the index of the array.
-                        foreach (FormatString fTest in FormatTest) {
-                                Assertion.AssertEquals ("DecF #" + fTest.TestNumber, fTest.ExpectedResult, fTest.Number.ToString(fTest.Format));                                
-                        }
-                }
+		public decimal Number
+		{
+			get { return number; }
+			set { number = value; }
+		}
 
-                
-                [Test]
-                [ExpectedException(typeof(FormatException))]
-                public void TestToDecimal()
-                {
-                        decimal x = 1.0000001m;
-                        string Result = x.ToString ("D2"); //To Decimal is for integral types only. 
-                }
-                
-                [Test]
-                [ExpectedException(typeof(FormatException))]
-                public void TestToHex()
-                {
-                        decimal x = 1.0000001m;
-                        string Result = x.ToString ("X2"); //To Hex is for integral types only. 
-                }
+		public string Format
+		{
+			get { return format; }
+			set { format = value; }
+		}
 
-                // Computer generated format array.
-                FormatString[] FormatTest = new FormatString[] {
-                        new FormatString(0, 1.0034m, "C", "$1.00"),  
-                        new FormatString(1, 1.0034m, "C0", "$1"),  
-                        new FormatString(2, 1.0034m, "C1", "$1.0"),  
-                        new FormatString(3, 1.0034m, "C2", "$1.00"),  
-                        new FormatString(4, 1.0034m, "C3", "$1.003"),  
-                        new FormatString(5, 1.0034m, "C4", "$1.0034"),  
-                        new FormatString(6, 1.0034m, "C5", "$1.00340"),  
-                        new FormatString(7, 1.0034m, "C6", "$1.003400"),  
-                        new FormatString(8, 1.0034m, "C7", "$1.0034000"),  
-                        new FormatString(9, 1.0034m, "C8", "$1.00340000"),  
-                        new FormatString(10, 1.0034m, "C9", "$1.003400000"),  
-                        new FormatString(11, 1.0034m, "E", "1.003400E+000"),  
-                        new FormatString(12, 1.0034m, "E0", "1E+000"),  
-                        new FormatString(13, 1.0034m, "E1", "1.0E+000"),  
-                        new FormatString(14, 1.0034m, "E2", "1.00E+000"),  
-                        new FormatString(15, 1.0034m, "E3", "1.003E+000"),  
-                        new FormatString(16, 1.0034m, "E4", "1.0034E+000"),  
-                        new FormatString(17, 1.0034m, "E5", "1.00340E+000"),  
-                        new FormatString(18, 1.0034m, "E6", "1.003400E+000"),  
-                        new FormatString(19, 1.0034m, "E7", "1.0034000E+000"),  
-                        new FormatString(20, 1.0034m, "E8", "1.00340000E+000"),  
-                        new FormatString(21, 1.0034m, "E9", "1.003400000E+000"),  
-                        new FormatString(22, 1.0034m, "F", "1.00"),  
-                        new FormatString(23, 1.0034m, "F0", "1"),  
-                        new FormatString(24, 1.0034m, "F1", "1.0"),  
-                        new FormatString(25, 1.0034m, "F2", "1.00"),  
-                        new FormatString(26, 1.0034m, "F3", "1.003"),  
-                        new FormatString(27, 1.0034m, "F4", "1.0034"),  
-                        new FormatString(28, 1.0034m, "F5", "1.00340"),  
-                        new FormatString(29, 1.0034m, "F6", "1.003400"),  
-                        new FormatString(30, 1.0034m, "F7", "1.0034000"),  
-                        new FormatString(31, 1.0034m, "F8", "1.00340000"),  
-                        new FormatString(32, 1.0034m, "F9", "1.003400000"),  
-                        new FormatString(33, 1.0034m, "G", "1.0034"),  
-                        new FormatString(34, 1.0034m, "G0", "1.0034"),  
-                        new FormatString(35, 1.0034m, "G1", "1"),  
-                        new FormatString(36, 1.0034m, "G2", "1"),  
-                        new FormatString(37, 1.0034m, "G3", "1"),  
-                        new FormatString(38, 1.0034m, "G4", "1.003"),  
-                        new FormatString(39, 1.0034m, "G5", "1.0034"),  
-                        new FormatString(40, 1.0034m, "G6", "1.0034"),  
-                        new FormatString(41, 1.0034m, "G7", "1.0034"),  
-                        new FormatString(42, 1.0034m, "G8", "1.0034"),  
-                        new FormatString(43, 1.0034m, "G9", "1.0034"),  
-                        new FormatString(44, 1.0034m, "N", "1.00"),  
-                        new FormatString(45, 1.0034m, "N0", "1"),  
-                        new FormatString(46, 1.0034m, "N1", "1.0"),  
-                        new FormatString(47, 1.0034m, "N2", "1.00"),  
-                        new FormatString(48, 1.0034m, "N3", "1.003"),  
-                        new FormatString(49, 1.0034m, "N4", "1.0034"),  
-                        new FormatString(50, 1.0034m, "N5", "1.00340"),  
-                        new FormatString(51, 1.0034m, "N6", "1.003400"),  
-                        new FormatString(52, 1.0034m, "N7", "1.0034000"),  
-                        new FormatString(53, 1.0034m, "N8", "1.00340000"),  
-                        new FormatString(54, 1.0034m, "N9", "1.003400000"),  
-                        new FormatString(55, 1.0034m, "P", "100.34 %"),  
-                        new FormatString(56, 1.0034m, "P0", "100 %"),  
-                        new FormatString(57, 1.0034m, "P1", "100.3 %"),  
-                        new FormatString(58, 1.0034m, "P2", "100.34 %"),  
-                        new FormatString(59, 1.0034m, "P3", "100.340 %"),  
-                        new FormatString(60, 1.0034m, "P4", "100.3400 %"),  
-                        new FormatString(61, 1.0034m, "P5", "100.34000 %"),  
-                        new FormatString(62, 1.0034m, "P6", "100.340000 %"),  
-                        new FormatString(63, 1.0034m, "P7", "100.3400000 %"),  
-                        new FormatString(64, 1.0034m, "P8", "100.34000000 %"),  
-                        new FormatString(65, 1.0034m, "P9", "100.340000000 %"),  
-                        new FormatString(66, 343433.223m, "C", "$343,433.22"),  
-                        new FormatString(67, 343433.223m, "C0", "$343,433"),  
-                        new FormatString(68, 343433.223m, "C1", "$343,433.2"),  
-                        new FormatString(69, 343433.223m, "C2", "$343,433.22"),  
-                        new FormatString(70, 343433.223m, "C3", "$343,433.223"),  
-                        new FormatString(71, 343433.223m, "C4", "$343,433.2230"),  
-                        new FormatString(72, 343433.223m, "C5", "$343,433.22300"),  
-                        new FormatString(73, 343433.223m, "C6", "$343,433.223000"),  
-                        new FormatString(74, 343433.223m, "C7", "$343,433.2230000"),  
-                        new FormatString(75, 343433.223m, "C8", "$343,433.22300000"),  
-                        new FormatString(76, 343433.223m, "C9", "$343,433.223000000"),  
-                        new FormatString(77, 343433.223m, "E", "3.434332E+005"),  
-                        new FormatString(78, 343433.223m, "E0", "3E+005"),  
-                        new FormatString(79, 343433.223m, "E1", "3.4E+005"),  
-                        new FormatString(80, 343433.223m, "E2", "3.43E+005"),  
-                        new FormatString(81, 343433.223m, "E3", "3.434E+005"),  
-                        new FormatString(82, 343433.223m, "E4", "3.4343E+005"),  
-                        new FormatString(83, 343433.223m, "E5", "3.43433E+005"),  
-                        new FormatString(84, 343433.223m, "E6", "3.434332E+005"),  
-                        new FormatString(85, 343433.223m, "E7", "3.4343322E+005"),  
-                        new FormatString(86, 343433.223m, "E8", "3.43433223E+005"),  
-                        new FormatString(87, 343433.223m, "E9", "3.434332230E+005"),  
-                        new FormatString(88, 343433.223m, "F", "343433.22"),  
-                        new FormatString(89, 343433.223m, "F0", "343433"),  
-                        new FormatString(90, 343433.223m, "F1", "343433.2"),  
-                        new FormatString(91, 343433.223m, "F2", "343433.22"),  
-                        new FormatString(92, 343433.223m, "F3", "343433.223"),  
-                        new FormatString(93, 343433.223m, "F4", "343433.2230"),  
-                        new FormatString(94, 343433.223m, "F5", "343433.22300"),  
-                        new FormatString(95, 343433.223m, "F6", "343433.223000"),  
-                        new FormatString(96, 343433.223m, "F7", "343433.2230000"),  
-                        new FormatString(97, 343433.223m, "F8", "343433.22300000"),  
-                        new FormatString(98, 343433.223m, "F9", "343433.223000000"),  
-                        new FormatString(99, 343433.223m, "G", "343433.223"),  
-                        new FormatString(100, 343433.223m, "G0", "343433.223"),  
-                        new FormatString(101, 343433.223m, "G1", "3E+05"),  
-                        new FormatString(102, 343433.223m, "G2", "3.4E+05"),  
-                        new FormatString(103, 343433.223m, "G3", "3.43E+05"),  
-                        new FormatString(104, 343433.223m, "G4", "3.434E+05"),  
-                        new FormatString(105, 343433.223m, "G5", "3.4343E+05"),  
-                        new FormatString(106, 343433.223m, "G6", "343433"),  
-                        new FormatString(107, 343433.223m, "G7", "343433.2"),  
-                        new FormatString(108, 343433.223m, "G8", "343433.22"),  
-                        new FormatString(109, 343433.223m, "G9", "343433.223"),  
-                        new FormatString(110, 343433.223m, "N", "343,433.22"),  
-                        new FormatString(111, 343433.223m, "N0", "343,433"),  
-                        new FormatString(112, 343433.223m, "N1", "343,433.2"),  
-                        new FormatString(113, 343433.223m, "N2", "343,433.22"),  
-                        new FormatString(114, 343433.223m, "N3", "343,433.223"),  
-                        new FormatString(115, 343433.223m, "N4", "343,433.2230"),  
-                        new FormatString(116, 343433.223m, "N5", "343,433.22300"),  
-                        new FormatString(117, 343433.223m, "N6", "343,433.223000"),  
-                        new FormatString(118, 343433.223m, "N7", "343,433.2230000"),  
-                        new FormatString(119, 343433.223m, "N8", "343,433.22300000"),  
-                        new FormatString(120, 343433.223m, "N9", "343,433.223000000"),  
-                        new FormatString(121, 343433.223m, "P", "34,343,322.30 %"),  
-                        new FormatString(122, 343433.223m, "P0", "34,343,322 %"),  
-                        new FormatString(123, 343433.223m, "P1", "34,343,322.3 %"),  
-                        new FormatString(124, 343433.223m, "P2", "34,343,322.30 %"),  
-                        new FormatString(125, 343433.223m, "P3", "34,343,322.300 %"),  
-                        new FormatString(126, 343433.223m, "P4", "34,343,322.3000 %"),  
-                        new FormatString(127, 343433.223m, "P5", "34,343,322.30000 %"),  
-                        new FormatString(128, 343433.223m, "P6", "34,343,322.300000 %"),  
-                        new FormatString(129, 343433.223m, "P7", "34,343,322.3000000 %"),  
-                        new FormatString(130, 343433.223m, "P8", "34,343,322.30000000 %"),  
-                        new FormatString(131, 343433.223m, "P9", "34,343,322.300000000 %"),  
-                        new FormatString(132, -1.9292929332m, "C", "($1.93)"),  
-                        new FormatString(133, -1.9292929332m, "C0", "($2)"),  
-                        new FormatString(134, -1.9292929332m, "C1", "($1.9)"),  
-                        new FormatString(135, -1.9292929332m, "C2", "($1.93)"),  
-                        new FormatString(136, -1.9292929332m, "C3", "($1.929)"),  
-                        new FormatString(137, -1.9292929332m, "C4", "($1.9293)"),  
-                        new FormatString(138, -1.9292929332m, "C5", "($1.92929)"),  
-                        new FormatString(139, -1.9292929332m, "C6", "($1.929293)"),  
-                        new FormatString(140, -1.9292929332m, "C7", "($1.9292929)"),  
-                        new FormatString(141, -1.9292929332m, "C8", "($1.92929293)"),  
-                        new FormatString(142, -1.9292929332m, "C9", "($1.929292933)"),  
-                        new FormatString(143, -1.9292929332m, "E", "-1.929293E+000"),  
-                        new FormatString(144, -1.9292929332m, "E0", "-2E+000"),  
-                        new FormatString(145, -1.9292929332m, "E1", "-1.9E+000"),  
-                        new FormatString(146, -1.9292929332m, "E2", "-1.93E+000"),  
-                        new FormatString(147, -1.9292929332m, "E3", "-1.929E+000"),  
-                        new FormatString(148, -1.9292929332m, "E4", "-1.9293E+000"),  
-                        new FormatString(149, -1.9292929332m, "E5", "-1.92929E+000"),  
-                        new FormatString(150, -1.9292929332m, "E6", "-1.929293E+000"),  
-                        new FormatString(151, -1.9292929332m, "E7", "-1.9292929E+000"),  
-                        new FormatString(152, -1.9292929332m, "E8", "-1.92929293E+000"),  
-                        new FormatString(153, -1.9292929332m, "E9", "-1.929292933E+000"),  
-                        new FormatString(154, -1.9292929332m, "F", "-1.93"),  
-                        new FormatString(155, -1.9292929332m, "F0", "-2"),  
-                        new FormatString(156, -1.9292929332m, "F1", "-1.9"),  
-                        new FormatString(157, -1.9292929332m, "F2", "-1.93"),  
-                        new FormatString(158, -1.9292929332m, "F3", "-1.929"),  
-                        new FormatString(159, -1.9292929332m, "F4", "-1.9293"),  
-                        new FormatString(160, -1.9292929332m, "F5", "-1.92929"),  
-                        new FormatString(161, -1.9292929332m, "F6", "-1.929293"),  
-                        new FormatString(162, -1.9292929332m, "F7", "-1.9292929"),  
-                        new FormatString(163, -1.9292929332m, "F8", "-1.92929293"),  
-                        new FormatString(164, -1.9292929332m, "F9", "-1.929292933"),  
-                        new FormatString(165, -1.9292929332m, "G", "-1.9292929332"),  
-                        new FormatString(166, -1.9292929332m, "G0", "-1.9292929332"),  
-                        new FormatString(167, -1.9292929332m, "G1", "-2"),  
-                        new FormatString(168, -1.9292929332m, "G2", "-1.9"),  
-                        new FormatString(169, -1.9292929332m, "G3", "-1.93"),  
-                        new FormatString(170, -1.9292929332m, "G4", "-1.929"),  
-                        new FormatString(171, -1.9292929332m, "G5", "-1.9293"),  
-                        new FormatString(172, -1.9292929332m, "G6", "-1.92929"),  
-                        new FormatString(173, -1.9292929332m, "G7", "-1.929293"),  
-                        new FormatString(174, -1.9292929332m, "G8", "-1.9292929"),  
-                        new FormatString(175, -1.9292929332m, "G9", "-1.92929293"),  
-                        new FormatString(176, -1.9292929332m, "N", "-1.93"),  
-                        new FormatString(177, -1.9292929332m, "N0", "-2"),  
-                        new FormatString(178, -1.9292929332m, "N1", "-1.9"),  
-                        new FormatString(179, -1.9292929332m, "N2", "-1.93"),  
-                        new FormatString(180, -1.9292929332m, "N3", "-1.929"),  
-                        new FormatString(181, -1.9292929332m, "N4", "-1.9293"),  
-                        new FormatString(182, -1.9292929332m, "N5", "-1.92929"),  
-                        new FormatString(183, -1.9292929332m, "N6", "-1.929293"),  
-                        new FormatString(184, -1.9292929332m, "N7", "-1.9292929"),  
-                        new FormatString(185, -1.9292929332m, "N8", "-1.92929293"),  
-                        new FormatString(186, -1.9292929332m, "N9", "-1.929292933"),  
-                        new FormatString(187, -1.9292929332m, "P", "-192.93 %"),  
-                        new FormatString(188, -1.9292929332m, "P0", "-193 %"),  
-                        new FormatString(189, -1.9292929332m, "P1", "-192.9 %"),  
-                        new FormatString(190, -1.9292929332m, "P2", "-192.93 %"),  
-                        new FormatString(191, -1.9292929332m, "P3", "-192.929 %"),  
-                        new FormatString(192, -1.9292929332m, "P4", "-192.9293 %"),  
-                        new FormatString(193, -1.9292929332m, "P5", "-192.92929 %"),  
-                        new FormatString(194, -1.9292929332m, "P6", "-192.929293 %"),  
-                        new FormatString(195, -1.9292929332m, "P7", "-192.9292933 %"),  
-                        new FormatString(196, -1.9292929332m, "P8", "-192.92929332 %"),  
-                        new FormatString(197, -1.9292929332m, "P9", "-192.929293320 %"),  
-                        new FormatString(198, 67234234.23434343434341111m, "C", "$67,234,234.23"),  
-                        new FormatString(199, 67234234.23434343434341111m, "C0", "$67,234,234"),  
-                        new FormatString(200, 67234234.23434343434341111m, "C1", "$67,234,234.2"),  
-                        new FormatString(201, 67234234.23434343434341111m, "C2", "$67,234,234.23"),  
-                        new FormatString(202, 67234234.23434343434341111m, "C3", "$67,234,234.234"),  
-                        new FormatString(203, 67234234.23434343434341111m, "C4", "$67,234,234.2343"),  
-                        new FormatString(204, 67234234.23434343434341111m, "C5", "$67,234,234.23434"),  
-                        new FormatString(205, 67234234.23434343434341111m, "C6", "$67,234,234.234343"),  
-                        new FormatString(206, 67234234.23434343434341111m, "C7", "$67,234,234.2343434"),  
-                        new FormatString(207, 67234234.23434343434341111m, "C8", "$67,234,234.23434343"),  
-                        new FormatString(208, 67234234.23434343434341111m, "C9", "$67,234,234.234343434"),  
-                        new FormatString(209, 67234234.23434343434341111m, "E", "6.723423E+007"),  
-                        new FormatString(210, 67234234.23434343434341111m, "E0", "7E+007"),  
-                        new FormatString(211, 67234234.23434343434341111m, "E1", "6.7E+007"),  
-                        new FormatString(212, 67234234.23434343434341111m, "E2", "6.72E+007"),  
-                        new FormatString(213, 67234234.23434343434341111m, "E3", "6.723E+007"),  
-                        new FormatString(214, 67234234.23434343434341111m, "E4", "6.7234E+007"),  
-                        new FormatString(215, 67234234.23434343434341111m, "E5", "6.72342E+007"),  
-                        new FormatString(216, 67234234.23434343434341111m, "E6", "6.723423E+007"),  
-                        new FormatString(217, 67234234.23434343434341111m, "E7", "6.7234234E+007"),  
-                        new FormatString(218, 67234234.23434343434341111m, "E8", "6.72342342E+007"),  
-                        new FormatString(219, 67234234.23434343434341111m, "E9", "6.723423423E+007"),  
-                        new FormatString(220, 67234234.23434343434341111m, "F", "67234234.23"),  
-                        new FormatString(221, 67234234.23434343434341111m, "F0", "67234234"),  
-                        new FormatString(222, 67234234.23434343434341111m, "F1", "67234234.2"),  
-                        new FormatString(223, 67234234.23434343434341111m, "F2", "67234234.23"),  
-                        new FormatString(224, 67234234.23434343434341111m, "F3", "67234234.234"),  
-                        new FormatString(225, 67234234.23434343434341111m, "F4", "67234234.2343"),  
-                        new FormatString(226, 67234234.23434343434341111m, "F5", "67234234.23434"),  
-                        new FormatString(227, 67234234.23434343434341111m, "F6", "67234234.234343"),  
-                        new FormatString(228, 67234234.23434343434341111m, "F7", "67234234.2343434"),  
-                        new FormatString(229, 67234234.23434343434341111m, "F8", "67234234.23434343"),  
-                        new FormatString(230, 67234234.23434343434341111m, "F9", "67234234.234343434"),  
-                        new FormatString(231, 67234234.23434343434341111m, "G", "67234234.23434343434341111"),  
-                        new FormatString(232, 67234234.23434343434341111m, "G0", "67234234.23434343434341111"),  
-                        new FormatString(233, 67234234.23434343434341111m, "G1", "7E+07"),  
-                        new FormatString(234, 67234234.23434343434341111m, "G2", "6.7E+07"),  
-                        new FormatString(235, 67234234.23434343434341111m, "G3", "6.72E+07"),  
-                        new FormatString(236, 67234234.23434343434341111m, "G4", "6.723E+07"),  
-                        new FormatString(237, 67234234.23434343434341111m, "G5", "6.7234E+07"),  
-                        new FormatString(238, 67234234.23434343434341111m, "G6", "6.72342E+07"),  
-                        new FormatString(239, 67234234.23434343434341111m, "G7", "6.723423E+07"),  
-                        new FormatString(240, 67234234.23434343434341111m, "G8", "67234234"),  
-                        new FormatString(241, 67234234.23434343434341111m, "G9", "67234234.2"),  
-                        new FormatString(242, 67234234.23434343434341111m, "N", "67,234,234.23"),  
-                        new FormatString(243, 67234234.23434343434341111m, "N0", "67,234,234"),  
-                        new FormatString(244, 67234234.23434343434341111m, "N1", "67,234,234.2"),  
-                        new FormatString(245, 67234234.23434343434341111m, "N2", "67,234,234.23"),  
-                        new FormatString(246, 67234234.23434343434341111m, "N3", "67,234,234.234"),  
-                        new FormatString(247, 67234234.23434343434341111m, "N4", "67,234,234.2343"),  
-                        new FormatString(248, 67234234.23434343434341111m, "N5", "67,234,234.23434"),  
-                        new FormatString(249, 67234234.23434343434341111m, "N6", "67,234,234.234343"),  
-                        new FormatString(250, 67234234.23434343434341111m, "N7", "67,234,234.2343434"),  
-                        new FormatString(251, 67234234.23434343434341111m, "N8", "67,234,234.23434343"),  
-                        new FormatString(252, 67234234.23434343434341111m, "N9", "67,234,234.234343434"),  
-                        new FormatString(253, 67234234.23434343434341111m, "P", "6,723,423,423.43 %"),  
-                        new FormatString(254, 67234234.23434343434341111m, "P0", "6,723,423,423 %"),  
-                        new FormatString(255, 67234234.23434343434341111m, "P1", "6,723,423,423.4 %"),  
-                        new FormatString(256, 67234234.23434343434341111m, "P2", "6,723,423,423.43 %"),  
-                        new FormatString(257, 67234234.23434343434341111m, "P3", "6,723,423,423.434 %"),  
-                        new FormatString(258, 67234234.23434343434341111m, "P4", "6,723,423,423.4343 %"),  
-                        new FormatString(259, 67234234.23434343434341111m, "P5", "6,723,423,423.43434 %"),  
-                        new FormatString(260, 67234234.23434343434341111m, "P6", "6,723,423,423.434343 %"),  
-                        new FormatString(261, 67234234.23434343434341111m, "P7", "6,723,423,423.4343434 %"),  
-                        new FormatString(262, 67234234.23434343434341111m, "P8", "6,723,423,423.43434343 %"),  
-                        new FormatString(263, 67234234.23434343434341111m, "P9", "6,723,423,423.434343434 %")
-                };
-        }
-}
-        
+		public string ExpectedResult
+		{
+			get { return expectedresult; }
+			set { expectedresult = value; }
+		}
+	}
+
+	[TestFixture]
+	public class DecimalFormatterTest
+	{
+		CultureInfo old_culture;
+
+		[SetUp]
+		public void Setup ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+
+			CultureInfo EnUs = new CultureInfo ("en-US", false);
+			EnUs.NumberFormat.CurrencyNegativePattern = 0; // -1 = (1)
+			EnUs.NumberFormat.CurrencyDecimalSeparator = ".";
+			EnUs.NumberFormat.NumberGroupSeparator = ",";
+			EnUs.NumberFormat.NumberNegativePattern = 1; // -1 = -1
+
+			//Set this culture for the current thread.
+			Thread.CurrentThread.CurrentCulture = EnUs;
+		}
 
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
+		[Test]
+		public void TestFormatStrings ()
+		{
+			// Test all the formatstrings in the FormatTest array. 
+			// If a test fails the "DecF #" equals the index of the array.
+			foreach (FormatString fTest in FormatTest) {
+				Assertion.AssertEquals ("DecF #" + fTest.TestNumber, fTest.ExpectedResult, fTest.Number.ToString (fTest.Format));
+			}
+		}
+
+		[Test]
+		[ExpectedException (typeof (FormatException))]
+		public void TestToDecimal ()
+		{
+			decimal x = 1.0000001m;
+			string Result = x.ToString ("D2"); //To Decimal is for integral types only. 
+		}
+
+		[Test]
+		[ExpectedException (typeof (FormatException))]
+		public void TestToHex ()
+		{
+			decimal x = 1.0000001m;
+			string Result = x.ToString ("X2"); //To Hex is for integral types only. 
+		}
+
+		// Computer generated format array.
+		FormatString [] FormatTest = new FormatString [] {
+			new FormatString (0, 1.0034m, "C", "$1.00"),
+			new FormatString (1, 1.0034m, "C0", "$1"),
+			new FormatString (2, 1.0034m, "C1", "$1.0"),
+			new FormatString (3, 1.0034m, "C2", "$1.00"),
+			new FormatString (4, 1.0034m, "C3", "$1.003"),
+			new FormatString (5, 1.0034m, "C4", "$1.0034"),
+			new FormatString (6, 1.0034m, "C5", "$1.00340"),
+			new FormatString (7, 1.0034m, "C6", "$1.003400"),
+			new FormatString (8, 1.0034m, "C7", "$1.0034000"),
+			new FormatString (9, 1.0034m, "C8", "$1.00340000"),
+			new FormatString (10, 1.0034m, "C9", "$1.003400000"),
+			new FormatString (11, 1.0034m, "E", "1.003400E+000"),
+			new FormatString (12, 1.0034m, "E0", "1E+000"),
+			new FormatString (13, 1.0034m, "E1", "1.0E+000"),
+			new FormatString (14, 1.0034m, "E2", "1.00E+000"),
+			new FormatString (15, 1.0034m, "E3", "1.003E+000"),
+			new FormatString (16, 1.0034m, "E4", "1.0034E+000"),
+			new FormatString (17, 1.0034m, "E5", "1.00340E+000"),
+			new FormatString (18, 1.0034m, "E6", "1.003400E+000"),
+			new FormatString (19, 1.0034m, "E7", "1.0034000E+000"),
+			new FormatString (20, 1.0034m, "E8", "1.00340000E+000"),
+			new FormatString (21, 1.0034m, "E9", "1.003400000E+000"),
+			new FormatString (22, 1.0034m, "F", "1.00"),
+			new FormatString (23, 1.0034m, "F0", "1"),
+			new FormatString (24, 1.0034m, "F1", "1.0"),
+			new FormatString (25, 1.0034m, "F2", "1.00"),
+			new FormatString (26, 1.0034m, "F3", "1.003"),
+			new FormatString (27, 1.0034m, "F4", "1.0034"),
+			new FormatString (28, 1.0034m, "F5", "1.00340"),
+			new FormatString (29, 1.0034m, "F6", "1.003400"),
+			new FormatString (30, 1.0034m, "F7", "1.0034000"),
+			new FormatString (31, 1.0034m, "F8", "1.00340000"),
+			new FormatString (32, 1.0034m, "F9", "1.003400000"),
+			new FormatString (33, 1.0034m, "G", "1.0034"),
+			new FormatString (34, 1.0034m, "G0", "1.0034"),
+			new FormatString (35, 1.0034m, "G1", "1"),
+			new FormatString (36, 1.0034m, "G2", "1"),
+			new FormatString (37, 1.0034m, "G3", "1"),
+			new FormatString (38, 1.0034m, "G4", "1.003"),
+			new FormatString (39, 1.0034m, "G5", "1.0034"),
+			new FormatString (40, 1.0034m, "G6", "1.0034"),
+			new FormatString (41, 1.0034m, "G7", "1.0034"),
+			new FormatString (42, 1.0034m, "G8", "1.0034"),
+			new FormatString (43, 1.0034m, "G9", "1.0034"),
+			new FormatString (44, 1.0034m, "N", "1.00"),
+			new FormatString (45, 1.0034m, "N0", "1"),
+			new FormatString (46, 1.0034m, "N1", "1.0"),
+			new FormatString (47, 1.0034m, "N2", "1.00"),
+			new FormatString (48, 1.0034m, "N3", "1.003"),
+			new FormatString (49, 1.0034m, "N4", "1.0034"),
+			new FormatString (50, 1.0034m, "N5", "1.00340"),
+			new FormatString (51, 1.0034m, "N6", "1.003400"),
+			new FormatString (52, 1.0034m, "N7", "1.0034000"),
+			new FormatString (53, 1.0034m, "N8", "1.00340000"),
+			new FormatString (54, 1.0034m, "N9", "1.003400000"),
+			new FormatString (55, 1.0034m, "P", "100.34 %"),
+			new FormatString (56, 1.0034m, "P0", "100 %"),
+			new FormatString (57, 1.0034m, "P1", "100.3 %"),
+			new FormatString (58, 1.0034m, "P2", "100.34 %"),
+			new FormatString (59, 1.0034m, "P3", "100.340 %"),
+			new FormatString (60, 1.0034m, "P4", "100.3400 %"),
+			new FormatString (61, 1.0034m, "P5", "100.34000 %"),
+			new FormatString (62, 1.0034m, "P6", "100.340000 %"),
+			new FormatString (63, 1.0034m, "P7", "100.3400000 %"),
+			new FormatString (64, 1.0034m, "P8", "100.34000000 %"),
+			new FormatString (65, 1.0034m, "P9", "100.340000000 %"),
+			new FormatString (66, 343433.223m, "C", "$343,433.22"),
+			new FormatString (67, 343433.223m, "C0", "$343,433"),
+			new FormatString (68, 343433.223m, "C1", "$343,433.2"),
+			new FormatString (69, 343433.223m, "C2", "$343,433.22"),
+			new FormatString (70, 343433.223m, "C3", "$343,433.223"),
+			new FormatString (71, 343433.223m, "C4", "$343,433.2230"),
+			new FormatString (72, 343433.223m, "C5", "$343,433.22300"),
+			new FormatString (73, 343433.223m, "C6", "$343,433.223000"),
+			new FormatString (74, 343433.223m, "C7", "$343,433.2230000"),
+			new FormatString (75, 343433.223m, "C8", "$343,433.22300000"),
+			new FormatString (76, 343433.223m, "C9", "$343,433.223000000"),
+			new FormatString (77, 343433.223m, "E", "3.434332E+005"),
+			new FormatString (78, 343433.223m, "E0", "3E+005"),
+			new FormatString (79, 343433.223m, "E1", "3.4E+005"),
+			new FormatString (80, 343433.223m, "E2", "3.43E+005"),
+			new FormatString (81, 343433.223m, "E3", "3.434E+005"),
+			new FormatString (82, 343433.223m, "E4", "3.4343E+005"),
+			new FormatString (83, 343433.223m, "E5", "3.43433E+005"),
+			new FormatString (84, 343433.223m, "E6", "3.434332E+005"),
+			new FormatString (85, 343433.223m, "E7", "3.4343322E+005"),
+			new FormatString (86, 343433.223m, "E8", "3.43433223E+005"),
+			new FormatString (87, 343433.223m, "E9", "3.434332230E+005"),
+			new FormatString (88, 343433.223m, "F", "343433.22"),
+			new FormatString (89, 343433.223m, "F0", "343433"),
+			new FormatString (90, 343433.223m, "F1", "343433.2"),
+			new FormatString (91, 343433.223m, "F2", "343433.22"),
+			new FormatString (92, 343433.223m, "F3", "343433.223"),
+			new FormatString (93, 343433.223m, "F4", "343433.2230"),
+			new FormatString (94, 343433.223m, "F5", "343433.22300"),
+			new FormatString (95, 343433.223m, "F6", "343433.223000"),
+			new FormatString (96, 343433.223m, "F7", "343433.2230000"),
+			new FormatString (97, 343433.223m, "F8", "343433.22300000"),
+			new FormatString (98, 343433.223m, "F9", "343433.223000000"),
+			new FormatString (99, 343433.223m, "G", "343433.223"),
+			new FormatString (100, 343433.223m, "G0", "343433.223"),
+			new FormatString (101, 343433.223m, "G1", "3E+05"),
+			new FormatString (102, 343433.223m, "G2", "3.4E+05"),
+			new FormatString (103, 343433.223m, "G3", "3.43E+05"),
+			new FormatString (104, 343433.223m, "G4", "3.434E+05"),
+			new FormatString (105, 343433.223m, "G5", "3.4343E+05"),
+			new FormatString (106, 343433.223m, "G6", "343433"),
+			new FormatString (107, 343433.223m, "G7", "343433.2"),
+			new FormatString (108, 343433.223m, "G8", "343433.22"),
+			new FormatString (109, 343433.223m, "G9", "343433.223"),
+			new FormatString (110, 343433.223m, "N", "343,433.22"),
+			new FormatString (111, 343433.223m, "N0", "343,433"),
+			new FormatString (112, 343433.223m, "N1", "343,433.2"),
+			new FormatString (113, 343433.223m, "N2", "343,433.22"),
+			new FormatString (114, 343433.223m, "N3", "343,433.223"),
+			new FormatString (115, 343433.223m, "N4", "343,433.2230"),
+			new FormatString (116, 343433.223m, "N5", "343,433.22300"),
+			new FormatString (117, 343433.223m, "N6", "343,433.223000"),
+			new FormatString (118, 343433.223m, "N7", "343,433.2230000"),
+			new FormatString (119, 343433.223m, "N8", "343,433.22300000"),
+			new FormatString (120, 343433.223m, "N9", "343,433.223000000"),
+			new FormatString (121, 343433.223m, "P", "34,343,322.30 %"),
+			new FormatString (122, 343433.223m, "P0", "34,343,322 %"),
+			new FormatString (123, 343433.223m, "P1", "34,343,322.3 %"),
+			new FormatString (124, 343433.223m, "P2", "34,343,322.30 %"),
+			new FormatString (125, 343433.223m, "P3", "34,343,322.300 %"),
+			new FormatString (126, 343433.223m, "P4", "34,343,322.3000 %"),
+			new FormatString (127, 343433.223m, "P5", "34,343,322.30000 %"),
+			new FormatString (128, 343433.223m, "P6", "34,343,322.300000 %"),
+			new FormatString (129, 343433.223m, "P7", "34,343,322.3000000 %"),
+			new FormatString (130, 343433.223m, "P8", "34,343,322.30000000 %"),
+			new FormatString (131, 343433.223m, "P9", "34,343,322.300000000 %"),
+			new FormatString (132, -1.9292929332m, "C", "($1.93)"),
+			new FormatString (133, -1.9292929332m, "C0", "($2)"),
+			new FormatString (134, -1.9292929332m, "C1", "($1.9)"),
+			new FormatString (135, -1.9292929332m, "C2", "($1.93)"),
+			new FormatString (136, -1.9292929332m, "C3", "($1.929)"),
+			new FormatString (137, -1.9292929332m, "C4", "($1.9293)"),
+			new FormatString (138, -1.9292929332m, "C5", "($1.92929)"),
+			new FormatString (139, -1.9292929332m, "C6", "($1.929293)"),
+			new FormatString (140, -1.9292929332m, "C7", "($1.9292929)"),
+			new FormatString (141, -1.9292929332m, "C8", "($1.92929293)"),
+			new FormatString (142, -1.9292929332m, "C9", "($1.929292933)"),
+			new FormatString (143, -1.9292929332m, "E", "-1.929293E+000"),
+			new FormatString (144, -1.9292929332m, "E0", "-2E+000"),
+			new FormatString (145, -1.9292929332m, "E1", "-1.9E+000"),
+			new FormatString (146, -1.9292929332m, "E2", "-1.93E+000"),
+			new FormatString (147, -1.9292929332m, "E3", "-1.929E+000"),
+			new FormatString (148, -1.9292929332m, "E4", "-1.9293E+000"),
+			new FormatString (149, -1.9292929332m, "E5", "-1.92929E+000"),
+			new FormatString (150, -1.9292929332m, "E6", "-1.929293E+000"),
+			new FormatString (151, -1.9292929332m, "E7", "-1.9292929E+000"),
+			new FormatString (152, -1.9292929332m, "E8", "-1.92929293E+000"),
+			new FormatString (153, -1.9292929332m, "E9", "-1.929292933E+000"),
+			new FormatString (154, -1.9292929332m, "F", "-1.93"),
+			new FormatString (155, -1.9292929332m, "F0", "-2"),
+			new FormatString (156, -1.9292929332m, "F1", "-1.9"),
+			new FormatString (157, -1.9292929332m, "F2", "-1.93"),
+			new FormatString (158, -1.9292929332m, "F3", "-1.929"),
+			new FormatString (159, -1.9292929332m, "F4", "-1.9293"),
+			new FormatString (160, -1.9292929332m, "F5", "-1.92929"),
+			new FormatString (161, -1.9292929332m, "F6", "-1.929293"),
+			new FormatString (162, -1.9292929332m, "F7", "-1.9292929"),
+			new FormatString (163, -1.9292929332m, "F8", "-1.92929293"),
+			new FormatString (164, -1.9292929332m, "F9", "-1.929292933"),
+			new FormatString (165, -1.9292929332m, "G", "-1.9292929332"),
+			new FormatString (166, -1.9292929332m, "G0", "-1.9292929332"),
+			new FormatString (167, -1.9292929332m, "G1", "-2"),
+			new FormatString (168, -1.9292929332m, "G2", "-1.9"),
+			new FormatString (169, -1.9292929332m, "G3", "-1.93"),
+			new FormatString (170, -1.9292929332m, "G4", "-1.929"),
+			new FormatString (171, -1.9292929332m, "G5", "-1.9293"),
+			new FormatString (172, -1.9292929332m, "G6", "-1.92929"),
+			new FormatString (173, -1.9292929332m, "G7", "-1.929293"),
+			new FormatString (174, -1.9292929332m, "G8", "-1.9292929"),
+			new FormatString (175, -1.9292929332m, "G9", "-1.92929293"),
+			new FormatString (176, -1.9292929332m, "N", "-1.93"),
+			new FormatString (177, -1.9292929332m, "N0", "-2"),
+			new FormatString (178, -1.9292929332m, "N1", "-1.9"),
+			new FormatString (179, -1.9292929332m, "N2", "-1.93"),
+			new FormatString (180, -1.9292929332m, "N3", "-1.929"),
+			new FormatString (181, -1.9292929332m, "N4", "-1.9293"),
+			new FormatString (182, -1.9292929332m, "N5", "-1.92929"),
+			new FormatString (183, -1.9292929332m, "N6", "-1.929293"),
+			new FormatString (184, -1.9292929332m, "N7", "-1.9292929"),
+			new FormatString (185, -1.9292929332m, "N8", "-1.92929293"),
+			new FormatString (186, -1.9292929332m, "N9", "-1.929292933"),
+			new FormatString (187, -1.9292929332m, "P", "-192.93 %"),
+			new FormatString (188, -1.9292929332m, "P0", "-193 %"),
+			new FormatString (189, -1.9292929332m, "P1", "-192.9 %"),
+			new FormatString (190, -1.9292929332m, "P2", "-192.93 %"),
+			new FormatString (191, -1.9292929332m, "P3", "-192.929 %"),
+			new FormatString (192, -1.9292929332m, "P4", "-192.9293 %"),
+			new FormatString (193, -1.9292929332m, "P5", "-192.92929 %"),
+			new FormatString (194, -1.9292929332m, "P6", "-192.929293 %"),
+			new FormatString (195, -1.9292929332m, "P7", "-192.9292933 %"),
+			new FormatString (196, -1.9292929332m, "P8", "-192.92929332 %"),
+			new FormatString (197, -1.9292929332m, "P9", "-192.929293320 %"),
+			new FormatString (198, 67234234.23434343434341111m, "C", "$67,234,234.23"),
+			new FormatString (199, 67234234.23434343434341111m, "C0", "$67,234,234"),
+			new FormatString (200, 67234234.23434343434341111m, "C1", "$67,234,234.2"),
+			new FormatString (201, 67234234.23434343434341111m, "C2", "$67,234,234.23"),
+			new FormatString (202, 67234234.23434343434341111m, "C3", "$67,234,234.234"),
+			new FormatString (203, 67234234.23434343434341111m, "C4", "$67,234,234.2343"),
+			new FormatString (204, 67234234.23434343434341111m, "C5", "$67,234,234.23434"),
+			new FormatString (205, 67234234.23434343434341111m, "C6", "$67,234,234.234343"),
+			new FormatString (206, 67234234.23434343434341111m, "C7", "$67,234,234.2343434"),
+			new FormatString (207, 67234234.23434343434341111m, "C8", "$67,234,234.23434343"),
+			new FormatString (208, 67234234.23434343434341111m, "C9", "$67,234,234.234343434"),
+			new FormatString (209, 67234234.23434343434341111m, "E", "6.723423E+007"),
+			new FormatString (210, 67234234.23434343434341111m, "E0", "7E+007"),
+			new FormatString (211, 67234234.23434343434341111m, "E1", "6.7E+007"),
+			new FormatString (212, 67234234.23434343434341111m, "E2", "6.72E+007"),
+			new FormatString (213, 67234234.23434343434341111m, "E3", "6.723E+007"),
+			new FormatString (214, 67234234.23434343434341111m, "E4", "6.7234E+007"),
+			new FormatString (215, 67234234.23434343434341111m, "E5", "6.72342E+007"),
+			new FormatString (216, 67234234.23434343434341111m, "E6", "6.723423E+007"),
+			new FormatString (217, 67234234.23434343434341111m, "E7", "6.7234234E+007"),
+			new FormatString (218, 67234234.23434343434341111m, "E8", "6.72342342E+007"),
+			new FormatString (219, 67234234.23434343434341111m, "E9", "6.723423423E+007"),
+			new FormatString (220, 67234234.23434343434341111m, "F", "67234234.23"),
+			new FormatString (221, 67234234.23434343434341111m, "F0", "67234234"),
+			new FormatString (222, 67234234.23434343434341111m, "F1", "67234234.2"),
+			new FormatString (223, 67234234.23434343434341111m, "F2", "67234234.23"),
+			new FormatString (224, 67234234.23434343434341111m, "F3", "67234234.234"),
+			new FormatString (225, 67234234.23434343434341111m, "F4", "67234234.2343"),
+			new FormatString (226, 67234234.23434343434341111m, "F5", "67234234.23434"),
+			new FormatString (227, 67234234.23434343434341111m, "F6", "67234234.234343"),
+			new FormatString (228, 67234234.23434343434341111m, "F7", "67234234.2343434"),
+			new FormatString (229, 67234234.23434343434341111m, "F8", "67234234.23434343"),
+			new FormatString (230, 67234234.23434343434341111m, "F9", "67234234.234343434"),
+			new FormatString (231, 67234234.23434343434341111m, "G", "67234234.23434343434341111"),
+			new FormatString (232, 67234234.23434343434341111m, "G0", "67234234.23434343434341111"),
+			new FormatString (233, 67234234.23434343434341111m, "G1", "7E+07"),
+			new FormatString (234, 67234234.23434343434341111m, "G2", "6.7E+07"),
+			new FormatString (235, 67234234.23434343434341111m, "G3", "6.72E+07"),
+			new FormatString (236, 67234234.23434343434341111m, "G4", "6.723E+07"),
+			new FormatString (237, 67234234.23434343434341111m, "G5", "6.7234E+07"),
+			new FormatString (238, 67234234.23434343434341111m, "G6", "6.72342E+07"),
+			new FormatString (239, 67234234.23434343434341111m, "G7", "6.723423E+07"),
+			new FormatString (240, 67234234.23434343434341111m, "G8", "67234234"),
+			new FormatString (241, 67234234.23434343434341111m, "G9", "67234234.2"),
+			new FormatString (242, 67234234.23434343434341111m, "N", "67,234,234.23"),
+			new FormatString (243, 67234234.23434343434341111m, "N0", "67,234,234"),
+			new FormatString (244, 67234234.23434343434341111m, "N1", "67,234,234.2"),
+			new FormatString (245, 67234234.23434343434341111m, "N2", "67,234,234.23"),
+			new FormatString (246, 67234234.23434343434341111m, "N3", "67,234,234.234"),
+			new FormatString (247, 67234234.23434343434341111m, "N4", "67,234,234.2343"),
+			new FormatString (248, 67234234.23434343434341111m, "N5", "67,234,234.23434"),
+			new FormatString (249, 67234234.23434343434341111m, "N6", "67,234,234.234343"),
+			new FormatString (250, 67234234.23434343434341111m, "N7", "67,234,234.2343434"),
+			new FormatString (251, 67234234.23434343434341111m, "N8", "67,234,234.23434343"),
+			new FormatString (252, 67234234.23434343434341111m, "N9", "67,234,234.234343434"),
+			new FormatString (253, 67234234.23434343434341111m, "P", "6,723,423,423.43 %"),
+			new FormatString (254, 67234234.23434343434341111m, "P0", "6,723,423,423 %"),
+			new FormatString (255, 67234234.23434343434341111m, "P1", "6,723,423,423.4 %"),
+			new FormatString (256, 67234234.23434343434341111m, "P2", "6,723,423,423.43 %"),
+			new FormatString (257, 67234234.23434343434341111m, "P3", "6,723,423,423.434 %"),
+			new FormatString (258, 67234234.23434343434341111m, "P4", "6,723,423,423.4343 %"),
+			new FormatString (259, 67234234.23434343434341111m, "P5", "6,723,423,423.43434 %"),
+			new FormatString (260, 67234234.23434343434341111m, "P6", "6,723,423,423.434343 %"),
+			new FormatString (261, 67234234.23434343434341111m, "P7", "6,723,423,423.4343434 %"),
+			new FormatString (262, 67234234.23434343434341111m, "P8", "6,723,423,423.43434343 %"),
+			new FormatString (263, 67234234.23434343434341111m, "P9", "6,723,423,423.434343434 %")
+		};
+	}
+}

+ 1274 - 1336
mcs/class/corlib/Test/System/DecimalTest.cs

@@ -15,1409 +15,1347 @@ using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Threading;
 
-namespace MonoTests.System {
-    internal struct ParseTest
-    {
-        public ParseTest(String str, bool exceptionFlag)
-        {
-            this.str = str;
-            this.exceptionFlag = exceptionFlag;
-            this.style = NumberStyles.Number;
-            this.d = 0;
-        }
-
-        public ParseTest(String str, Decimal d)
-        {
-            this.str = str;
-            this.exceptionFlag = false;
-            this.style = NumberStyles.Number;
-            this.d = d;
-        }
-
-        public ParseTest(String str, Decimal d, NumberStyles style)
-        {
-            this.str = str;
-            this.exceptionFlag = false;
-            this.style = style;
-            this.d = d;
-        }
-
-        public String str;
-        public Decimal d;
-        public NumberStyles style;
-        public bool exceptionFlag;
-    }
-
-    internal struct ToStringTest
-    {
-        public ToStringTest(String format, Decimal d, String str)
-        {
-            this.format = format;
-            this.d = d;
-            this.str = str;
-        }
-
-        public String format;
-        public Decimal d;
-        public String str;
-    }
-
-    [TestFixture]
-    public class DecimalTest : Assertion
-    {
-        private const int negativeBitValue = unchecked ((int)0x80000000);
-        private const int negativeScale4Value = unchecked ((int)0x80040000);
-        private int [] parts0 = {0,0,0,0}; //Positive Zero.
-        private int [] parts1 = {1,0,0,0};
-        private int [] parts2 = {0,1,0,0};
-        private int [] parts3 = {0,0,1,0};
-        private int [] parts4 = {0,0,0,negativeBitValue}; // Negative zero.
-        private int [] parts5 = {1,1,1,0};
-        private int [] partsMaxValue = {-1,-1,-1,0};
-        private int [] partsMinValue = {-1,-1,-1,negativeBitValue};
-        private int [] parts6 = {1234, 5678, 8888, negativeScale4Value};
-        private NumberFormatInfo NfiUser;
-
-	private CultureInfo old_culture;
-
-	[TestFixtureSetUp]
-	public void FixtureSetUp ()
+namespace MonoTests.System
+{
+	internal struct ParseTest
 	{
-		old_culture = Thread.CurrentThread.CurrentCulture;
-
-		// Set culture to en-US and don't let the user override.
-		Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
-
-		NfiUser = new NumberFormatInfo();
-		NfiUser.CurrencyDecimalDigits = 3;
-		NfiUser.CurrencyDecimalSeparator = ",";
-		NfiUser.CurrencyGroupSeparator = "_";
-		NfiUser.CurrencyGroupSizes = new int[] { 2,1,0 };
-		NfiUser.CurrencyNegativePattern = 10;
-		NfiUser.CurrencyPositivePattern = 3;
-		NfiUser.CurrencySymbol = "XYZ";
-		NfiUser.NumberDecimalSeparator = "##";
-		NfiUser.NumberDecimalDigits = 4;
-		NfiUser.NumberGroupSeparator = "__";
-		NfiUser.NumberGroupSizes = new int[] { 2,1 };
-		NfiUser.PercentDecimalDigits = 1;
-		NfiUser.PercentDecimalSeparator = ";";
-		NfiUser.PercentGroupSeparator = "~";
-		NfiUser.PercentGroupSizes = new int[] {1};
-		NfiUser.PercentNegativePattern = 2;
-		NfiUser.PercentPositivePattern = 2;
-		NfiUser.PercentSymbol = "%%%";
-        }
-
-	[TestFixtureTearDown]
-	public void FixtureTearDown ()
+		public ParseTest (String str, bool exceptionFlag)
+		{
+			this.str = str;
+			this.exceptionFlag = exceptionFlag;
+			this.style = NumberStyles.Number;
+			this.d = 0;
+		}
+
+		public ParseTest (String str, Decimal d)
+		{
+			this.str = str;
+			this.exceptionFlag = false;
+			this.style = NumberStyles.Number;
+			this.d = d;
+		}
+
+		public ParseTest (String str, Decimal d, NumberStyles style)
+		{
+			this.str = str;
+			this.exceptionFlag = false;
+			this.style = style;
+			this.d = d;
+		}
+
+		public String str;
+		public Decimal d;
+		public NumberStyles style;
+		public bool exceptionFlag;
+	}
+
+	internal struct ToStringTest
 	{
-		Thread.CurrentThread.CurrentCulture = old_culture;
+		public ToStringTest (String format, Decimal d, String str)
+		{
+			this.format = format;
+			this.d = d;
+			this.str = str;
+		}
+
+		public String format;
+		public Decimal d;
+		public String str;
 	}
 
-	public void TestToString()
-        {
-            ToStringTest[] tab = {
-                new ToStringTest("F", 12.345678m, "12.35"),
-                new ToStringTest("F3", 12.345678m, "12.346"),
-                new ToStringTest("F0", 12.345678m, "12"),
-                new ToStringTest("F7", 12.345678m, "12.3456780"),
-                new ToStringTest("g", 12.345678m, "12.345678"),
-                new ToStringTest("E", 12.345678m, "1.234568E+001"),
-                new ToStringTest("E3", 12.345678m, "1.235E+001"),
-                new ToStringTest("E0", 12.345678m, "1E+001"),
-                new ToStringTest("e8", 12.345678m, "1.23456780e+001"),
-                new ToStringTest("F", 0.0012m, "0.00"),
-                new ToStringTest("F3", 0.0012m, "0.001"),
-                new ToStringTest("F0", 0.0012m, "0"),
-                new ToStringTest("F6", 0.0012m, "0.001200"),
-                new ToStringTest("e", 0.0012m, "1.200000e-003"),
-                new ToStringTest("E3", 0.0012m, "1.200E-003"),
-                new ToStringTest("E0", 0.0012m, "1E-003"),
-                new ToStringTest("E6", 0.0012m, "1.200000E-003"),
-                new ToStringTest("F4", -0.001234m, "-0.0012"),
-                new ToStringTest("E3", -0.001234m, "-1.234E-003"),
+	[TestFixture]
+	public class DecimalTest : Assertion
+	{
+		private const int negativeBitValue = unchecked ((int) 0x80000000);
+		private const int negativeScale4Value = unchecked ((int) 0x80040000);
+		private int [] parts0 = { 0, 0, 0, 0 }; //Positive Zero.
+		private int [] parts1 = { 1, 0, 0, 0 };
+		private int [] parts2 = { 0, 1, 0, 0 };
+		private int [] parts3 = { 0, 0, 1, 0 };
+		private int [] parts4 = { 0, 0, 0, negativeBitValue }; // Negative zero.
+		private int [] parts5 = { 1, 1, 1, 0 };
+		private int [] partsMaxValue = { -1, -1, -1, 0 };
+		private int [] partsMinValue = { -1, -1, -1, negativeBitValue };
+		private int [] parts6 = { 1234, 5678, 8888, negativeScale4Value };
+		private NumberFormatInfo NfiUser;
+
+		private CultureInfo old_culture;
+
+		[TestFixtureSetUp]
+		public void FixtureSetUp ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+
+			// Set culture to en-US and don't let the user override.
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
+
+			NfiUser = new NumberFormatInfo ();
+			NfiUser.CurrencyDecimalDigits = 3;
+			NfiUser.CurrencyDecimalSeparator = ",";
+			NfiUser.CurrencyGroupSeparator = "_";
+			NfiUser.CurrencyGroupSizes = new int [] { 2, 1, 0 };
+			NfiUser.CurrencyNegativePattern = 10;
+			NfiUser.CurrencyPositivePattern = 3;
+			NfiUser.CurrencySymbol = "XYZ";
+			NfiUser.NumberDecimalSeparator = "##";
+			NfiUser.NumberDecimalDigits = 4;
+			NfiUser.NumberGroupSeparator = "__";
+			NfiUser.NumberGroupSizes = new int [] { 2, 1 };
+			NfiUser.PercentDecimalDigits = 1;
+			NfiUser.PercentDecimalSeparator = ";";
+			NfiUser.PercentGroupSeparator = "~";
+			NfiUser.PercentGroupSizes = new int [] { 1 };
+			NfiUser.PercentNegativePattern = 2;
+			NfiUser.PercentPositivePattern = 2;
+			NfiUser.PercentSymbol = "%%%";
+		}
+
+		[TestFixtureTearDown]
+		public void FixtureTearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
+		[Test]
+		public void TestToString ()
+		{
+			ToStringTest [] tab = {
+				new ToStringTest ("F", 12.345678m, "12.35"),
+				new ToStringTest ("F3", 12.345678m, "12.346"),
+				new ToStringTest ("F0", 12.345678m, "12"),
+				new ToStringTest ("F7", 12.345678m, "12.3456780"),
+				new ToStringTest ("g", 12.345678m, "12.345678"),
+				new ToStringTest ("E", 12.345678m, "1.234568E+001"),
+				new ToStringTest ("E3", 12.345678m, "1.235E+001"),
+				new ToStringTest ("E0", 12.345678m, "1E+001"),
+				new ToStringTest ("e8", 12.345678m, "1.23456780e+001"),
+				new ToStringTest ("F", 0.0012m, "0.00"),
+				new ToStringTest ("F3", 0.0012m, "0.001"),
+				new ToStringTest ("F0", 0.0012m, "0"),
+				new ToStringTest ("F6", 0.0012m, "0.001200"),
+				new ToStringTest ("e", 0.0012m, "1.200000e-003"),
+				new ToStringTest ("E3", 0.0012m, "1.200E-003"),
+				new ToStringTest ("E0", 0.0012m, "1E-003"),
+				new ToStringTest ("E6", 0.0012m, "1.200000E-003"),
+				new ToStringTest ("F4", -0.001234m, "-0.0012"),
+				new ToStringTest ("E3", -0.001234m, "-1.234E-003"),
 #if NET_1_0
-		new ToStringTest("g", -0.000012m, "-1.2e-05"),
+				new ToStringTest ("g", -0.000012m, "-1.2e-05"),
 #else
-                new ToStringTest("g", -0.000012m, "-0.000012"),
+				new ToStringTest ("g", -0.000012m, "-0.000012"),
 #endif
-                new ToStringTest("g", -0.00012m, "-0.00012"),
-                new ToStringTest("g4", -0.00012m, "-0.00012"),
-                new ToStringTest("g7", -0.00012m, "-0.00012"),
-                new ToStringTest("g", -0.0001234m, "-0.0001234"),
-                new ToStringTest("g", -0.0012m, "-0.0012"),
-                new ToStringTest("g", -0.001234m, "-0.001234"),
-                new ToStringTest("g", -0.012m, "-0.012"),
-                new ToStringTest("g4", -0.012m, "-0.012"),
-                new ToStringTest("g", -0.12m, "-0.12"),
-                new ToStringTest("g", -1.2m, "-1.2"),
-                new ToStringTest("g4", -120m, "-120"),
-                new ToStringTest("g", -12m, "-12"),
-                new ToStringTest("g", -120m, "-120"),
-                new ToStringTest("g", -1200m, "-1200"),
-                new ToStringTest("g4", -1200m, "-1200"),
-                new ToStringTest("g", -1234m, "-1234"),
-                new ToStringTest("g", -12000m, "-12000"),
-                new ToStringTest("g4", -12000m, "-1.2e+04"),
-                new ToStringTest("g5", -12000m, "-12000"),
-                new ToStringTest("g", -12345m, "-12345"),
-                new ToStringTest("g", -120000m, "-120000"),
-                new ToStringTest("g4", -120000m, "-1.2e+05"),
-                new ToStringTest("g5", -120000m, "-1.2e+05"),
-                new ToStringTest("g6", -120000m, "-120000"),
-                new ToStringTest("g", -123456.1m, "-123456.1"),
-                new ToStringTest("g5", -123456.1m, "-1.2346e+05"),
-                new ToStringTest("g6", -123456.1m, "-123456"),
-                new ToStringTest("g", -1200000m, "-1200000"),
-                new ToStringTest("g", -123456.1m, "-123456.1"),
-                new ToStringTest("g", -123456.1m, "-123456.1"),
-                new ToStringTest("g", -1234567.1m, "-1234567.1"),
-                new ToStringTest("g", -12000000m, "-12000000"),
-                new ToStringTest("g", -12345678.1m, "-12345678.1"),
-                new ToStringTest("g", -12000000000000000000m, "-12000000000000000000"),
-                new ToStringTest("F", -123, "-123.00"),
-                new ToStringTest("F3", -123, "-123.000"),
-                new ToStringTest("F0", -123, "-123"),
-                new ToStringTest("E3", -123, "-1.230E+002"),
-                new ToStringTest("E0", -123, "-1E+002"),
-                new ToStringTest("E", -123, "-1.230000E+002"),
-                new ToStringTest("F3", Decimal.MinValue, "-79228162514264337593543950335.000"),
-                new ToStringTest("F", Decimal.MinValue, "-79228162514264337593543950335.00"),
-                new ToStringTest("F0", Decimal.MinValue, "-79228162514264337593543950335"),
-                new ToStringTest("E", Decimal.MinValue, "-7.922816E+028"),
-                new ToStringTest("E3", Decimal.MinValue, "-7.923E+028"),
-                new ToStringTest("E28", Decimal.MinValue, "-7.9228162514264337593543950335E+028"),
-                new ToStringTest("E30", Decimal.MinValue, "-7.922816251426433759354395033500E+028"),
-                new ToStringTest("E0", Decimal.MinValue, "-8E+028"),
-                new ToStringTest("N3", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.000"),
-                new ToStringTest("N0", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335"),
-                new ToStringTest("N", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.00"),
-                new ToStringTest("n3", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.000"),
-                new ToStringTest("n0", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335"),
-                new ToStringTest("n", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.00"),
-                new ToStringTest("C", 123456.7890m, NumberFormatInfo.InvariantInfo.CurrencySymbol + "123,456.79"),
-                new ToStringTest("C", -123456.7890m, "(" + NumberFormatInfo.InvariantInfo.CurrencySymbol + "123,456.79)"),
-                new ToStringTest("C3", 1123456.7890m, NumberFormatInfo.InvariantInfo.CurrencySymbol + "1,123,456.789"),
-                new ToStringTest("P", 123456.7891m, "12,345,678.91 %"),
-                new ToStringTest("P", -123456.7892m, "-12,345,678.92 %"),
-                new ToStringTest("P3", 1234.56789m, "123,456.789 %"),
-            };
-
-            NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
-
-            for (int i = 0; i < tab.Length; i++) 
-            {
-                try
-                {
-                    string s = tab[i].d.ToString(tab[i].format, nfi);
-		    AssertEquals("A01 tab[" + i + "].format = '" + tab[i].format + "')", tab[i].str, s);
-                } 
-                catch (OverflowException)
-                {
-                    Fail(tab[i].d.ToString(tab[i].format, nfi) + " (format = '" + tab[i].format + "'): unexpected exception !");
-                }
-		catch (NUnit.Framework.AssertionException e) {
-			throw e;
+				new ToStringTest ("g", -0.00012m, "-0.00012"),
+				new ToStringTest ("g4", -0.00012m, "-0.00012"),
+				new ToStringTest ("g7", -0.00012m, "-0.00012"),
+				new ToStringTest ("g", -0.0001234m, "-0.0001234"),
+				new ToStringTest ("g", -0.0012m, "-0.0012"),
+				new ToStringTest ("g", -0.001234m, "-0.001234"),
+				new ToStringTest ("g", -0.012m, "-0.012"),
+				new ToStringTest ("g4", -0.012m, "-0.012"),
+				new ToStringTest ("g", -0.12m, "-0.12"),
+				new ToStringTest ("g", -1.2m, "-1.2"),
+				new ToStringTest ("g4", -120m, "-120"),
+				new ToStringTest ("g", -12m, "-12"),
+				new ToStringTest ("g", -120m, "-120"),
+				new ToStringTest ("g", -1200m, "-1200"),
+				new ToStringTest ("g4", -1200m, "-1200"),
+				new ToStringTest ("g", -1234m, "-1234"),
+				new ToStringTest ("g", -12000m, "-12000"),
+				new ToStringTest ("g4", -12000m, "-1.2e+04"),
+				new ToStringTest ("g5", -12000m, "-12000"),
+				new ToStringTest ("g", -12345m, "-12345"),
+				new ToStringTest ("g", -120000m, "-120000"),
+				new ToStringTest ("g4", -120000m, "-1.2e+05"),
+				new ToStringTest ("g5", -120000m, "-1.2e+05"),
+				new ToStringTest ("g6", -120000m, "-120000"),
+				new ToStringTest ("g", -123456.1m, "-123456.1"),
+				new ToStringTest ("g5", -123456.1m, "-1.2346e+05"),
+				new ToStringTest ("g6", -123456.1m, "-123456"),
+				new ToStringTest ("g", -1200000m, "-1200000"),
+				new ToStringTest ("g", -123456.1m, "-123456.1"),
+				new ToStringTest ("g", -123456.1m, "-123456.1"),
+				new ToStringTest ("g", -1234567.1m, "-1234567.1"),
+				new ToStringTest ("g", -12000000m, "-12000000"),
+				new ToStringTest ("g", -12345678.1m, "-12345678.1"),
+				new ToStringTest ("g", -12000000000000000000m, "-12000000000000000000"),
+				new ToStringTest ("F", -123, "-123.00"),
+				new ToStringTest ("F3", -123, "-123.000"),
+				new ToStringTest ("F0", -123, "-123"),
+				new ToStringTest ("E3", -123, "-1.230E+002"),
+				new ToStringTest ("E0", -123, "-1E+002"),
+				new ToStringTest ("E", -123, "-1.230000E+002"),
+				new ToStringTest ("F3", Decimal.MinValue, "-79228162514264337593543950335.000"),
+				new ToStringTest ("F", Decimal.MinValue, "-79228162514264337593543950335.00"),
+				new ToStringTest ("F0", Decimal.MinValue, "-79228162514264337593543950335"),
+				new ToStringTest ("E", Decimal.MinValue, "-7.922816E+028"),
+				new ToStringTest ("E3", Decimal.MinValue, "-7.923E+028"),
+				new ToStringTest ("E28", Decimal.MinValue, "-7.9228162514264337593543950335E+028"),
+				new ToStringTest ("E30", Decimal.MinValue, "-7.922816251426433759354395033500E+028"),
+				new ToStringTest ("E0", Decimal.MinValue, "-8E+028"),
+				new ToStringTest ("N3", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.000"),
+				new ToStringTest ("N0", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335"),
+				new ToStringTest ("N", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.00"),
+				new ToStringTest ("n3", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.000"),
+				new ToStringTest ("n0", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335"),
+				new ToStringTest ("n", Decimal.MinValue, "-79,228,162,514,264,337,593,543,950,335.00"),
+				new ToStringTest ("C", 123456.7890m, NumberFormatInfo.InvariantInfo.CurrencySymbol + "123,456.79"),
+				new ToStringTest ("C", -123456.7890m, "(" + NumberFormatInfo.InvariantInfo.CurrencySymbol + "123,456.79)"),
+				new ToStringTest ("C3", 1123456.7890m, NumberFormatInfo.InvariantInfo.CurrencySymbol + "1,123,456.789"),
+				new ToStringTest ("P", 123456.7891m, "12,345,678.91 %"),
+				new ToStringTest ("P", -123456.7892m, "-12,345,678.92 %"),
+				new ToStringTest ("P3", 1234.56789m, "123,456.789 %"),
+			};
+
+			NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
+
+			for (int i = 0; i < tab.Length; i++) {
+				try {
+					string s = tab [i].d.ToString (tab [i].format, nfi);
+					AssertEquals ("A01 tab[" + i + "].format = '" + tab [i].format + "')", tab [i].str, s);
+				} catch (OverflowException) {
+					Fail (tab [i].d.ToString (tab [i].format, nfi) + " (format = '" + tab [i].format + "'): unexpected exception !");
+				} catch (NUnit.Framework.AssertionException e) {
+					throw e;
+				} catch (Exception e) {
+					Fail ("Unexpected Exception when i = " + i + ". e = " + e);
+				}
+			}
 		}
-		catch (Exception e) {
-			Fail ("Unexpected Exception when i = " + i + ". e = " + e);
+
+		[Test]
+		public void TestCurrencyPattern ()
+		{
+			NumberFormatInfo nfi2 = (NumberFormatInfo) NfiUser.Clone ();
+			Decimal d = -1234567.8976m;
+			string [] ergCurrencyNegativePattern = new String [16] {
+				"(XYZ1234_5_67,898)", "-XYZ1234_5_67,898", "XYZ-1234_5_67,898", "XYZ1234_5_67,898-",
+				"(1234_5_67,898XYZ)", "-1234_5_67,898XYZ", "1234_5_67,898-XYZ", "1234_5_67,898XYZ-",
+				"-1234_5_67,898 XYZ", "-XYZ 1234_5_67,898", "1234_5_67,898 XYZ-", "XYZ 1234_5_67,898-",
+				"XYZ -1234_5_67,898", "1234_5_67,898- XYZ", "(XYZ 1234_5_67,898)", "(1234_5_67,898 XYZ)",
+			};
+
+			for (int i = 0; i < ergCurrencyNegativePattern.Length; i++) {
+				nfi2.CurrencyNegativePattern = i;
+				if (d.ToString ("C", nfi2) != ergCurrencyNegativePattern [i]) {
+					Fail ("CurrencyNegativePattern #" + i + " failed: " +
+						d.ToString ("C", nfi2) + " != " + ergCurrencyNegativePattern [i]);
+				}
+			}
+
+			d = 1234567.8976m;
+			string [] ergCurrencyPositivePattern = new String [4] {
+				"XYZ1234_5_67,898", "1234_5_67,898XYZ", "XYZ 1234_5_67,898", "1234_5_67,898 XYZ",
+			};
+
+			for (int i = 0; i < ergCurrencyPositivePattern.Length; i++) {
+				nfi2.CurrencyPositivePattern = i;
+				if (d.ToString ("C", nfi2) != ergCurrencyPositivePattern [i]) {
+					Fail ("CurrencyPositivePattern #" + i + " failed: " +
+						d.ToString ("C", nfi2) + " != " + ergCurrencyPositivePattern [i]);
+				}
+			}
+		}
+
+		[Test]
+		public void TestNumberNegativePattern ()
+		{
+			NumberFormatInfo nfi2 = (NumberFormatInfo) NfiUser.Clone ();
+			Decimal d = -1234.89765m;
+			string [] ergNumberNegativePattern = new String [5] {
+				"(1__2__34##8977)", "-1__2__34##8977", "- 1__2__34##8977", "1__2__34##8977-", "1__2__34##8977 -",
+			};
+
+			for (int i = 0; i < ergNumberNegativePattern.Length; i++) {
+				nfi2.NumberNegativePattern = i;
+				AssertEquals ("NumberNegativePattern #" + i, ergNumberNegativePattern [i], d.ToString ("N", nfi2));
+			}
+		}
+
+		[Test]
+		public void TestPercentPattern ()
+		{
+			NumberFormatInfo nfi2 = (NumberFormatInfo) NfiUser.Clone ();
+			Decimal d = -1234.8976m;
+			string [] ergPercentNegativePattern = new String [3] {
+				"-1~2~3~4~8~9;8 %%%", "-1~2~3~4~8~9;8%%%", "-%%%1~2~3~4~8~9;8"
+			};
+
+			for (int i = 0; i < ergPercentNegativePattern.Length; i++) {
+				nfi2.PercentNegativePattern = i;
+				if (d.ToString ("P", nfi2) != ergPercentNegativePattern [i]) {
+					Fail ("PercentNegativePattern #" + i + " failed: " +
+						d.ToString ("P", nfi2) + " != " + ergPercentNegativePattern [i]);
+				}
+			}
+
+			d = 1234.8976m;
+			string [] ergPercentPositivePattern = new String [3] {
+				"1~2~3~4~8~9;8 %%%", "1~2~3~4~8~9;8%%%", "%%%1~2~3~4~8~9;8"
+			};
+
+			for (int i = 0; i < ergPercentPositivePattern.Length; i++) {
+				nfi2.PercentPositivePattern = i;
+				if (d.ToString ("P", nfi2) != ergPercentPositivePattern [i]) {
+					Fail ("PercentPositivePattern #" + i + " failed: " +
+						d.ToString ("P", nfi2) + " != " + ergPercentPositivePattern [i]);
+				}
+			}
 		}
-            }      
-        }
-
-        public void TestCurrencyPattern()
-        {
-            NumberFormatInfo nfi2 = (NumberFormatInfo)NfiUser.Clone();
-            Decimal d = -1234567.8976m;
-            string[] ergCurrencyNegativePattern = new String[16] {
-                "(XYZ1234_5_67,898)", "-XYZ1234_5_67,898", "XYZ-1234_5_67,898", "XYZ1234_5_67,898-",
-                "(1234_5_67,898XYZ)", "-1234_5_67,898XYZ", "1234_5_67,898-XYZ", "1234_5_67,898XYZ-",
-                "-1234_5_67,898 XYZ", "-XYZ 1234_5_67,898", "1234_5_67,898 XYZ-", "XYZ 1234_5_67,898-",
-                "XYZ -1234_5_67,898", "1234_5_67,898- XYZ", "(XYZ 1234_5_67,898)", "(1234_5_67,898 XYZ)",
-            };
-
-            for (int i = 0; i < ergCurrencyNegativePattern.Length; i++) 
-            {
-                nfi2.CurrencyNegativePattern = i;
-                if (d.ToString("C", nfi2) != ergCurrencyNegativePattern[i]) 
-                {
-                    Fail("CurrencyNegativePattern #" + i + " failed: " +
-                        d.ToString("C", nfi2) + " != " + ergCurrencyNegativePattern[i]);
-                }
-            }
-
-            d = 1234567.8976m;
-            string[] ergCurrencyPositivePattern = new String[4] {
-                "XYZ1234_5_67,898", "1234_5_67,898XYZ", "XYZ 1234_5_67,898", "1234_5_67,898 XYZ",
-            };
-
-            for (int i = 0; i < ergCurrencyPositivePattern.Length; i++) 
-            {
-                nfi2.CurrencyPositivePattern = i;
-                if (d.ToString("C", nfi2) != ergCurrencyPositivePattern[i]) 
-                {
-                    Fail("CurrencyPositivePattern #" + i + " failed: " +
-                        d.ToString("C", nfi2) + " != " + ergCurrencyPositivePattern[i]);
-                }
-            }
-        }
-
-        public void TestNumberNegativePattern()
-        {
-            NumberFormatInfo nfi2 = (NumberFormatInfo)NfiUser.Clone();
-            Decimal d = -1234.89765m;
-            string[] ergNumberNegativePattern = new String[5] {
-                "(1__2__34##8977)", "-1__2__34##8977", "- 1__2__34##8977", "1__2__34##8977-", "1__2__34##8977 -",
-            };
-
-            for (int i = 0; i < ergNumberNegativePattern.Length; i++) 
-            {
-                nfi2.NumberNegativePattern = i;
-		AssertEquals ("NumberNegativePattern #" + i, ergNumberNegativePattern[i], d.ToString("N", nfi2));
-            }
-        }
-        
-        public void TestPercentPattern()
-        {
-            NumberFormatInfo nfi2 = (NumberFormatInfo)NfiUser.Clone();
-            Decimal d = -1234.8976m;
-            string[] ergPercentNegativePattern = new String[3] {
-                "-1~2~3~4~8~9;8 %%%", "-1~2~3~4~8~9;8%%%", "-%%%1~2~3~4~8~9;8"
-            };
-
-            for (int i = 0; i < ergPercentNegativePattern.Length; i++) 
-            {
-                nfi2.PercentNegativePattern = i;
-                if (d.ToString("P", nfi2) != ergPercentNegativePattern[i]) 
-                {
-                    Fail("PercentNegativePattern #" + i + " failed: " +
-                        d.ToString("P", nfi2) + " != " + ergPercentNegativePattern[i]);
-                }
-            }
-
-            d = 1234.8976m;
-            string[] ergPercentPositivePattern = new String[3] {
-                "1~2~3~4~8~9;8 %%%", "1~2~3~4~8~9;8%%%", "%%%1~2~3~4~8~9;8"
-            };
-
-            for (int i = 0; i < ergPercentPositivePattern.Length; i++) 
-            {
-                nfi2.PercentPositivePattern = i;
-                if (d.ToString("P", nfi2) != ergPercentPositivePattern[i]) 
-                {
-                    Fail("PercentPositivePattern #" + i + " failed: " +
-                        d.ToString("P", nfi2) + " != " + ergPercentPositivePattern[i]);
-                }
-            }
-        }
-
-        ParseTest[] tab = {
-                new ParseTest("1.2345", 1.2345m),
-                new ParseTest("-9876543210", -9876543210m),
-                new ParseTest(NumberFormatInfo.InvariantInfo.CurrencySymbol 
-			+ " (  79,228,162,514,264,337,593,543,950,335.000 ) ", Decimal.MinValue, NumberStyles.Currency),
-                new ParseTest("1.234567890e-10", (Decimal)1.234567890e-10, NumberStyles.Float),
-                new ParseTest("1.234567890e-24", 1.2346e-24m, NumberStyles.Float),
-                new ParseTest("  47896396.457983645462346E10  ", 478963964579836454.62346m, NumberStyles.Float),
-                new ParseTest("-7922816251426433759354395033.250000000000001", -7922816251426433759354395033.3m),
-                new ParseTest("-00000000000000795033.2500000000000000", -795033.25m),
-                new ParseTest("-000000000000001922816251426433759354395033.300000000000000", -1922816251426433759354395033.3m),
-                new ParseTest("-7922816251426433759354395033.150000000000", -7922816251426433759354395033.2m),
-                new ParseTest("-7922816251426433759354395033.2400000000000", -7922816251426433759354395033.2m),
-                new ParseTest("-7922816251426433759354395033.2600000000000", -7922816251426433759354395033.3m)
-        };
-
-        public void TestParse()
-        {
-
-            Decimal d;
-            for (int i = 0; i < tab.Length; i++) 
-            {
-                try
-                {
-                    d = Decimal.Parse(tab[i].str, tab[i].style, NumberFormatInfo.InvariantInfo);
-                    if (tab[i].exceptionFlag)
-                    {
-                        Fail(tab[i].str + ": missing exception !");
-                    }
-                    else if (d != tab[i].d) 
-                    {
-                        Fail(tab[i].str + " != " + d);
-                    }
-                } 
-                catch (OverflowException)
-                {
-                    if (!tab[i].exceptionFlag)
-                    {
-                        Fail(tab[i].str + ": unexpected exception !");
-                    }
-                }
-            }  
-    
-            try 
-            {
-                d = Decimal.Parse(null);
-                Fail("Expected ArgumentNullException");
-            }
-            catch (ArgumentNullException)
-            {
-                //ok
-            }
-
-            try 
-            {
-                d = Decimal.Parse("123nx");
-                Fail("Expected FormatException");
-            }
-            catch (FormatException)
-            {
-                //ok
-            }
-
-            try 
-            {
-                d = Decimal.Parse("79228162514264337593543950336");
-                Fail("Expected OverflowException" + d);
-            }
-            catch (OverflowException)
-            {
-                //ok
-            }
-        }
-
-        public void TestConstants()
-        {
-            AssertEquals ("Zero", 0m, Decimal.Zero);
-            AssertEquals ("One", 1m, Decimal.One);
-            AssertEquals ("MinusOne", -1m, Decimal.MinusOne);
-            AssertEquals ("MaxValue", 79228162514264337593543950335m, Decimal.MaxValue);
-            AssertEquals ("MinValue", -79228162514264337593543950335m, Decimal.MinValue);       
-            Assert ("MinusOne 2", -1m == Decimal.MinusOne);
-        }
-
-        public void TestConstructInt32()
-        {
-            decimal[] dtab = {0m, 1m, -1m, 123456m, -1234567m};
-            int[] itab = {0, 1, -1, 123456, -1234567};
-
-            Decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = new Decimal(itab[i]);
-                if ((decimal)d != dtab[i]) 
-                {
-                    Fail("Int32 -> Decimal: " + itab[i] + " != " + d);
-                }
-                else 
-                {
-                    int n = (int) d;
-                    if (n != itab[i]) 
-                    {
-                        Fail("Decimal -> Int32: " + d + " != " + itab[i]);
-                    }
-                }
-            }
-
-            d = new Decimal(Int32.MaxValue);
-            Assert((int)d == Int32.MaxValue);
-
-            d = new Decimal(Int32.MinValue);
-            Assert((int)d == Int32.MinValue);
-        }
-
-        public void TestConstructUInt32()
-        {
-            decimal[] dtab = {0m, 1m, 123456m, 123456789m};
-            uint[] itab = {0, 1, 123456, 123456789};
-
-            Decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = new Decimal(itab[i]);
-                if ((decimal)d != dtab[i]) 
-                {
-                    Fail("UInt32 -> Decimal: " + itab[i] + " != " + d);
-                }
-                else 
-                {
-                    uint n = (uint) d;
-                    if (n != itab[i]) 
-                    {
-                        Fail("Decimal -> UInt32: " + d + " != " + itab[i]);
-                    }
-                }
-            }
-
-            d = new Decimal(UInt32.MaxValue);
-            Assert((uint)d == UInt32.MaxValue);
-
-            d = new Decimal(UInt32.MinValue);
-            Assert((uint)d == UInt32.MinValue);
-        }
-
-        public void TestConstructInt64()
-        {
-            decimal[] dtab = {0m, 1m, -1m, 9876543m, -9876543210m, 12345678987654321m};
-            long[] itab = {0, 1, -1, 9876543, -9876543210L, 12345678987654321L};
-
-            Decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = new Decimal(itab[i]);
-                if ((decimal)d != dtab[i]) 
-                {
-                    Fail("Int64 -> Decimal: " + itab[i] + " != " + d);
-                }
-                else 
-                {
-                    long n = (long) d;
-                    if (n != itab[i]) 
-                    {
-                        Fail("Decimal -> Int64: " + d + " != " + itab[i]);
-                    }
-                }
-            }
-
-            d = new Decimal(Int64.MaxValue);
-            Assert((long)d == Int64.MaxValue);
-
-            d = new Decimal(Int64.MinValue);
-            Assert((long)d == Int64.MinValue);
-        }
-
-        public void TestConstructUInt64()
-        {
-            decimal[] dtab = {0m, 1m, 987654321m, 123456789876543210m};
-            ulong[] itab = {0, 1, 987654321, 123456789876543210L};
-
-            Decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = new Decimal(itab[i]);
-                if ((decimal)d != dtab[i]) 
-                {
-                    Fail("UInt64 -> Decimal: " + itab[i] + " != " + d);
-                }
-                else 
-                {
-                    ulong n = (ulong) d;
-                    if (n != itab[i]) 
-                    {
-                        Fail("Decimal -> UInt64: " + d + " != " + itab[i]);
-                    }
-                }
-            }
-
-            d = new Decimal(UInt64.MaxValue);
-            Assert((ulong)d == UInt64.MaxValue);
-
-            d = new Decimal(UInt64.MinValue);
-            Assert((ulong)d == UInt64.MinValue);
-        }
-
-        public void TestConstructSingle()
-        {
-            Decimal d;
-
-            d = new Decimal(-1.2345678f);
-            AssertEquals("A#01", -1.234568m, (decimal)d);
-
-            d=3;
-            AssertEquals("A#02", 3.0f, (float)d);
-
-            d = new Decimal(0.0f);
-            AssertEquals("A#03", 0m, (decimal)d);
-            AssertEquals("A#04", 0.0f, (float)d);
-
-            d = new Decimal(1.0f);
-            AssertEquals("A#05", 1m, (decimal)d);
-            AssertEquals("A#06", 1.0f, (float)d);
-
-            d = new Decimal(-1.2345678f);
-            AssertEquals("A#07", -1.234568m, (decimal)d);
-            AssertEquals("A#08", -1.234568f, (float)d);
-
-            d = new Decimal(1.2345673f);
-            AssertEquals("A#09", 1.234567m, (decimal)d);
-
-            d = new Decimal(1.2345673e7f);
-            AssertEquals("A#10", 12345670m, (decimal)d);
-
-            d = new Decimal(1.2345673e-17f);
-            AssertEquals("A#11", 0.00000000000000001234567m, (decimal)d);
-            AssertEquals("A#12", 1.234567e-17f, (float)d);
-
-            // test exceptions
-            try
-            {
-                d = new Decimal(Single.MaxValue);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-
-            try
-            {
-                d = new Decimal(Single.NaN);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-
-            try
-            {
-                d = new Decimal(Single.PositiveInfinity);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-        }
-
-	public void TestConstructSingleRounding_NowWorking ()
-	{
-            decimal d;
 
-            d = new Decimal(1765.23454f);
-            AssertEquals ("failed banker's rule rounding test 2", 1765.234m, d);
+		ParseTest [] tab = {
+				new ParseTest("1.2345", 1.2345m),
+				new ParseTest("-9876543210", -9876543210m),
+				new ParseTest(NumberFormatInfo.InvariantInfo.CurrencySymbol 
+					+ " (  79,228,162,514,264,337,593,543,950,335.000 ) ", 
+					Decimal.MinValue, NumberStyles.Currency),
+				new ParseTest("1.234567890e-10", (Decimal)1.234567890e-10, NumberStyles.Float),
+				new ParseTest("1.234567890e-24", 1.2346e-24m, NumberStyles.Float),
+				new ParseTest("  47896396.457983645462346E10  ", 478963964579836454.62346m, NumberStyles.Float),
+				new ParseTest("-7922816251426433759354395033.250000000000001", -7922816251426433759354395033.3m),
+				new ParseTest("-00000000000000795033.2500000000000000", -795033.25m),
+				new ParseTest("-000000000000001922816251426433759354395033.300000000000000", -1922816251426433759354395033.3m),
+				new ParseTest("-7922816251426433759354395033.150000000000", -7922816251426433759354395033.2m),
+				new ParseTest("-7922816251426433759354395033.2400000000000", -7922816251426433759354395033.2m),
+				new ParseTest("-7922816251426433759354395033.2600000000000", -7922816251426433759354395033.3m)
+		};
+
+		[Test]
+		public void TestParse ()
+		{
+
+			Decimal d;
+			for (int i = 0; i < tab.Length; i++) {
+				try {
+					d = Decimal.Parse (tab [i].str, tab [i].style, NumberFormatInfo.InvariantInfo);
+					if (tab [i].exceptionFlag) {
+						Fail (tab [i].str + ": missing exception !");
+					} else if (d != tab [i].d) {
+						Fail (tab [i].str + " != " + d);
+					}
+				} catch (OverflowException) {
+					if (!tab [i].exceptionFlag) {
+						Fail (tab [i].str + ": unexpected exception !");
+					}
+				}
+			}
+
+			try {
+				d = Decimal.Parse (null);
+				Fail ("Expected ArgumentNullException");
+			} catch (ArgumentNullException) {
+				//ok
+			}
+
+			try {
+				d = Decimal.Parse ("123nx");
+				Fail ("Expected FormatException");
+			} catch (FormatException) {
+				//ok
+			}
+
+			try {
+				d = Decimal.Parse ("79228162514264337593543950336");
+				Fail ("Expected OverflowException" + d);
+			} catch (OverflowException) {
+				//ok
+			}
+		}
 
-            d = new Decimal(0.00017652356f);
-            AssertEquals ("06", 0.0001765236m, d);
+		[Test]
+		public void TestConstants ()
+		{
+			AssertEquals ("Zero", 0m, Decimal.Zero);
+			AssertEquals ("One", 1m, Decimal.One);
+			AssertEquals ("MinusOne", -1m, Decimal.MinusOne);
+			AssertEquals ("MaxValue", 79228162514264337593543950335m, Decimal.MaxValue);
+			AssertEquals ("MinValue", -79228162514264337593543950335m, Decimal.MinValue);
+			Assert ("MinusOne 2", -1m == Decimal.MinusOne);
+		}
 
-            d = new Decimal(0.000176523554f);
-            AssertEquals ("failed banker's rule rounding test 3", 0.0001765236m, d);
+		[Test]
+		public void TestConstructInt32 ()
+		{
+			decimal [] dtab = { 0m, 1m, -1m, 123456m, -1234567m };
+			int [] itab = { 0, 1, -1, 123456, -1234567 };
+
+			Decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = new Decimal (itab [i]);
+				if ((decimal) d != dtab [i]) {
+					Fail ("Int32 -> Decimal: " + itab [i] + " != " + d);
+				} else {
+					int n = (int) d;
+					if (n != itab [i]) {
+						Fail ("Decimal -> Int32: " + d + " != " + itab [i]);
+					}
+				}
+			}
+
+			d = new Decimal (Int32.MaxValue);
+			Assert ((int) d == Int32.MaxValue);
+
+			d = new Decimal (Int32.MinValue);
+			Assert ((int) d == Int32.MinValue);
+		}
 
-            d = new Decimal(0.00017652354f);
-            AssertEquals ("08", 0.0001765235m, d);
+		[Test]
+		public void TestConstructUInt32 ()
+		{
+			decimal [] dtab = { 0m, 1m, 123456m, 123456789m };
+			uint [] itab = { 0, 1, 123456, 123456789 };
+
+			Decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = new Decimal (itab [i]);
+				if ((decimal) d != dtab [i]) {
+					Fail ("UInt32 -> Decimal: " + itab [i] + " != " + d);
+				} else {
+					uint n = (uint) d;
+					if (n != itab [i]) {
+						Fail ("Decimal -> UInt32: " + d + " != " + itab [i]);
+					}
+				}
+			}
+
+			d = new Decimal (UInt32.MaxValue);
+			Assert ((uint) d == UInt32.MaxValue);
+
+			d = new Decimal (UInt32.MinValue);
+			Assert ((uint) d == UInt32.MinValue);
+		}
 
-            d = new Decimal(0.00017652346f);
-            AssertEquals ("09", 0.0001765235m, d);
+		[Test]
+		public void TestConstructInt64 ()
+		{
+			decimal [] dtab = { 0m, 1m, -1m, 9876543m, -9876543210m, 12345678987654321m };
+			long [] itab = { 0, 1, -1, 9876543, -9876543210L, 12345678987654321L };
+
+			Decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = new Decimal (itab [i]);
+				if ((decimal) d != dtab [i]) {
+					Fail ("Int64 -> Decimal: " + itab [i] + " != " + d);
+				} else {
+					long n = (long) d;
+					if (n != itab [i]) {
+						Fail ("Decimal -> Int64: " + d + " != " + itab [i]);
+					}
+				}
+			}
+
+			d = new Decimal (Int64.MaxValue);
+			Assert ((long) d == Int64.MaxValue);
+
+			d = new Decimal (Int64.MinValue);
+			Assert ((long) d == Int64.MinValue);
+		}
 
-            d = new Decimal(0.000176523454f);
-            AssertEquals ("failed banker's rule rounding test 4", 0.0001765234m, d);
+		[Test]
+		public void TestConstructUInt64 ()
+		{
+			decimal [] dtab = { 0m, 1m, 987654321m, 123456789876543210m };
+			ulong [] itab = { 0, 1, 987654321, 123456789876543210L };
+
+			Decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = new Decimal (itab [i]);
+				if ((decimal) d != dtab [i]) {
+					Fail ("UInt64 -> Decimal: " + itab [i] + " != " + d);
+				} else {
+					ulong n = (ulong) d;
+					if (n != itab [i]) {
+						Fail ("Decimal -> UInt64: " + d + " != " + itab [i]);
+					}
+				}
+			}
+
+			d = new Decimal (UInt64.MaxValue);
+			Assert ((ulong) d == UInt64.MaxValue);
+
+			d = new Decimal (UInt64.MinValue);
+			Assert ((ulong) d == UInt64.MinValue);
+		}
 
-            d = new Decimal(0.00017652344f);
-            AssertEquals ("11", 0.0001765234m, d);
-	}
+		[Test]
+		public void TestConstructSingle ()
+		{
+			Decimal d;
+
+			d = new Decimal (-1.2345678f);
+			AssertEquals ("A#01", -1.234568m, (decimal) d);
+
+			d = 3;
+			AssertEquals ("A#02", 3.0f, (float) d);
+
+			d = new Decimal (0.0f);
+			AssertEquals ("A#03", 0m, (decimal) d);
+			AssertEquals ("A#04", 0.0f, (float) d);
+
+			d = new Decimal (1.0f);
+			AssertEquals ("A#05", 1m, (decimal) d);
+			AssertEquals ("A#06", 1.0f, (float) d);
+
+			d = new Decimal (-1.2345678f);
+			AssertEquals ("A#07", -1.234568m, (decimal) d);
+			AssertEquals ("A#08", -1.234568f, (float) d);
+
+			d = new Decimal (1.2345673f);
+			AssertEquals ("A#09", 1.234567m, (decimal) d);
+
+			d = new Decimal (1.2345673e7f);
+			AssertEquals ("A#10", 12345670m, (decimal) d);
+
+			d = new Decimal (1.2345673e-17f);
+			AssertEquals ("A#11", 0.00000000000000001234567m, (decimal) d);
+			AssertEquals ("A#12", 1.234567e-17f, (float) d);
+
+			// test exceptions
+			try {
+				d = new Decimal (Single.MaxValue);
+				Fail ();
+			} catch (OverflowException) {
+			}
+
+			try {
+				d = new Decimal (Single.NaN);
+				Fail ();
+			} catch (OverflowException) {
+			}
+
+			try {
+				d = new Decimal (Single.PositiveInfinity);
+				Fail ();
+			} catch (OverflowException) {
+			}
+		}
 
-        public void TestConstructSingleRounding()
-        {
-            decimal d;
+		[Test]
+		public void TestConstructSingleRounding_NowWorking ()
+		{
+			decimal d;
 
-            d = new Decimal(1765.2356f);
-            Assert("01", d == 1765.236m);
+			d = new Decimal (1765.23454f);
+			AssertEquals ("failed banker's rule rounding test 2", 1765.234m, d);
 
-            d = new Decimal(1765.23554f);
-            Assert("failed banker's rule rounding test 1", d == 1765.236m);
+			d = new Decimal (0.00017652356f);
+			AssertEquals ("06", 0.0001765236m, d);
 
-            d = new Decimal(1765.2354f);
-            Assert("03", d == 1765.235m);
+			d = new Decimal (0.000176523554f);
+			AssertEquals ("failed banker's rule rounding test 3", 0.0001765236m, d);
 
-            d = new Decimal(1765.2346f);
-            Assert("04", d == 1765.235m);
+			d = new Decimal (0.00017652354f);
+			AssertEquals ("08", 0.0001765235m, d);
 
-            d = new Decimal(1765.2344f);
-            Assert("05", d == 1765.234m);
+			d = new Decimal (0.00017652346f);
+			AssertEquals ("09", 0.0001765235m, d);
 
-            d = new Decimal(3.7652356e10f);
-            Assert("12", d == 37652360000m);
+			d = new Decimal (0.000176523454f);
+			AssertEquals ("failed banker's rule rounding test 4", 0.0001765234m, d);
 
-            d = new Decimal(3.7652356e20f);
-            Assert("13", d == 376523600000000000000m);
-
-            d = new Decimal(3.76523554e20f);
-            Assert("failed banker's rule rounding test 5", d == 376523600000000000000m);
-
-            d = new Decimal(3.7652352e20f);
-            Assert("15", d == 376523500000000000000m);
-
-            d = new Decimal(3.7652348e20f);
-            Assert("16", d == 376523500000000000000m);
-
-            d = new Decimal(3.76523454e20f);
-            Assert("failed banker's rule rounding test 6", d == 376523400000000000000m);
-
-            d = new Decimal(3.7652342e20f);
-            Assert("18", d == 376523400000000000000m);
-        }
-
-        public void TestConstructDouble()
-        {
-            Decimal d;
-
-            d = new Decimal(0.0);
-            Assert((decimal)d == 0m);
-
-            d = new Decimal(1.0);
-            Assert((decimal)d == 1m);
-            Assert(1.0 == (double)d);
-
-            d = new Decimal(-1.2345678901234);
-            Assert((decimal)d == -1.2345678901234m);
-            Assert(-1.2345678901234 == (double)d);
-
-            d = new Decimal(1.2345678901234);
-            Assert((decimal)d == 1.2345678901234m);
-
-            d = new Decimal(1.2345678901234e8);
-            Assert((decimal)d == 123456789.01234m);
-            Assert(1.2345678901234e8 == (double)d);
-
-            d = new Decimal(1.2345678901234e16);
-            Assert((decimal)d == 12345678901234000m);
-            Assert(1.2345678901234e16 == (double)d);
-
-            d = new Decimal(1.2345678901234e24);
-            Assert((decimal)d == 1234567890123400000000000m);
-            Assert(1.2345678901234e24 == (double)d);
-
-            d = new Decimal(1.2345678901234e28);
-            Assert((decimal)d == 1.2345678901234e28m);
-            Assert(1.2345678901234e28 == (double)d);
-
-            d = new Decimal(7.2345678901234e28);
-            Assert((decimal)d == 7.2345678901234e28m);
-            Assert(new Decimal((double)d) == d);
-
-            d = new Decimal(1.2345678901234e-8);
-            Assert((decimal)d == 1.2345678901234e-8m);
-
-            d = new Decimal(1.2345678901234e-14);
-            Assert((decimal)d == 1.2345678901234e-14m);
-            Assert(1.2345678901234e-14 == (double)d);
-
-            d = new Decimal(1.2342278901234e-25);
-            AssertEquals("A10", d, 1.234e-25m);
-
-            // test exceptions
-            try
-            {
-                d = new Decimal(8e28);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-
-            try
-            {
-                d = new Decimal(8e48);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-
-            try
-            {
-                d = new Decimal(Double.NaN);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-
-            try
-            {
-                d = new Decimal(Double.PositiveInfinity);
-                Fail();
-            } 
-            catch (OverflowException) 
-            {
-            }
-        }
-
-        public void TestConstructDoubleRound()
-        {
-            decimal d;
-	    int TestNum = 1;
-            
-	    try {
-			d = new Decimal(1765.231234567857);
-			AssertEquals("A01", 1765.23123456786m, d);
-
-			TestNum++;
-			d = new Decimal(1765.2312345678554);
-			AssertEquals("A02, failed banker's rule rounding test 1", 1765.23123456786m, d);
-			AssertEquals("A03", 1765.23123456786, (double)d);
-
-			TestNum++;
-			d = new Decimal(1765.231234567853);
-			Assert(d == 1765.23123456785m);
-
-			TestNum++;
-			d = new Decimal(1765.231234567847);
-			Assert(d == 1765.23123456785m);
-
-			TestNum++;
-			d = new Decimal(1765.231234567843);
-			Assert(d == 1765.23123456784m);
-
-			TestNum++;
-			d = new Decimal(1.765231234567857e-9);
-			Assert(d == 1.76523123456786e-9m);
-
-			TestNum++;
-			d = new Decimal(1.7652312345678554e-9);
-			Assert("failed banker's rule rounding test 3", d == 1.76523123456786e-9m);
-
-			TestNum++;
-			d = new Decimal(1.765231234567853e-9);
-			Assert(d == 1.76523123456785e-9m);
-
-			TestNum++;
-			d = new Decimal(1.765231234567857e+24);
-			Assert(d == 1.76523123456786e+24m);
-
-			TestNum++;
-			d = new Decimal(1.7652312345678554e+24);
-			Assert("failed banker's rule rounding test 4", d == 1.76523123456786e+24m);
-
-			TestNum++;
-			d = new Decimal(1.765231234567853e+24);
-			Assert(d == 1.76523123456785e+24m);
-
-			TestNum++;
-			d = new Decimal(1765.2312345678454);
-			Assert(d == 1765.23123456785m);
+			d = new Decimal (0.00017652344f);
+			AssertEquals ("11", 0.0001765234m, d);
 		}
-		catch (Exception e) {
-			Fail("At TestNum = " + TestNum + " unexpected exception. e = " + e);
+
+		public void TestConstructSingleRounding ()
+		{
+			decimal d;
+
+			d = new Decimal (1765.2356f);
+			Assert ("01", d == 1765.236m);
+
+			d = new Decimal (1765.23554f);
+			Assert ("failed banker's rule rounding test 1", d == 1765.236m);
+
+			d = new Decimal (1765.2354f);
+			Assert ("03", d == 1765.235m);
+
+			d = new Decimal (1765.2346f);
+			Assert ("04", d == 1765.235m);
+
+			d = new Decimal (1765.2344f);
+			Assert ("05", d == 1765.234m);
+
+			d = new Decimal (3.7652356e10f);
+			Assert ("12", d == 37652360000m);
+
+			d = new Decimal (3.7652356e20f);
+			Assert ("13", d == 376523600000000000000m);
+
+			d = new Decimal (3.76523554e20f);
+			Assert ("failed banker's rule rounding test 5", d == 376523600000000000000m);
+
+			d = new Decimal (3.7652352e20f);
+			Assert ("15", d == 376523500000000000000m);
+
+			d = new Decimal (3.7652348e20f);
+			Assert ("16", d == 376523500000000000000m);
+
+			d = new Decimal (3.76523454e20f);
+			Assert ("failed banker's rule rounding test 6", d == 376523400000000000000m);
+
+			d = new Decimal (3.7652342e20f);
+			Assert ("18", d == 376523400000000000000m);
 		}
-        }
-
-        public void TestNegate()
-        {
-            decimal d;
-
-            d = new Decimal(12345678);
-            Assert((decimal)Decimal.Negate(d) == -12345678m);
-        }
-
-        public void TestPartConstruct()
-        {
-            decimal d;
-            
-            d = new Decimal(parts0);
-            Assert(d == 0);
-
-            d = new Decimal(parts1);
-            Assert(d == 1);
-
-            d = new Decimal(parts2);
-            Assert(d == 4294967296m);
-
-            d = new Decimal(parts3);
-            Assert(d == 18446744073709551616m);
-
-            d = new Decimal(parts4);
-            Assert(d == 0m);
-
-            d = new Decimal(parts5);
-            Assert(d == 18446744078004518913m);
-            
-            d = new Decimal(partsMaxValue);
-            Assert(d == Decimal.MaxValue);
-            
-            d = new Decimal(partsMinValue);
-            Assert(d == Decimal.MinValue);
-
-            d = new Decimal(parts6);
-            int[] erg = Decimal.GetBits(d);
-            for (int i = 0; i < 4; i++) 
-            {
-                Assert(erg[i] == parts6[i]); 
-            }
-        }
-
-        public void TestFloorTruncate()
-        {
-            decimal[,] dtab = {
-                {0m, 0m, 0m}, {1m, 1m, 1m}, {-1m, -1m, -1m}, {1.1m, 1m, 1m}, 
-                {-1.000000000001m, -2m, -1m}, {12345.67890m,12345m,12345m},
-                {-123456789012345.67890m, -123456789012346m, -123456789012345m},
-                {Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue},
-                {Decimal.MinValue, Decimal.MinValue, Decimal.MinValue},
-                {6.999999999m, 6m, 6m}, {-6.999999999m, -7m, -6m}, 
-                {0.00001m, 0m, 0m}, {-0.00001m, -1m, 0m}
-            };
-
-            decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = Decimal.Floor(dtab[i,0]);
-                if (d != dtab[i,1]) 
-                {
-                    Fail("Floor: Floor(" + dtab[i,0] + ") != " + d);
-                }
-                d = Decimal.Truncate(dtab[i,0]);
-                if (d != dtab[i,2]) 
-                {
-                    Fail("Truncate: Truncate(" + dtab[i,0] + ") != " + d);
-                }
-            }
-        }
-
-	[Test]
-	public void Truncate () 
-	{
-		decimal dd = 249.9m;
-		decimal dt = Decimal.Truncate (dd);
-		AssertEquals ("Original", 249.9m, dd);
-		AssertEquals ("Truncate", 249m, dt);
-		AssertEquals ("Cast-Byte", 249, (byte)dd);
-		AssertEquals ("Cast-Char", 249, (char)dd);
-		AssertEquals ("Cast-Int16", 249, (short)dd);
-		AssertEquals ("Cast-UInt16", 249, (ushort)dd);
-		AssertEquals ("Cast-Int32", 249, (int)dd);
-		AssertEquals ("Cast-UInt32", 249, (uint)dd);
-		AssertEquals ("Cast-Int64", 249, (long)dd);
-		AssertEquals ("Cast-UInt64", 249, (ulong)dd);
-	}
 
-	public void TestRound()
-        {
-            decimal[,] dtab = { 
-                {1m, 0, 1m}, {1.234567890m, 1, 1.2m}, 
-                {1.234567890m, 2, 1.23m}, {1.23450000001m, 3, 1.235m}, 
-                {1.2355m, 3, 1.236m}, 
-                {1.234567890m, 4, 1.2346m}, {1.23567890m, 2, 1.24m}, 
-                {47893764694.4578563236436621m, 7, 47893764694.4578563m},
-                {-47893764694.4578563236436621m, 9, -47893764694.457856324m},
-                {-47893764694.4578m, 5, -47893764694.4578m}
-            };
-
-            decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = Decimal.Round(dtab[i,0], (int)dtab[i,1]);
-                if (d != dtab[i,2]) 
-                {
-                    Fail("Round: Round(" + dtab[i,0] + "," + (int)dtab[i,1] + ") != " + d);
-                }
-            }
-        }
-	
-	public void TestRoundFailures ()
-        {
-            decimal[,] dtab = { 
-                {1.2345m, 3, 1.234m} 
-            };
-
-            decimal d;
-            
-            for (int i = 0; i < dtab.GetLength(0); i++)
-            {
-                d = Decimal.Round(dtab[i,0], (int)dtab[i,1]);
-                if (d != dtab[i,2]) 
-                {
-                    Fail("FailRound: Round(" + dtab[i,0] + "," + (int)dtab[i,1] + ") != " + d);
-                }
-            }
-        }
-
-	[Test]
-	public void ParseInt64 () 
-	{
-		long max = Int64.MaxValue;
-		Decimal dmax = Decimal.Parse (max.ToString ());
-		AssertEquals ("Int64.MaxValue", Int64.MaxValue, Decimal.ToInt64 (dmax));
+		[Test]
+		public void TestConstructDouble ()
+		{
+			Decimal d;
+
+			d = new Decimal (0.0);
+			Assert ((decimal) d == 0m);
+
+			d = new Decimal (1.0);
+			Assert ((decimal) d == 1m);
+			Assert (1.0 == (double) d);
+
+			d = new Decimal (-1.2345678901234);
+			Assert ((decimal) d == -1.2345678901234m);
+			Assert (-1.2345678901234 == (double) d);
+
+			d = new Decimal (1.2345678901234);
+			Assert ((decimal) d == 1.2345678901234m);
+
+			d = new Decimal (1.2345678901234e8);
+			Assert ((decimal) d == 123456789.01234m);
+			Assert (1.2345678901234e8 == (double) d);
+
+			d = new Decimal (1.2345678901234e16);
+			Assert ((decimal) d == 12345678901234000m);
+			Assert (1.2345678901234e16 == (double) d);
+
+			d = new Decimal (1.2345678901234e24);
+			Assert ((decimal) d == 1234567890123400000000000m);
+			Assert (1.2345678901234e24 == (double) d);
+
+			d = new Decimal (1.2345678901234e28);
+			Assert ((decimal) d == 1.2345678901234e28m);
+			Assert (1.2345678901234e28 == (double) d);
+
+			d = new Decimal (7.2345678901234e28);
+			Assert ((decimal) d == 7.2345678901234e28m);
+			Assert (new Decimal ((double) d) == d);
+
+			d = new Decimal (1.2345678901234e-8);
+			Assert ((decimal) d == 1.2345678901234e-8m);
+
+			d = new Decimal (1.2345678901234e-14);
+			Assert ((decimal) d == 1.2345678901234e-14m);
+			Assert (1.2345678901234e-14 == (double) d);
+
+			d = new Decimal (1.2342278901234e-25);
+			AssertEquals ("A10", d, 1.234e-25m);
+
+			// test exceptions
+			try {
+				d = new Decimal (8e28);
+				Fail ();
+			} catch (OverflowException) {
+			}
+
+			try {
+				d = new Decimal (8e48);
+				Fail ();
+			} catch (OverflowException) {
+			}
+
+			try {
+				d = new Decimal (Double.NaN);
+				Fail ();
+			} catch (OverflowException) {
+			}
+
+			try {
+				d = new Decimal (Double.PositiveInfinity);
+				Fail ();
+			} catch (OverflowException) {
+			}
+		}
 
-		long min = Int64.MinValue;
-		Decimal dmin = Decimal.Parse (min.ToString ());
-		AssertEquals ("Int64.MinValue", Int64.MinValue, Decimal.ToInt64 (dmin));
+		[Test]
+		public void TestConstructDoubleRound ()
+		{
+			decimal d;
+			int TestNum = 1;
+
+			try {
+				d = new Decimal (1765.231234567857);
+				AssertEquals ("A01", 1765.23123456786m, d);
+
+				TestNum++;
+				d = new Decimal (1765.2312345678554);
+				AssertEquals ("A02, failed banker's rule rounding test 1", 1765.23123456786m, d);
+				AssertEquals ("A03", 1765.23123456786, (double) d);
+
+				TestNum++;
+				d = new Decimal (1765.231234567853);
+				Assert (d == 1765.23123456785m);
+
+				TestNum++;
+				d = new Decimal (1765.231234567847);
+				Assert (d == 1765.23123456785m);
+
+				TestNum++;
+				d = new Decimal (1765.231234567843);
+				Assert (d == 1765.23123456784m);
+
+				TestNum++;
+				d = new Decimal (1.765231234567857e-9);
+				Assert (d == 1.76523123456786e-9m);
+
+				TestNum++;
+				d = new Decimal (1.7652312345678554e-9);
+				Assert ("failed banker's rule rounding test 3", d == 1.76523123456786e-9m);
+
+				TestNum++;
+				d = new Decimal (1.765231234567853e-9);
+				Assert (d == 1.76523123456785e-9m);
+
+				TestNum++;
+				d = new Decimal (1.765231234567857e+24);
+				Assert (d == 1.76523123456786e+24m);
+
+				TestNum++;
+				d = new Decimal (1.7652312345678554e+24);
+				Assert ("failed banker's rule rounding test 4", d == 1.76523123456786e+24m);
+
+				TestNum++;
+				d = new Decimal (1.765231234567853e+24);
+				Assert (d == 1.76523123456785e+24m);
+
+				TestNum++;
+				d = new Decimal (1765.2312345678454);
+				Assert (d == 1765.23123456785m);
+			} catch (Exception e) {
+				Fail ("At TestNum = " + TestNum + " unexpected exception. e = " + e);
+			}
+		}
 
-		dmax += 1.1m;
-		dmax = Decimal.Parse (dmax.ToString ());
-		AssertEquals ("Int64.MaxValue+1.1", Int64.MaxValue, Decimal.ToInt64 (dmax - 1.1m));
+		[Test]
+		public void TestNegate ()
+		{
+			decimal d;
 
-		dmin -= 1.1m;
-		dmin = Decimal.Parse (dmin.ToString ());
-		AssertEquals ("Int64.MinValue-1.1", Int64.MinValue, Decimal.ToInt64 (dmin + 1.1m));
-	}
+			d = new Decimal (12345678);
+			Assert ((decimal) Decimal.Negate (d) == -12345678m);
+		}
 
-	[Test]
-	public void ToByte () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToByte", 254, Decimal.ToByte (d));
-		AssertEquals ("Convert.ToByte", 255, Convert.ToByte (d));
-		AssertEquals ("IConvertible.ToByte", 255, (d as IConvertible).ToByte (null));
-	}
+		[Test]
+		public void TestPartConstruct ()
+		{
+			decimal d;
 
-	[Test]
-	public void ToSByte () 
-	{
-		Decimal d = 126.9m;
-		AssertEquals ("Decimal.ToSByte", 126, Decimal.ToSByte (d));
-		AssertEquals ("Convert.ToSByte", 127, Convert.ToSByte (d));
-		AssertEquals ("IConvertible.ToSByte", 127, (d as IConvertible).ToSByte (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToSByte", -126, Decimal.ToSByte (d));
-		AssertEquals ("-Convert.ToSByte", -127, Convert.ToSByte (d));
-		AssertEquals ("-IConvertible.ToSByte", -127, (d as IConvertible).ToSByte (null));
-	}
+			d = new Decimal (parts0);
+			Assert (d == 0);
 
-	[Test]
-	public void ToInt16 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToInt16", 254, Decimal.ToInt16 (d));
-		AssertEquals ("Convert.ToInt16", 255, Convert.ToInt16 (d));
-		AssertEquals ("IConvertible.ToInt16", 255, (d as IConvertible).ToInt16 (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToInt16", -254, Decimal.ToInt16 (d));
-		AssertEquals ("-Convert.ToInt16", -255, Convert.ToInt16 (d));
-		AssertEquals ("-IConvertible.ToInt16", -255, (d as IConvertible).ToInt16 (null));
-	}
+			d = new Decimal (parts1);
+			Assert (d == 1);
 
-	[Test]
-	public void ToUInt16 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToUInt16", 254, Decimal.ToUInt16 (d));
-		AssertEquals ("Convert.ToUInt16", 255, Convert.ToUInt16 (d));
-		AssertEquals ("IConvertible.ToUInt16", 255, (d as IConvertible).ToUInt16 (null));
-	}
+			d = new Decimal (parts2);
+			Assert (d == 4294967296m);
 
-	[Test]
-	public void ToInt32 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToInt32", 254, Decimal.ToInt32 (d));
-		AssertEquals ("Convert.ToInt32", 255, Convert.ToInt32 (d));
-		AssertEquals ("IConvertible.ToInt32", 255, (d as IConvertible).ToInt32 (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToInt32", -254, Decimal.ToInt32 (d));
-		AssertEquals ("-Convert.ToInt32", -255, Convert.ToInt32 (d));
-		AssertEquals ("-IConvertible.ToInt32", -255, (d as IConvertible).ToInt32 (null));
-	}
+			d = new Decimal (parts3);
+			Assert (d == 18446744073709551616m);
 
-	[Test]
-	public void ToUInt32 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToUInt32", 254, Decimal.ToUInt32 (d));
-		AssertEquals ("Convert.ToUInt32", 255, Convert.ToUInt32 (d));
-		AssertEquals ("IConvertible.ToUInt32", 255, (d as IConvertible).ToUInt32 (null));
-	}
+			d = new Decimal (parts4);
+			Assert (d == 0m);
 
-	[Test]
-	public void ToInt64 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToInt64", 254, Decimal.ToInt64 (d));
-		AssertEquals ("Convert.ToInt64", 255, Convert.ToInt64 (d));
-		AssertEquals ("IConvertible.ToInt64", 255, (d as IConvertible).ToInt64 (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToInt64", -254, Decimal.ToInt64 (d));
-		AssertEquals ("-Convert.ToInt64", -255, Convert.ToInt64 (d));
-		AssertEquals ("-IConvertible.ToInt64", -255, (d as IConvertible).ToInt64 (null));
-	}
+			d = new Decimal (parts5);
+			Assert (d == 18446744078004518913m);
 
-	[Test]
-	[ExpectedException (typeof(OverflowException))]
-	public void ToInt64_TooBig () 
-	{
-		Decimal d = (Decimal) Int64.MaxValue;
-		d += 1.1m;
-		long value = Decimal.ToInt64 (d);
-	}
+			d = new Decimal (partsMaxValue);
+			Assert (d == Decimal.MaxValue);
 
-	[Test]
-	[ExpectedException (typeof(OverflowException))]
-	public void ToInt64_TooSmall () 
-	{
-		Decimal d = (Decimal) Int64.MinValue;
-		d -= 1.1m;
-		long value = Decimal.ToInt64 (d);
-	}
+			d = new Decimal (partsMinValue);
+			Assert (d == Decimal.MinValue);
 
-	[Test]
-	public void ToUInt64 () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToUInt64", 254, Decimal.ToUInt64 (d));
-		AssertEquals ("Convert.ToUInt64", 255, Convert.ToUInt64 (d));
-		AssertEquals ("IConvertible.ToUInt64", 255, (d as IConvertible).ToUInt64 (null));
-	}
+			d = new Decimal (parts6);
+			int [] erg = Decimal.GetBits (d);
+			for (int i = 0; i < 4; i++) {
+				Assert (erg [i] == parts6 [i]);
+			}
+		}
 
-	[Test]
-	public void ToSingle () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToSingle", 254.9f, Decimal.ToSingle (d));
-		AssertEquals ("Convert.ToSingle", 254.9f, Convert.ToSingle (d));
-		AssertEquals ("IConvertible.ToSingle", 254.9f, (d as IConvertible).ToSingle (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToSingle", -254.9f, Decimal.ToSingle (d));
-		AssertEquals ("-Convert.ToSingle", -254.9f, Convert.ToSingle (d));
-		AssertEquals ("-IConvertible.ToSingle", -254.9f, (d as IConvertible).ToSingle (null));
-	}
+		[Test]
+		public void TestFloorTruncate ()
+		{
+			decimal [,] dtab = {
+				{0m, 0m, 0m}, {1m, 1m, 1m}, {-1m, -1m, -1m}, {1.1m, 1m, 1m}, 
+				{-1.000000000001m, -2m, -1m}, {12345.67890m,12345m,12345m},
+				{-123456789012345.67890m, -123456789012346m, -123456789012345m},
+				{Decimal.MaxValue, Decimal.MaxValue, Decimal.MaxValue},
+				{Decimal.MinValue, Decimal.MinValue, Decimal.MinValue},
+				{6.999999999m, 6m, 6m}, {-6.999999999m, -7m, -6m}, 
+				{0.00001m, 0m, 0m}, {-0.00001m, -1m, 0m}
+			};
+
+			decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = Decimal.Floor (dtab [i, 0]);
+				if (d != dtab [i, 1]) {
+					Fail ("Floor: Floor(" + dtab [i, 0] + ") != " + d);
+				}
+				d = Decimal.Truncate (dtab [i, 0]);
+				if (d != dtab [i, 2]) {
+					Fail ("Truncate: Truncate(" + dtab [i, 0] + ") != " + d);
+				}
+			}
+		}
 
-	[Test]
-	public void ToDouble () 
-	{
-		Decimal d = 254.9m;
-		AssertEquals ("Decimal.ToDouble", 254.9d, Decimal.ToDouble (d));
-		AssertEquals ("Convert.ToDouble", 254.9d, Convert.ToDouble (d));
-		AssertEquals ("IConvertible.ToDouble", 254.9d, (d as IConvertible).ToDouble (null));
-		d = -d;
-		AssertEquals ("-Decimal.ToDouble", -254.9d, Decimal.ToDouble (d));
-		AssertEquals ("-Convert.ToDouble", -254.9d, Convert.ToDouble (d));
-		AssertEquals ("-IConvertible.ToDouble", -254.9d, (d as IConvertible).ToDouble (null));
-	}
+		[Test]
+		public void Truncate ()
+		{
+			decimal dd = 249.9m;
+			decimal dt = Decimal.Truncate (dd);
+			AssertEquals ("Original", 249.9m, dd);
+			AssertEquals ("Truncate", 249m, dt);
+			AssertEquals ("Cast-Byte", 249, (byte) dd);
+			AssertEquals ("Cast-Char", 249, (char) dd);
+			AssertEquals ("Cast-Int16", 249, (short) dd);
+			AssertEquals ("Cast-UInt16", 249, (ushort) dd);
+			AssertEquals ("Cast-Int32", 249, (int) dd);
+			AssertEquals ("Cast-UInt32", 249, (uint) dd);
+			AssertEquals ("Cast-Int64", 249, (long) dd);
+			AssertEquals ("Cast-UInt64", 249, (ulong) dd);
+		}
 
-	[Test]
-	public void ToString_Defaults () 
-	{
-		Decimal d = 254.9m;
-		// everything defaults to "G"
-		string def = d.ToString ("G");
-		AssertEquals ("ToString()", def, d.ToString ());
-		AssertEquals ("ToString((IFormatProvider)null)", def, d.ToString ((IFormatProvider)null));
-		AssertEquals ("ToString((string)null)", def, d.ToString ((string)null));
-		AssertEquals ("ToString(empty)", def, d.ToString (String.Empty));
-		AssertEquals ("ToString(null,null)", def, d.ToString (null, null));
-		AssertEquals ("ToString(empty,null)", def, d.ToString (String.Empty, null));
-
-		AssertEquals ("ToString()", "254.9", def);
-	}
+		[Test]
+		public void TestRound ()
+		{
+			decimal [,] dtab = { 
+				{1m, 0, 1m}, {1.234567890m, 1, 1.2m}, 
+				{1.234567890m, 2, 1.23m}, {1.23450000001m, 3, 1.235m}, 
+				{1.2355m, 3, 1.236m}, 
+				{1.234567890m, 4, 1.2346m}, {1.23567890m, 2, 1.24m}, 
+				{47893764694.4578563236436621m, 7, 47893764694.4578563m},
+				{-47893764694.4578563236436621m, 9, -47893764694.457856324m},
+				{-47893764694.4578m, 5, -47893764694.4578m}
+			};
+
+			decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = Decimal.Round (dtab [i, 0], (int) dtab [i, 1]);
+				if (d != dtab [i, 2]) {
+					Fail ("Round: Round(" + dtab [i, 0] + "," + (int) dtab [i, 1] + ") != " + d);
+				}
+			}
+		}
 
-	[Test]
-	public void CastTruncRounding ()
-	{
-		// casting truncs decimal value (not normal nor banker's rounding)
-		AssertEquals ("254.9==254", 254, (long)(254.9m));
-		AssertEquals ("-254.9=-254", -254, (long)(-254.9m));
-		AssertEquals ("255.9==256", 255, (long)(255.9m));
-		AssertEquals ("-255.9=-256", -255, (long)(-255.9m));
-	}
+		[Test]
+		public void TestRoundFailures ()
+		{
+			decimal [,] dtab = {
+				{1.2345m, 3, 1.234m} 
+			};
+
+			decimal d;
+
+			for (int i = 0; i < dtab.GetLength (0); i++) {
+				d = Decimal.Round (dtab [i, 0], (int) dtab [i, 1]);
+				if (d != dtab [i, 2]) {
+					Fail ("FailRound: Round(" + dtab [i, 0] + "," + (int) dtab [i, 1] + ") != " + d);
+				}
+			}
+		}
 
-	[Test]
-	public void ParseFractions ()
-	{
-		decimal d1 = Decimal.Parse ("0.523456789012345467890123456789", CultureInfo.InvariantCulture);
-		AssertEquals ("f1", 0.5234567890123454678901234568m, d1);
-		decimal d2 = Decimal.Parse ("0.49214206543486529434634231456", CultureInfo.InvariantCulture);
-		AssertEquals ("f2", 0.4921420654348652943463423146m, d2);
-	}
+		[Test]
+		public void ParseInt64 ()
+		{
+			long max = Int64.MaxValue;
+			Decimal dmax = Decimal.Parse (max.ToString ());
+			AssertEquals ("Int64.MaxValue", Int64.MaxValue, Decimal.ToInt64 (dmax));
 
-	[Test]
-	[ExpectedException (typeof (OverflowException))]
-	public void Parse_Int64_Overflow ()
-	{
-		// Int64.MaxValue + 1 + small fraction to allow 30 digits
-		//                          123456789012345678901234567890
-		decimal d = Decimal.Parse ("9223372036854775808.0000000009", CultureInfo.InvariantCulture);
-		long l = (long) d;
-	}
+			long min = Int64.MinValue;
+			Decimal dmin = Decimal.Parse (min.ToString ());
+			AssertEquals ("Int64.MinValue", Int64.MinValue, Decimal.ToInt64 (dmin));
+
+			dmax += 1.1m;
+			dmax = Decimal.Parse (dmax.ToString ());
+			AssertEquals ("Int64.MaxValue+1.1", Int64.MaxValue, Decimal.ToInt64 (dmax - 1.1m));
+
+			dmin -= 1.1m;
+			dmin = Decimal.Parse (dmin.ToString ());
+			AssertEquals ("Int64.MinValue-1.1", Int64.MinValue, Decimal.ToInt64 (dmin + 1.1m));
+		}
+
+		[Test]
+		public void ToByte ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToByte", 254, Decimal.ToByte (d));
+			AssertEquals ("Convert.ToByte", 255, Convert.ToByte (d));
+			AssertEquals ("IConvertible.ToByte", 255, (d as IConvertible).ToByte (null));
+		}
+
+		[Test]
+		public void ToSByte ()
+		{
+			Decimal d = 126.9m;
+			AssertEquals ("Decimal.ToSByte", 126, Decimal.ToSByte (d));
+			AssertEquals ("Convert.ToSByte", 127, Convert.ToSByte (d));
+			AssertEquals ("IConvertible.ToSByte", 127, (d as IConvertible).ToSByte (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToSByte", -126, Decimal.ToSByte (d));
+			AssertEquals ("-Convert.ToSByte", -127, Convert.ToSByte (d));
+			AssertEquals ("-IConvertible.ToSByte", -127, (d as IConvertible).ToSByte (null));
+		}
+
+		[Test]
+		public void ToInt16 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToInt16", 254, Decimal.ToInt16 (d));
+			AssertEquals ("Convert.ToInt16", 255, Convert.ToInt16 (d));
+			AssertEquals ("IConvertible.ToInt16", 255, (d as IConvertible).ToInt16 (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToInt16", -254, Decimal.ToInt16 (d));
+			AssertEquals ("-Convert.ToInt16", -255, Convert.ToInt16 (d));
+			AssertEquals ("-IConvertible.ToInt16", -255, (d as IConvertible).ToInt16 (null));
+		}
+
+		[Test]
+		public void ToUInt16 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToUInt16", 254, Decimal.ToUInt16 (d));
+			AssertEquals ("Convert.ToUInt16", 255, Convert.ToUInt16 (d));
+			AssertEquals ("IConvertible.ToUInt16", 255, (d as IConvertible).ToUInt16 (null));
+		}
+
+		[Test]
+		public void ToInt32 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToInt32", 254, Decimal.ToInt32 (d));
+			AssertEquals ("Convert.ToInt32", 255, Convert.ToInt32 (d));
+			AssertEquals ("IConvertible.ToInt32", 255, (d as IConvertible).ToInt32 (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToInt32", -254, Decimal.ToInt32 (d));
+			AssertEquals ("-Convert.ToInt32", -255, Convert.ToInt32 (d));
+			AssertEquals ("-IConvertible.ToInt32", -255, (d as IConvertible).ToInt32 (null));
+		}
+
+		[Test]
+		public void ToUInt32 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToUInt32", 254, Decimal.ToUInt32 (d));
+			AssertEquals ("Convert.ToUInt32", 255, Convert.ToUInt32 (d));
+			AssertEquals ("IConvertible.ToUInt32", 255, (d as IConvertible).ToUInt32 (null));
+		}
+
+		[Test]
+		public void ToInt64 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToInt64", 254, Decimal.ToInt64 (d));
+			AssertEquals ("Convert.ToInt64", 255, Convert.ToInt64 (d));
+			AssertEquals ("IConvertible.ToInt64", 255, (d as IConvertible).ToInt64 (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToInt64", -254, Decimal.ToInt64 (d));
+			AssertEquals ("-Convert.ToInt64", -255, Convert.ToInt64 (d));
+			AssertEquals ("-IConvertible.ToInt64", -255, (d as IConvertible).ToInt64 (null));
+		}
+
+		[Test]
+		[ExpectedException (typeof (OverflowException))]
+		public void ToInt64_TooBig ()
+		{
+			Decimal d = (Decimal) Int64.MaxValue;
+			d += 1.1m;
+			long value = Decimal.ToInt64 (d);
+		}
+
+		[Test]
+		[ExpectedException (typeof (OverflowException))]
+		public void ToInt64_TooSmall ()
+		{
+			Decimal d = (Decimal) Int64.MinValue;
+			d -= 1.1m;
+			long value = Decimal.ToInt64 (d);
+		}
+
+		[Test]
+		public void ToUInt64 ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToUInt64", 254, Decimal.ToUInt64 (d));
+			AssertEquals ("Convert.ToUInt64", 255, Convert.ToUInt64 (d));
+			AssertEquals ("IConvertible.ToUInt64", 255, (d as IConvertible).ToUInt64 (null));
+		}
+
+		[Test]
+		public void ToSingle ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToSingle", 254.9f, Decimal.ToSingle (d));
+			AssertEquals ("Convert.ToSingle", 254.9f, Convert.ToSingle (d));
+			AssertEquals ("IConvertible.ToSingle", 254.9f, (d as IConvertible).ToSingle (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToSingle", -254.9f, Decimal.ToSingle (d));
+			AssertEquals ("-Convert.ToSingle", -254.9f, Convert.ToSingle (d));
+			AssertEquals ("-IConvertible.ToSingle", -254.9f, (d as IConvertible).ToSingle (null));
+		}
+
+		[Test]
+		public void ToDouble ()
+		{
+			Decimal d = 254.9m;
+			AssertEquals ("Decimal.ToDouble", 254.9d, Decimal.ToDouble (d));
+			AssertEquals ("Convert.ToDouble", 254.9d, Convert.ToDouble (d));
+			AssertEquals ("IConvertible.ToDouble", 254.9d, (d as IConvertible).ToDouble (null));
+			d = -d;
+			AssertEquals ("-Decimal.ToDouble", -254.9d, Decimal.ToDouble (d));
+			AssertEquals ("-Convert.ToDouble", -254.9d, Convert.ToDouble (d));
+			AssertEquals ("-IConvertible.ToDouble", -254.9d, (d as IConvertible).ToDouble (null));
+		}
+
+		[Test]
+		public void ToString_Defaults ()
+		{
+			Decimal d = 254.9m;
+			// everything defaults to "G"
+			string def = d.ToString ("G");
+			AssertEquals ("ToString()", def, d.ToString ());
+			AssertEquals ("ToString((IFormatProvider)null)", def, d.ToString ((IFormatProvider) null));
+			AssertEquals ("ToString((string)null)", def, d.ToString ((string) null));
+			AssertEquals ("ToString(empty)", def, d.ToString (String.Empty));
+			AssertEquals ("ToString(null,null)", def, d.ToString (null, null));
+			AssertEquals ("ToString(empty,null)", def, d.ToString (String.Empty, null));
+
+			AssertEquals ("ToString()", "254.9", def);
+		}
+
+		[Test]
+		public void CastTruncRounding ()
+		{
+			// casting truncs decimal value (not normal nor banker's rounding)
+			AssertEquals ("254.9==254", 254, (long) (254.9m));
+			AssertEquals ("-254.9=-254", -254, (long) (-254.9m));
+			AssertEquals ("255.9==256", 255, (long) (255.9m));
+			AssertEquals ("-255.9=-256", -255, (long) (-255.9m));
+		}
+
+		[Test]
+		public void ParseFractions ()
+		{
+			decimal d1 = Decimal.Parse ("0.523456789012345467890123456789", CultureInfo.InvariantCulture);
+			AssertEquals ("f1", 0.5234567890123454678901234568m, d1);
+			decimal d2 = Decimal.Parse ("0.49214206543486529434634231456", CultureInfo.InvariantCulture);
+			AssertEquals ("f2", 0.4921420654348652943463423146m, d2);
+		}
+
+		[Test]
+		[ExpectedException (typeof (OverflowException))]
+		public void Parse_Int64_Overflow ()
+		{
+			// Int64.MaxValue + 1 + small fraction to allow 30 digits
+			// 123456789012345678901234567890
+			decimal d = Decimal.Parse ("9223372036854775808.0000000009", CultureInfo.InvariantCulture);
+			long l = (long) d;
+		}
 
 #if NET_2_0
-        [Test]
-	public void TryParse ()
-	{
-		Decimal r;
+		[Test]
+		public void TryParse ()
+		{
+			Decimal r;
 		
-		// These should return false
-		AssertEquals (false, Decimal.TryParse ("79228162514264337593543950336", out r));
-		AssertEquals (false, Decimal.TryParse ("123nx", NumberStyles.Number, CultureInfo.InvariantCulture, out r));
-		AssertEquals (false, Decimal.TryParse (null, NumberStyles.Number, CultureInfo.InvariantCulture, out r));
-
-		// These should pass
-		for (int i = 0; i < tab.Length; i++){
-			AssertEquals (!tab [i].exceptionFlag,
-				      Decimal.TryParse (tab [i].str, tab [i].style,
-							NumberFormatInfo.InvariantInfo, out r));
+			// These should return false
+			AssertEquals (false, Decimal.TryParse ("79228162514264337593543950336", out r));
+			AssertEquals (false, Decimal.TryParse ("123nx", NumberStyles.Number, CultureInfo.InvariantCulture, out r));
+			AssertEquals (false, Decimal.TryParse (null, NumberStyles.Number, CultureInfo.InvariantCulture, out r));
+
+			// These should pass
+			for (int i = 0; i < tab.Length; i++) {
+				AssertEquals (!tab [i].exceptionFlag,
+					Decimal.TryParse (tab [i].str, tab [i].style,
+					NumberFormatInfo.InvariantInfo, out r));
+			}
 		}
-	}
 #endif
 
-	[Test]
-	[ExpectedException (typeof (DivideByZeroException))]
-	public void Remainder_ByZero () 
-	{
-		Decimal.Remainder (254.9m, 0m);
-	}
+		[Test]
+		[ExpectedException (typeof (DivideByZeroException))]
+		public void Remainder_ByZero ()
+		{
+			Decimal.Remainder (254.9m, 0m);
+		}
 
-	[Test]
-	public void Remainder () 
-	{
-		decimal p1 = 254.9m;
-		decimal p2 = 12.1m;
-		decimal n1 = -254.9m;
-		decimal n2 = -12.1m;
-
-		AssertEquals ("254.9 % 12.1", 0.8m, Decimal.Remainder (p1, p2));
-		AssertEquals ("-254.9 % 12.1", -0.8m, Decimal.Remainder (n1, p2));
-		AssertEquals ("254.9 % -12.1", 0.8m, Decimal.Remainder (p1, n2));
-		AssertEquals ("-254.9 % -12.1", -0.8m, Decimal.Remainder (n1, n2));
-
-		AssertEquals ("12.1 % 254.9", 12.1m, Decimal.Remainder (p2, p1));
-		AssertEquals ("-12.1 % 254.9", -12.1m, Decimal.Remainder (n2, p1));
-		AssertEquals ("12.1 % -254.9", 12.1m, Decimal.Remainder (p2, n1));
-		AssertEquals ("-12.1 % -254.9", -12.1m, Decimal.Remainder (n2, n1));
+		[Test]
+		public void Remainder ()
+		{
+			decimal p1 = 254.9m;
+			decimal p2 = 12.1m;
+			decimal n1 = -254.9m;
+			decimal n2 = -12.1m;
+
+			AssertEquals ("254.9 % 12.1", 0.8m, Decimal.Remainder (p1, p2));
+			AssertEquals ("-254.9 % 12.1", -0.8m, Decimal.Remainder (n1, p2));
+			AssertEquals ("254.9 % -12.1", 0.8m, Decimal.Remainder (p1, n2));
+			AssertEquals ("-254.9 % -12.1", -0.8m, Decimal.Remainder (n1, n2));
+
+			AssertEquals ("12.1 % 254.9", 12.1m, Decimal.Remainder (p2, p1));
+			AssertEquals ("-12.1 % 254.9", -12.1m, Decimal.Remainder (n2, p1));
+			AssertEquals ("12.1 % -254.9", 12.1m, Decimal.Remainder (p2, n1));
+			AssertEquals ("-12.1 % -254.9", -12.1m, Decimal.Remainder (n2, n1));
 #if NET_2_0
-		AssertEquals ("12.1 % 12.1", 0.0m, Decimal.Remainder (p1, p1));
-		AssertEquals ("-12.1 % 12.1", 0.0m, Decimal.Remainder (n1, p1));
-		AssertEquals ("12.1 % -12.1", 0.0m, Decimal.Remainder (p1, n1));
-		AssertEquals ("-12.1 % -12.1", 0.0m, Decimal.Remainder (n1, n1));
+			AssertEquals ("12.1 % 12.1", 0.0m, Decimal.Remainder (p1, p1));
+			AssertEquals ("-12.1 % 12.1", 0.0m, Decimal.Remainder (n1, p1));
+			AssertEquals ("12.1 % -12.1", 0.0m, Decimal.Remainder (p1, n1));
+			AssertEquals ("-12.1 % -12.1", 0.0m, Decimal.Remainder (n1, n1));
 #else
-		AssertEquals ("12.1 % 12.1", 0, Decimal.Remainder (p1, p1));
-		AssertEquals ("-12.1 % 12.1", 0, Decimal.Remainder (n1, p1));
-		AssertEquals ("12.1 % -12.1", 0, Decimal.Remainder (p1, n1));
-		AssertEquals ("-12.1 % -12.1", 0, Decimal.Remainder (n1, n1));
+			AssertEquals ("12.1 % 12.1", 0, Decimal.Remainder (p1, p1));
+			AssertEquals ("-12.1 % 12.1", 0, Decimal.Remainder (n1, p1));
+			AssertEquals ("12.1 % -12.1", 0, Decimal.Remainder (p1, n1));
+			AssertEquals ("-12.1 % -12.1", 0, Decimal.Remainder (n1, n1));
 #endif
-	}
-
-	[Test]
-	[ExpectedException (typeof (DivideByZeroException))]
-	public void Divide_ByZero () 
-	{
-		Decimal.Divide (254.9m, 0m);
-	}
+		}
 
-	[Test]
-	public void Divide () 
-	{
-		decimal p1 = 254.9m;
-		decimal p2 = 12.1m;
-		decimal n1 = -254.9m;
-		decimal n2 = -12.1m;
-
-		decimal c1 = 21.066115702479338842975206612m;
-		decimal c2 = 0.0474695959199686151431934092m;
-
-		AssertEquals ("254.9 / 12.1", c1, Decimal.Divide (p1, p2));
-		AssertEquals ("-254.9 / 12.1", -c1, Decimal.Divide (n1, p2));
-		AssertEquals ("254.9 / -12.1", -c1, Decimal.Divide (p1, n2));
-		AssertEquals ("-254.9 / -12.1", c1, Decimal.Divide (n1, n2));
-
-		AssertEquals ("12.1 / 254.9", c2, Decimal.Divide (p2, p1));
-		AssertEquals ("-12.1 / 254.9", -c2, Decimal.Divide (n2, p1));
-		AssertEquals ("12.1 / -254.9", -c2, Decimal.Divide (p2, n1));
-		AssertEquals ("-12.1 / -254.9", c2, Decimal.Divide (n2, n1));
-
-		AssertEquals ("12.1 / 12.1", 1, Decimal.Divide (p1, p1));
-		AssertEquals ("-12.1 / 12.1", -1, Decimal.Divide (n1, p1));
-		AssertEquals ("12.1 / -12.1", -1, Decimal.Divide (p1, n1));
-		AssertEquals ("-12.1 / -12.1", 1, Decimal.Divide (n1, n1));
-	}
+		[Test]
+		[ExpectedException (typeof (DivideByZeroException))]
+		public void Divide_ByZero ()
+		{
+			Decimal.Divide (254.9m, 0m);
+		}
 
-	[Test]
-	[ExpectedException (typeof (ArgumentOutOfRangeException))]
-	public void Round_InvalidDecimals_Negative () 
-	{
-		Decimal.Round (254.9m, -1);
-	}
+		[Test]
+		public void Divide ()
+		{
+			decimal p1 = 254.9m;
+			decimal p2 = 12.1m;
+			decimal n1 = -254.9m;
+			decimal n2 = -12.1m;
+
+			decimal c1 = 21.066115702479338842975206612m;
+			decimal c2 = 0.0474695959199686151431934092m;
+
+			AssertEquals ("254.9 / 12.1", c1, Decimal.Divide (p1, p2));
+			AssertEquals ("-254.9 / 12.1", -c1, Decimal.Divide (n1, p2));
+			AssertEquals ("254.9 / -12.1", -c1, Decimal.Divide (p1, n2));
+			AssertEquals ("-254.9 / -12.1", c1, Decimal.Divide (n1, n2));
+
+			AssertEquals ("12.1 / 254.9", c2, Decimal.Divide (p2, p1));
+			AssertEquals ("-12.1 / 254.9", -c2, Decimal.Divide (n2, p1));
+			AssertEquals ("12.1 / -254.9", -c2, Decimal.Divide (p2, n1));
+			AssertEquals ("-12.1 / -254.9", c2, Decimal.Divide (n2, n1));
+
+			AssertEquals ("12.1 / 12.1", 1, Decimal.Divide (p1, p1));
+			AssertEquals ("-12.1 / 12.1", -1, Decimal.Divide (n1, p1));
+			AssertEquals ("12.1 / -12.1", -1, Decimal.Divide (p1, n1));
+			AssertEquals ("-12.1 / -12.1", 1, Decimal.Divide (n1, n1));
+		}
 
-	[Test]
-	[ExpectedException (typeof (ArgumentOutOfRangeException))]
-	public void Round_InvalidDecimals_TooHigh () 
-	{
-		Decimal.Round (254.9m, 29);
-	}
+		[Test]
+		[ExpectedException (typeof (ArgumentOutOfRangeException))]
+		public void Round_InvalidDecimals_Negative ()
+		{
+			Decimal.Round (254.9m, -1);
+		}
 
-	[Test]
-	public void Round_OddValue () 
-	{
-		decimal five = 5.5555555555555555555555555555m;
-		AssertEquals ("5,5_,00", 6, Decimal.Round (five, 0));
-		AssertEquals ("5,5_,01", 5.6m, Decimal.Round (five, 1));
-		AssertEquals ("5,5_,02", 5.56m, Decimal.Round (five, 2));
-		AssertEquals ("5,5_,03", 5.556m, Decimal.Round (five, 3));
-		AssertEquals ("5,5_,04", 5.5556m, Decimal.Round (five, 4));
-		AssertEquals ("5,5_,05", 5.55556m, Decimal.Round (five, 5));
-		AssertEquals ("5,5_,06", 5.555556m, Decimal.Round (five, 6));
-		AssertEquals ("5,5_,07", 5.5555556m, Decimal.Round (five, 7));
-		AssertEquals ("5,5_,08", 5.55555556m, Decimal.Round (five, 8));
-		AssertEquals ("5,5_,09", 5.555555556m, Decimal.Round (five, 9));
-		AssertEquals ("5,5_,10", 5.5555555556m, Decimal.Round (five, 10));
-		AssertEquals ("5,5_,11", 5.55555555556m, Decimal.Round (five, 11));
-		AssertEquals ("5,5_,12", 5.555555555556m, Decimal.Round (five, 12));
-		AssertEquals ("5,5_,13", 5.5555555555556m, Decimal.Round (five, 13));
-		AssertEquals ("5,5_,14", 5.55555555555556m, Decimal.Round (five, 14));
-		AssertEquals ("5,5_,15", 5.555555555555556m, Decimal.Round (five, 15));
-		AssertEquals ("5,5_,16", 5.5555555555555556m, Decimal.Round (five, 16));
-		AssertEquals ("5,5_,17", 5.55555555555555556m, Decimal.Round (five, 17));
-		AssertEquals ("5,5_,18", 5.555555555555555556m, Decimal.Round (five, 18));
-		AssertEquals ("5,5_,19", 5.5555555555555555556m, Decimal.Round (five, 19));
-		AssertEquals ("5,5_,20", 5.55555555555555555556m, Decimal.Round (five, 20));
-		AssertEquals ("5,5_,21", 5.555555555555555555556m, Decimal.Round (five, 21));
-		AssertEquals ("5,5_,22", 5.5555555555555555555556m, Decimal.Round (five, 22));
-		AssertEquals ("5,5_,23", 5.55555555555555555555556m, Decimal.Round (five, 23));
-		AssertEquals ("5,5_,24", 5.555555555555555555555556m, Decimal.Round (five, 24));
-		AssertEquals ("5,5_,25", 5.5555555555555555555555556m, Decimal.Round (five, 25));
-		AssertEquals ("5,5_,26", 5.55555555555555555555555556m, Decimal.Round (five, 26));
-		AssertEquals ("5,5_,27", 5.555555555555555555555555556m, Decimal.Round (five, 27));
-		AssertEquals ("5.5_,28", 5.5555555555555555555555555555m, Decimal.Round (five, 28));
-	}
+		[Test]
+		[ExpectedException (typeof (ArgumentOutOfRangeException))]
+		public void Round_InvalidDecimals_TooHigh ()
+		{
+			Decimal.Round (254.9m, 29);
+		}
 
-	[Test]
-	public void Round_EvenValue () 
-	{
-		AssertEquals ("2,2_5,00", 2, Decimal.Round (2.5m, 0));
-		AssertEquals ("2,2_5,01", 2.2m, Decimal.Round (2.25m, 1));
-		AssertEquals ("2,2_5,02", 2.22m, Decimal.Round (2.225m, 2));
-		AssertEquals ("2,2_5,03", 2.222m, Decimal.Round (2.2225m, 3));
-		AssertEquals ("2,2_5,04", 2.2222m, Decimal.Round (2.22225m, 4));
-		AssertEquals ("2,2_5,05", 2.22222m, Decimal.Round (2.222225m, 5));
-		AssertEquals ("2,2_5,06", 2.222222m, Decimal.Round (2.2222225m, 6));
-		AssertEquals ("2,2_5,07", 2.2222222m, Decimal.Round (2.22222225m, 7));
-		AssertEquals ("2,2_5,08", 2.22222222m, Decimal.Round (2.222222225m, 8));
-		AssertEquals ("2,2_5,09", 2.222222222m, Decimal.Round (2.2222222225m, 9));
-		AssertEquals ("2,2_5,10", 2.2222222222m, Decimal.Round (2.22222222225m, 10));
-		AssertEquals ("2,2_5,11", 2.22222222222m, Decimal.Round (2.222222222225m, 11));
-		AssertEquals ("2,2_5,12", 2.222222222222m, Decimal.Round (2.2222222222225m, 12));
-		AssertEquals ("2,2_5,13", 2.2222222222222m, Decimal.Round (2.22222222222225m, 13));
-		AssertEquals ("2,2_5,14", 2.22222222222222m, Decimal.Round (2.222222222222225m, 14));
-		AssertEquals ("2,2_5,15", 2.222222222222222m, Decimal.Round (2.2222222222222225m, 15));
-		AssertEquals ("2,2_5,16", 2.2222222222222222m, Decimal.Round (2.22222222222222225m, 16));
-		AssertEquals ("2,2_5,17", 2.22222222222222222m, Decimal.Round (2.222222222222222225m, 17));
-		AssertEquals ("2,2_5,18", 2.222222222222222222m, Decimal.Round (2.2222222222222222225m, 18));
-		AssertEquals ("2,2_5,19", 2.2222222222222222222m, Decimal.Round (2.22222222222222222225m, 19));
-		AssertEquals ("2,2_5,20", 2.22222222222222222222m, Decimal.Round (2.222222222222222222225m, 20));
-		AssertEquals ("2,2_5,21", 2.222222222222222222222m, Decimal.Round (2.2222222222222222222225m, 21));
-		AssertEquals ("2,2_5,22", 2.2222222222222222222222m, Decimal.Round (2.22222222222222222222225m, 22));
-		AssertEquals ("2,2_5,23", 2.22222222222222222222222m, Decimal.Round (2.222222222222222222222225m, 23));
-		AssertEquals ("2,2_5,24", 2.222222222222222222222222m, Decimal.Round (2.2222222222222222222222225m, 24));
-		AssertEquals ("2,2_5,25", 2.2222222222222222222222222m, Decimal.Round (2.22222222222222222222222225m, 25));
-		AssertEquals ("2,2_5,26", 2.22222222222222222222222222m, Decimal.Round (2.222222222222222222222222225m, 26));
-		AssertEquals ("2,2_5,27", 2.222222222222222222222222222m, Decimal.Round (2.2222222222222222222222222225m, 27));
-		AssertEquals ("2,2_5,28", 2.2222222222222222222222222222m, Decimal.Round (2.22222222222222222222222222225m, 28));
-	}
+		[Test]
+		public void Round_OddValue ()
+		{
+			decimal five = 5.5555555555555555555555555555m;
+			AssertEquals ("5,5_,00", 6, Decimal.Round (five, 0));
+			AssertEquals ("5,5_,01", 5.6m, Decimal.Round (five, 1));
+			AssertEquals ("5,5_,02", 5.56m, Decimal.Round (five, 2));
+			AssertEquals ("5,5_,03", 5.556m, Decimal.Round (five, 3));
+			AssertEquals ("5,5_,04", 5.5556m, Decimal.Round (five, 4));
+			AssertEquals ("5,5_,05", 5.55556m, Decimal.Round (five, 5));
+			AssertEquals ("5,5_,06", 5.555556m, Decimal.Round (five, 6));
+			AssertEquals ("5,5_,07", 5.5555556m, Decimal.Round (five, 7));
+			AssertEquals ("5,5_,08", 5.55555556m, Decimal.Round (five, 8));
+			AssertEquals ("5,5_,09", 5.555555556m, Decimal.Round (five, 9));
+			AssertEquals ("5,5_,10", 5.5555555556m, Decimal.Round (five, 10));
+			AssertEquals ("5,5_,11", 5.55555555556m, Decimal.Round (five, 11));
+			AssertEquals ("5,5_,12", 5.555555555556m, Decimal.Round (five, 12));
+			AssertEquals ("5,5_,13", 5.5555555555556m, Decimal.Round (five, 13));
+			AssertEquals ("5,5_,14", 5.55555555555556m, Decimal.Round (five, 14));
+			AssertEquals ("5,5_,15", 5.555555555555556m, Decimal.Round (five, 15));
+			AssertEquals ("5,5_,16", 5.5555555555555556m, Decimal.Round (five, 16));
+			AssertEquals ("5,5_,17", 5.55555555555555556m, Decimal.Round (five, 17));
+			AssertEquals ("5,5_,18", 5.555555555555555556m, Decimal.Round (five, 18));
+			AssertEquals ("5,5_,19", 5.5555555555555555556m, Decimal.Round (five, 19));
+			AssertEquals ("5,5_,20", 5.55555555555555555556m, Decimal.Round (five, 20));
+			AssertEquals ("5,5_,21", 5.555555555555555555556m, Decimal.Round (five, 21));
+			AssertEquals ("5,5_,22", 5.5555555555555555555556m, Decimal.Round (five, 22));
+			AssertEquals ("5,5_,23", 5.55555555555555555555556m, Decimal.Round (five, 23));
+			AssertEquals ("5,5_,24", 5.555555555555555555555556m, Decimal.Round (five, 24));
+			AssertEquals ("5,5_,25", 5.5555555555555555555555556m, Decimal.Round (five, 25));
+			AssertEquals ("5,5_,26", 5.55555555555555555555555556m, Decimal.Round (five, 26));
+			AssertEquals ("5,5_,27", 5.555555555555555555555555556m, Decimal.Round (five, 27));
+			AssertEquals ("5.5_,28", 5.5555555555555555555555555555m, Decimal.Round (five, 28));
+		}
 
-	[Test]
-	public void Round_OddValue_Negative () 
-	{
-		decimal five = -5.5555555555555555555555555555m;
-		AssertEquals ("-5,5_,00", -6, Decimal.Round (five, 0));
-		AssertEquals ("-5,5_,01", -5.6m, Decimal.Round (five, 1));
-		AssertEquals ("-5,5_,02", -5.56m, Decimal.Round (five, 2));
-		AssertEquals ("-5,5_,03", -5.556m, Decimal.Round (five, 3));
-		AssertEquals ("-5,5_,04", -5.5556m, Decimal.Round (five, 4));
-		AssertEquals ("-5,5_,05", -5.55556m, Decimal.Round (five, 5));
-		AssertEquals ("-5,5_,06", -5.555556m, Decimal.Round (five, 6));
-		AssertEquals ("-5,5_,07", -5.5555556m, Decimal.Round (five, 7));
-		AssertEquals ("-5,5_,08", -5.55555556m, Decimal.Round (five, 8));
-		AssertEquals ("-5,5_,09", -5.555555556m, Decimal.Round (five, 9));
-		AssertEquals ("-5,5_,10", -5.5555555556m, Decimal.Round (five, 10));
-		AssertEquals ("-5,5_,11", -5.55555555556m, Decimal.Round (five, 11));
-		AssertEquals ("-5,5_,12", -5.555555555556m, Decimal.Round (five, 12));
-		AssertEquals ("-5,5_,13", -5.5555555555556m, Decimal.Round (five, 13));
-		AssertEquals ("-5,5_,14", -5.55555555555556m, Decimal.Round (five, 14));
-		AssertEquals ("-5,5_,15", -5.555555555555556m, Decimal.Round (five, 15));
-		AssertEquals ("-5,5_,16", -5.5555555555555556m, Decimal.Round (five, 16));
-		AssertEquals ("-5,5_,17", -5.55555555555555556m, Decimal.Round (five, 17));
-		AssertEquals ("-5,5_,18", -5.555555555555555556m, Decimal.Round (five, 18));
-		AssertEquals ("-5,5_,19", -5.5555555555555555556m, Decimal.Round (five, 19));
-		AssertEquals ("-5,5_,20", -5.55555555555555555556m, Decimal.Round (five, 20));
-		AssertEquals ("-5,5_,21", -5.555555555555555555556m, Decimal.Round (five, 21));
-		AssertEquals ("-5,5_,22", -5.5555555555555555555556m, Decimal.Round (five, 22));
-		AssertEquals ("-5,5_,23", -5.55555555555555555555556m, Decimal.Round (five, 23));
-		AssertEquals ("-5,5_,24", -5.555555555555555555555556m, Decimal.Round (five, 24));
-		AssertEquals ("-5,5_,25", -5.5555555555555555555555556m, Decimal.Round (five, 25));
-		AssertEquals ("-5,5_,26", -5.55555555555555555555555556m, Decimal.Round (five, 26));
-		AssertEquals ("-5,5_,27", -5.555555555555555555555555556m, Decimal.Round (five, 27));
-		AssertEquals ("-5.5_,28", -5.5555555555555555555555555555m, Decimal.Round (five, 28));
-	}
+		[Test]
+		public void Round_EvenValue ()
+		{
+			AssertEquals ("2,2_5,00", 2, Decimal.Round (2.5m, 0));
+			AssertEquals ("2,2_5,01", 2.2m, Decimal.Round (2.25m, 1));
+			AssertEquals ("2,2_5,02", 2.22m, Decimal.Round (2.225m, 2));
+			AssertEquals ("2,2_5,03", 2.222m, Decimal.Round (2.2225m, 3));
+			AssertEquals ("2,2_5,04", 2.2222m, Decimal.Round (2.22225m, 4));
+			AssertEquals ("2,2_5,05", 2.22222m, Decimal.Round (2.222225m, 5));
+			AssertEquals ("2,2_5,06", 2.222222m, Decimal.Round (2.2222225m, 6));
+			AssertEquals ("2,2_5,07", 2.2222222m, Decimal.Round (2.22222225m, 7));
+			AssertEquals ("2,2_5,08", 2.22222222m, Decimal.Round (2.222222225m, 8));
+			AssertEquals ("2,2_5,09", 2.222222222m, Decimal.Round (2.2222222225m, 9));
+			AssertEquals ("2,2_5,10", 2.2222222222m, Decimal.Round (2.22222222225m, 10));
+			AssertEquals ("2,2_5,11", 2.22222222222m, Decimal.Round (2.222222222225m, 11));
+			AssertEquals ("2,2_5,12", 2.222222222222m, Decimal.Round (2.2222222222225m, 12));
+			AssertEquals ("2,2_5,13", 2.2222222222222m, Decimal.Round (2.22222222222225m, 13));
+			AssertEquals ("2,2_5,14", 2.22222222222222m, Decimal.Round (2.222222222222225m, 14));
+			AssertEquals ("2,2_5,15", 2.222222222222222m, Decimal.Round (2.2222222222222225m, 15));
+			AssertEquals ("2,2_5,16", 2.2222222222222222m, Decimal.Round (2.22222222222222225m, 16));
+			AssertEquals ("2,2_5,17", 2.22222222222222222m, Decimal.Round (2.222222222222222225m, 17));
+			AssertEquals ("2,2_5,18", 2.222222222222222222m, Decimal.Round (2.2222222222222222225m, 18));
+			AssertEquals ("2,2_5,19", 2.2222222222222222222m, Decimal.Round (2.22222222222222222225m, 19));
+			AssertEquals ("2,2_5,20", 2.22222222222222222222m, Decimal.Round (2.222222222222222222225m, 20));
+			AssertEquals ("2,2_5,21", 2.222222222222222222222m, Decimal.Round (2.2222222222222222222225m, 21));
+			AssertEquals ("2,2_5,22", 2.2222222222222222222222m, Decimal.Round (2.22222222222222222222225m, 22));
+			AssertEquals ("2,2_5,23", 2.22222222222222222222222m, Decimal.Round (2.222222222222222222222225m, 23));
+			AssertEquals ("2,2_5,24", 2.222222222222222222222222m, Decimal.Round (2.2222222222222222222222225m, 24));
+			AssertEquals ("2,2_5,25", 2.2222222222222222222222222m, Decimal.Round (2.22222222222222222222222225m, 25));
+			AssertEquals ("2,2_5,26", 2.22222222222222222222222222m, Decimal.Round (2.222222222222222222222222225m, 26));
+			AssertEquals ("2,2_5,27", 2.222222222222222222222222222m, Decimal.Round (2.2222222222222222222222222225m, 27));
+			AssertEquals ("2,2_5,28", 2.2222222222222222222222222222m, Decimal.Round (2.22222222222222222222222222225m, 28));
+		}
 
-	[Test]
-	public void Round_EvenValue_Negative () 
-	{
-		AssertEquals ("-2,2_5,00", -2, Decimal.Round (-2.5m, 0));
-		AssertEquals ("-2,2_5,01", -2.2m, Decimal.Round (-2.25m, 1));
-		AssertEquals ("-2,2_5,02", -2.22m, Decimal.Round (-2.225m, 2));
-		AssertEquals ("-2,2_5,03", -2.222m, Decimal.Round (-2.2225m, 3));
-		AssertEquals ("-2,2_5,04", -2.2222m, Decimal.Round (-2.22225m, 4));
-		AssertEquals ("-2,2_5,05", -2.22222m, Decimal.Round (-2.222225m, 5));
-		AssertEquals ("-2,2_5,06", -2.222222m, Decimal.Round (-2.2222225m, 6));
-		AssertEquals ("-2,2_5,07", -2.2222222m, Decimal.Round (-2.22222225m, 7));
-		AssertEquals ("-2,2_5,08", -2.22222222m, Decimal.Round (-2.222222225m, 8));
-		AssertEquals ("-2,2_5,09", -2.222222222m, Decimal.Round (-2.2222222225m, 9));
-		AssertEquals ("-2,2_5,10", -2.2222222222m, Decimal.Round (-2.22222222225m, 10));
-		AssertEquals ("-2,2_5,11", -2.22222222222m, Decimal.Round (-2.222222222225m, 11));
-		AssertEquals ("-2,2_5,12", -2.222222222222m, Decimal.Round (-2.2222222222225m, 12));
-		AssertEquals ("-2,2_5,13", -2.2222222222222m, Decimal.Round (-2.22222222222225m, 13));
-		AssertEquals ("-2,2_5,14", -2.22222222222222m, Decimal.Round (-2.222222222222225m, 14));
-		AssertEquals ("-2,2_5,15", -2.222222222222222m, Decimal.Round (-2.2222222222222225m, 15));
-		AssertEquals ("-2,2_5,16", -2.2222222222222222m, Decimal.Round (-2.22222222222222225m, 16));
-		AssertEquals ("-2,2_5,17", -2.22222222222222222m, Decimal.Round (-2.222222222222222225m, 17));
-		AssertEquals ("-2,2_5,18", -2.222222222222222222m, Decimal.Round (-2.2222222222222222225m, 18));
-		AssertEquals ("-2,2_5,19", -2.2222222222222222222m, Decimal.Round (-2.22222222222222222225m, 19));
-		AssertEquals ("-2,2_5,20", -2.22222222222222222222m, Decimal.Round (-2.222222222222222222225m, 20));
-		AssertEquals ("-2,2_5,21", -2.222222222222222222222m, Decimal.Round (-2.2222222222222222222225m, 21));
-		AssertEquals ("-2,2_5,22", -2.2222222222222222222222m, Decimal.Round (-2.22222222222222222222225m, 22));
-		AssertEquals ("-2,2_5,23", -2.22222222222222222222222m, Decimal.Round (-2.222222222222222222222225m, 23));
-		AssertEquals ("-2,2_5,24", -2.222222222222222222222222m, Decimal.Round (-2.2222222222222222222222225m, 24));
-		AssertEquals ("-2,2_5,25", -2.2222222222222222222222222m, Decimal.Round (-2.22222222222222222222222225m, 25));
-		AssertEquals ("-2,2_5,26", -2.22222222222222222222222222m, Decimal.Round (-2.222222222222222222222222225m, 26));
-		AssertEquals ("-2,2_5,27", -2.222222222222222222222222222m, Decimal.Round (-2.2222222222222222222222222225m, 27));
-		AssertEquals ("-2,2_5,28", -2.2222222222222222222222222222m, Decimal.Round (-2.22222222222222222222222222225m, 28));
-	}
+		[Test]
+		public void Round_OddValue_Negative ()
+		{
+			decimal five = -5.5555555555555555555555555555m;
+			AssertEquals ("-5,5_,00", -6, Decimal.Round (five, 0));
+			AssertEquals ("-5,5_,01", -5.6m, Decimal.Round (five, 1));
+			AssertEquals ("-5,5_,02", -5.56m, Decimal.Round (five, 2));
+			AssertEquals ("-5,5_,03", -5.556m, Decimal.Round (five, 3));
+			AssertEquals ("-5,5_,04", -5.5556m, Decimal.Round (five, 4));
+			AssertEquals ("-5,5_,05", -5.55556m, Decimal.Round (five, 5));
+			AssertEquals ("-5,5_,06", -5.555556m, Decimal.Round (five, 6));
+			AssertEquals ("-5,5_,07", -5.5555556m, Decimal.Round (five, 7));
+			AssertEquals ("-5,5_,08", -5.55555556m, Decimal.Round (five, 8));
+			AssertEquals ("-5,5_,09", -5.555555556m, Decimal.Round (five, 9));
+			AssertEquals ("-5,5_,10", -5.5555555556m, Decimal.Round (five, 10));
+			AssertEquals ("-5,5_,11", -5.55555555556m, Decimal.Round (five, 11));
+			AssertEquals ("-5,5_,12", -5.555555555556m, Decimal.Round (five, 12));
+			AssertEquals ("-5,5_,13", -5.5555555555556m, Decimal.Round (five, 13));
+			AssertEquals ("-5,5_,14", -5.55555555555556m, Decimal.Round (five, 14));
+			AssertEquals ("-5,5_,15", -5.555555555555556m, Decimal.Round (five, 15));
+			AssertEquals ("-5,5_,16", -5.5555555555555556m, Decimal.Round (five, 16));
+			AssertEquals ("-5,5_,17", -5.55555555555555556m, Decimal.Round (five, 17));
+			AssertEquals ("-5,5_,18", -5.555555555555555556m, Decimal.Round (five, 18));
+			AssertEquals ("-5,5_,19", -5.5555555555555555556m, Decimal.Round (five, 19));
+			AssertEquals ("-5,5_,20", -5.55555555555555555556m, Decimal.Round (five, 20));
+			AssertEquals ("-5,5_,21", -5.555555555555555555556m, Decimal.Round (five, 21));
+			AssertEquals ("-5,5_,22", -5.5555555555555555555556m, Decimal.Round (five, 22));
+			AssertEquals ("-5,5_,23", -5.55555555555555555555556m, Decimal.Round (five, 23));
+			AssertEquals ("-5,5_,24", -5.555555555555555555555556m, Decimal.Round (five, 24));
+			AssertEquals ("-5,5_,25", -5.5555555555555555555555556m, Decimal.Round (five, 25));
+			AssertEquals ("-5,5_,26", -5.55555555555555555555555556m, Decimal.Round (five, 26));
+			AssertEquals ("-5,5_,27", -5.555555555555555555555555556m, Decimal.Round (five, 27));
+			AssertEquals ("-5.5_,28", -5.5555555555555555555555555555m, Decimal.Round (five, 28));
+		}
 
-	[Test]
-	// http://bugzilla.ximian.com/show_bug.cgi?id=59425
-	public void ParseAndKeepPrecision () 
-	{
-		string value = "5";
-		AssertEquals (value, value, Decimal.Parse (value).ToString ());
-		value += '.';
-		for (int i=0; i < 28; i++) {
-			value += "0";
-			AssertEquals (i.ToString(), value, Decimal.Parse (value).ToString ());
+		[Test]
+		public void Round_EvenValue_Negative ()
+		{
+			AssertEquals ("-2,2_5,00", -2, Decimal.Round (-2.5m, 0));
+			AssertEquals ("-2,2_5,01", -2.2m, Decimal.Round (-2.25m, 1));
+			AssertEquals ("-2,2_5,02", -2.22m, Decimal.Round (-2.225m, 2));
+			AssertEquals ("-2,2_5,03", -2.222m, Decimal.Round (-2.2225m, 3));
+			AssertEquals ("-2,2_5,04", -2.2222m, Decimal.Round (-2.22225m, 4));
+			AssertEquals ("-2,2_5,05", -2.22222m, Decimal.Round (-2.222225m, 5));
+			AssertEquals ("-2,2_5,06", -2.222222m, Decimal.Round (-2.2222225m, 6));
+			AssertEquals ("-2,2_5,07", -2.2222222m, Decimal.Round (-2.22222225m, 7));
+			AssertEquals ("-2,2_5,08", -2.22222222m, Decimal.Round (-2.222222225m, 8));
+			AssertEquals ("-2,2_5,09", -2.222222222m, Decimal.Round (-2.2222222225m, 9));
+			AssertEquals ("-2,2_5,10", -2.2222222222m, Decimal.Round (-2.22222222225m, 10));
+			AssertEquals ("-2,2_5,11", -2.22222222222m, Decimal.Round (-2.222222222225m, 11));
+			AssertEquals ("-2,2_5,12", -2.222222222222m, Decimal.Round (-2.2222222222225m, 12));
+			AssertEquals ("-2,2_5,13", -2.2222222222222m, Decimal.Round (-2.22222222222225m, 13));
+			AssertEquals ("-2,2_5,14", -2.22222222222222m, Decimal.Round (-2.222222222222225m, 14));
+			AssertEquals ("-2,2_5,15", -2.222222222222222m, Decimal.Round (-2.2222222222222225m, 15));
+			AssertEquals ("-2,2_5,16", -2.2222222222222222m, Decimal.Round (-2.22222222222222225m, 16));
+			AssertEquals ("-2,2_5,17", -2.22222222222222222m, Decimal.Round (-2.222222222222222225m, 17));
+			AssertEquals ("-2,2_5,18", -2.222222222222222222m, Decimal.Round (-2.2222222222222222225m, 18));
+			AssertEquals ("-2,2_5,19", -2.2222222222222222222m, Decimal.Round (-2.22222222222222222225m, 19));
+			AssertEquals ("-2,2_5,20", -2.22222222222222222222m, Decimal.Round (-2.222222222222222222225m, 20));
+			AssertEquals ("-2,2_5,21", -2.222222222222222222222m, Decimal.Round (-2.2222222222222222222225m, 21));
+			AssertEquals ("-2,2_5,22", -2.2222222222222222222222m, Decimal.Round (-2.22222222222222222222225m, 22));
+			AssertEquals ("-2,2_5,23", -2.22222222222222222222222m, Decimal.Round (-2.222222222222222222222225m, 23));
+			AssertEquals ("-2,2_5,24", -2.222222222222222222222222m, Decimal.Round (-2.2222222222222222222222225m, 24));
+			AssertEquals ("-2,2_5,25", -2.2222222222222222222222222m, Decimal.Round (-2.22222222222222222222222225m, 25));
+			AssertEquals ("-2,2_5,26", -2.22222222222222222222222222m, Decimal.Round (-2.222222222222222222222222225m, 26));
+			AssertEquals ("-2,2_5,27", -2.222222222222222222222222222m, Decimal.Round (-2.2222222222222222222222222225m, 27));
+			AssertEquals ("-2,2_5,28", -2.2222222222222222222222222222m, Decimal.Round (-2.22222222222222222222222222225m, 28));
 		}
 
-		value = "-5";
-		AssertEquals (value, value, Decimal.Parse (value).ToString ());
-		value += '.';
-		for (int i=0; i < 28; i++) {
-			value += "0";
-			AssertEquals ("-" + i.ToString(), value, Decimal.Parse (value).ToString ());
+		[Test] // bug #59425
+		public void ParseAndKeepPrecision ()
+		{
+			string value = "5";
+			AssertEquals (value, value, Decimal.Parse (value).ToString ());
+			value += '.';
+			for (int i = 0; i < 28; i++) {
+				value += "0";
+				AssertEquals (i.ToString (), value, Decimal.Parse (value).ToString ());
+			}
+
+			value = "-5";
+			AssertEquals (value, value, Decimal.Parse (value).ToString ());
+			value += '.';
+			for (int i = 0; i < 28; i++) {
+				value += "0";
+				AssertEquals ("-" + i.ToString (), value, Decimal.Parse (value).ToString ());
+			}
 		}
-	}
 
-	[Test]
-	public void ToString_G () 
-	{
-		AssertEquals ("00", "1.0", (1.0m).ToString ());
-		AssertEquals ("01", "0.1", (0.1m).ToString ());
-		AssertEquals ("02", "0.01", (0.01m).ToString ());
-		AssertEquals ("03", "0.001", (0.001m).ToString ());
-		AssertEquals ("04", "0.0001", (0.0001m).ToString ());
-		AssertEquals ("05", "0.00001", (0.00001m).ToString ());
-		AssertEquals ("06", "0.000001", (0.000001m).ToString ());
-		AssertEquals ("07", "0.0000001", (0.0000001m).ToString ());
-		AssertEquals ("08", "0.00000001", (0.00000001m).ToString ());
-		AssertEquals ("09", "0.000000001", (0.000000001m).ToString ());
-		AssertEquals ("10", "0.0000000001", (0.0000000001m).ToString ());
-		AssertEquals ("11", "0.00000000001", (0.00000000001m).ToString ());
-		AssertEquals ("12", "0.000000000001", (0.000000000001m).ToString ());
-		AssertEquals ("13", "0.0000000000001", (0.0000000000001m).ToString ());
-		AssertEquals ("14", "0.00000000000001", (0.00000000000001m).ToString ());
-		AssertEquals ("15", "0.000000000000001", (0.000000000000001m).ToString ());
-		AssertEquals ("16", "0.0000000000000001", (0.0000000000000001m).ToString ());
-		AssertEquals ("17", "0.00000000000000001", (0.00000000000000001m).ToString ());
-		AssertEquals ("18", "0.000000000000000001", (0.000000000000000001m).ToString ());
-		AssertEquals ("19", "0.0000000000000000001", (0.0000000000000000001m).ToString ());
-		AssertEquals ("20", "0.00000000000000000001", (0.00000000000000000001m).ToString ());
-		AssertEquals ("21", "0.000000000000000000001", (0.000000000000000000001m).ToString ());
-		AssertEquals ("22", "0.0000000000000000000001", (0.0000000000000000000001m).ToString ());
-		AssertEquals ("23", "0.00000000000000000000001", (0.00000000000000000000001m).ToString ());
-		AssertEquals ("24", "0.000000000000000000000001", (0.000000000000000000000001m).ToString ());
-		AssertEquals ("25", "0.0000000000000000000000001", (0.0000000000000000000000001m).ToString ());
-		AssertEquals ("26", "0.00000000000000000000000001", (0.00000000000000000000000001m).ToString ());
-		AssertEquals ("27", "0.000000000000000000000000001", (0.000000000000000000000000001m).ToString ());
-		AssertEquals ("28", "0.0000000000000000000000000001", (0.0000000000000000000000000001m).ToString ());
+		[Test]
+		public void ToString_G ()
+		{
+			AssertEquals ("00", "1.0", (1.0m).ToString ());
+			AssertEquals ("01", "0.1", (0.1m).ToString ());
+			AssertEquals ("02", "0.01", (0.01m).ToString ());
+			AssertEquals ("03", "0.001", (0.001m).ToString ());
+			AssertEquals ("04", "0.0001", (0.0001m).ToString ());
+			AssertEquals ("05", "0.00001", (0.00001m).ToString ());
+			AssertEquals ("06", "0.000001", (0.000001m).ToString ());
+			AssertEquals ("07", "0.0000001", (0.0000001m).ToString ());
+			AssertEquals ("08", "0.00000001", (0.00000001m).ToString ());
+			AssertEquals ("09", "0.000000001", (0.000000001m).ToString ());
+			AssertEquals ("10", "0.0000000001", (0.0000000001m).ToString ());
+			AssertEquals ("11", "0.00000000001", (0.00000000001m).ToString ());
+			AssertEquals ("12", "0.000000000001", (0.000000000001m).ToString ());
+			AssertEquals ("13", "0.0000000000001", (0.0000000000001m).ToString ());
+			AssertEquals ("14", "0.00000000000001", (0.00000000000001m).ToString ());
+			AssertEquals ("15", "0.000000000000001", (0.000000000000001m).ToString ());
+			AssertEquals ("16", "0.0000000000000001", (0.0000000000000001m).ToString ());
+			AssertEquals ("17", "0.00000000000000001", (0.00000000000000001m).ToString ());
+			AssertEquals ("18", "0.000000000000000001", (0.000000000000000001m).ToString ());
+			AssertEquals ("19", "0.0000000000000000001", (0.0000000000000000001m).ToString ());
+			AssertEquals ("20", "0.00000000000000000001", (0.00000000000000000001m).ToString ());
+			AssertEquals ("21", "0.000000000000000000001", (0.000000000000000000001m).ToString ());
+			AssertEquals ("22", "0.0000000000000000000001", (0.0000000000000000000001m).ToString ());
+			AssertEquals ("23", "0.00000000000000000000001", (0.00000000000000000000001m).ToString ());
+			AssertEquals ("24", "0.000000000000000000000001", (0.000000000000000000000001m).ToString ());
+			AssertEquals ("25", "0.0000000000000000000000001", (0.0000000000000000000000001m).ToString ());
+			AssertEquals ("26", "0.00000000000000000000000001", (0.00000000000000000000000001m).ToString ());
+			AssertEquals ("27", "0.000000000000000000000000001", (0.000000000000000000000000001m).ToString ());
+			AssertEquals ("28", "0.0000000000000000000000000001", (0.0000000000000000000000000001m).ToString ());
+		}
 	}
-    }
 }

+ 17 - 2
mcs/class/corlib/Test/System/DoubleFormatterTest.cs

@@ -10,11 +10,26 @@ using System;
 using System.Threading;
 using System.Globalization;
 
-namespace MonoTests.System {
-	
+namespace MonoTests.System 
+{
 	[TestFixture]
 	public class DoubleFormatterTest : Assertion
 	{
+		CultureInfo old_culture;
+
+		[SetUp]
+		public void SetUp ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
 		[Test]
 		[ExpectedException(typeof(FormatException))]
 		public void TestToDecimal()

+ 19 - 2
mcs/class/corlib/Test/System/FloatingPointFormatterTest.cs

@@ -8,16 +8,33 @@
 // (C) 2004 Novell Inc.
 // 
 
-using NUnit.Framework;
 using System;
 using System.Globalization;
 using System.IO;
+using System.Threading;
+
+using NUnit.Framework;
 
 namespace MonoTests.System
 {
 	[TestFixture]
 	public class FloatingPointFormatterTest : Assertion
 	{
+		CultureInfo old_culture;
+
+		[SetUp]
+		public void SetUp ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
 		[Test]
 		public void Format1 ()
 		{
@@ -68,5 +85,5 @@ namespace MonoTests.System
 			AssertEquals ("#2", "235 hoge", 234.56.ToString ("### 'hoge'", ci));
 			AssertEquals ("#3", "234 hoge.56", 234.56.ToString ("### 'hoge'.###", ci));
 		}
-        }
+	}
 }

File diff suppressed because it is too large
+ 230 - 111
mcs/class/corlib/Test/System/NumberFormatterTest.cs


+ 13 - 7
mcs/class/corlib/Test/System/SingleFormatterTest.cs

@@ -11,28 +11,34 @@ using System;
 using System.Threading;
 using System.Globalization;
 
-namespace MonoTests.System {
-	
+namespace MonoTests.System
+{
 	[TestFixture]
 	public class SingleFormatterTest 
 	{
+		CultureInfo old_culture;
+
 		[SetUp]
-		public void GetReady() 
+		public void SetUp ()
 		{
-			CultureInfo EnUs = new CultureInfo ("en-us", false);
+			old_culture = Thread.CurrentThread.CurrentCulture;
+
+			CultureInfo EnUs = new CultureInfo ("en-US", false);
 			EnUs.NumberFormat.CurrencyNegativePattern = 0; // -1 = (1)
 			EnUs.NumberFormat.CurrencyDecimalSeparator = ".";
 			EnUs.NumberFormat.NumberGroupSeparator = ",";
 			EnUs.NumberFormat.NumberNegativePattern = 1; // -1 = -1
 			EnUs.NumberFormat.NumberDecimalDigits = 2;
 			
-			
 			//Set this culture for the current thread.
 			Thread.CurrentThread.CurrentCulture = EnUs;
 		}
 		
 		[TearDown]
-		public void Clean() {}
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
 		
 		[Test]
 		[ExpectedException(typeof(FormatException))]
@@ -60,7 +66,7 @@ namespace MonoTests.System {
 		
 		private void FormatStringTest(int TestNumber, float Number, string Format, string ExpectedResult)
 		{
-			Assertion.AssertEquals ("SngF #" + TestNumber, ExpectedResult, Number.ToString(Format));                                
+			Assertion.AssertEquals ("SngF #" + TestNumber, ExpectedResult, Number.ToString(Format));
 		}
 		
 		string GetPercent (string s)

+ 28 - 13
mcs/class/corlib/Test/System/SingleTest.cs

@@ -11,15 +11,32 @@
 
 using System;
 using System.Globalization;
-using NUnit.Framework;
+using System.Threading;
 
-namespace MonoTests.System  {
+using NUnit.Framework;
 
+namespace MonoTests.System
+{
 	[TestFixture]
-	public class SingleTest : Assertion {
+	public class SingleTest : Assertion
+	{
+		CultureInfo old_culture;
+
+		[SetUp]
+		public void SetUp ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US", false);
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
 
 		[Test]
-		public void Equals () 
+		public void Equals ()
 		{
 			Single s1 = 1f;
 			Single s2 = 1f;
@@ -40,8 +57,8 @@ namespace MonoTests.System  {
 		{
 			Assert ("PositiveInfinity",  Single.IsInfinity (Single.PositiveInfinity));
 			Assert ("NegativeInfinity", Single.IsInfinity (Single.NegativeInfinity));
-			Assert ("12", !Single.IsInfinity(12));		
-			Assert ("NaN", !Single.IsInfinity (Single.NaN));		
+			Assert ("12", !Single.IsInfinity(12));
+			Assert ("NaN", !Single.IsInfinity (Single.NaN));
 		}
 
 		[Test]
@@ -57,16 +74,16 @@ namespace MonoTests.System  {
 		public void IsNegativeInfinity ()
 		{
 			Assert ("IsNegativeInfinity", Single.IsNegativeInfinity (Single.NegativeInfinity));
-			Assert ("12", !Single.IsNegativeInfinity (12));		
-			Assert ("NaN", !Single.IsNegativeInfinity (Single.NaN));		
+			Assert ("12", !Single.IsNegativeInfinity (12));
+			Assert ("NaN", !Single.IsNegativeInfinity (Single.NaN));
 		}
 
 		[Test]
 		public void IsPositiveInfinity ()
 		{
 			Assert ("PositiveInfinity", Single.IsPositiveInfinity (Single.PositiveInfinity));
-			Assert ("12", !Single.IsPositiveInfinity (12));		
-			Assert ("NaN", !Single.IsPositiveInfinity (Single.NaN));		
+			Assert ("12", !Single.IsPositiveInfinity (12));
+			Assert ("NaN", !Single.IsPositiveInfinity (Single.NaN));
 		}
 
 		[Test]
@@ -81,16 +98,14 @@ namespace MonoTests.System  {
 			AssertEquals ("ToString(empty)", def, i.ToString (String.Empty));
 			AssertEquals ("ToString(null,null)", def, i.ToString (null, null));
 			AssertEquals ("ToString(empty,null)", def, i.ToString (String.Empty, null));
-
 			AssertEquals ("ToString(G)", "254.9", def);
 		}
 
 #if NET_2_0
-		[Test]
+		[Test] // bug #72221
 		[ExpectedException (typeof (ArgumentException))]
 		public void HexNumber_WithHexToParse ()
 		{
-			// from bug #72221
 			float f;
 			Single.TryParse ("0dead", NumberStyles.HexNumber, null, out f);
 		}

+ 14 - 0
mcs/class/corlib/Test/System/StringComparerTest.cs

@@ -41,6 +41,20 @@ namespace MonoTests.System
 	[TestFixture]
 	public class StringComparerTest
 	{
+		private CultureInfo old_culture;
+
+		[SetUp]
+		public void SetUp ()
+		{
+			old_culture = Thread.CurrentThread.CurrentCulture;
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			Thread.CurrentThread.CurrentCulture = old_culture;
+		}
+
 		[Test]
 		public void Serialize_CurrentCulture ()
 		{

Some files were not shown because too many files changed in this diff