New test.
[mono.git] / mcs / class / corlib / Test / System / SingleFormatterTest.cs
index 46f7cd3fc0b40cfaa5787b8ffa3b8a24385a9fab..66a064d783ffe96415d847526f76666a8cd1e141 100644 (file)
@@ -19,11 +19,13 @@ namespace MonoTests.System {
                [SetUp]
                public void GetReady() 
                {
-                       CultureInfo EnUs = new CultureInfo ("en-us");
+                       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;
@@ -61,6 +63,15 @@ namespace MonoTests.System {
                        Assertion.AssertEquals ("SngF #" + TestNumber, ExpectedResult, Number.ToString(Format));                                
                }
                
+               string GetPercent (string s)
+               {
+                       switch (NumberFormatInfo.CurrentInfo.PercentPositivePattern) {
+                               case 0: return s + " %";
+                               case 1: return s + "%";
+                               default: return "%" + s;
+                       }
+               }
+               
                [Test]
                public void TestFormatStrings()
                {
@@ -124,18 +135,18 @@ namespace MonoTests.System {
                         FormatStringTest (57, 121212F, "N8", "121,212.00000000");  
                         FormatStringTest (58, 121212F, "N9", "121,212.000000000");  
                         FormatStringTest (59, 121212F, "N67", "121,212.0000000000000000000000000000000000000000000000000000000000000000000");  
-                        FormatStringTest (60, 121212F, "P", "12,121,200.00 %");  
-                        FormatStringTest (61, 121212F, "P0", "12,121,200 %");  
-                        FormatStringTest (62, 121212F, "P1", "12,121,200.0 %");  
-                        FormatStringTest (63, 121212F, "P2", "12,121,200.00 %");  
-                        FormatStringTest (64, 121212F, "P3", "12,121,200.000 %");  
-                        FormatStringTest (65, 121212F, "P4", "12,121,200.0000 %");  
-                        FormatStringTest (66, 121212F, "P5", "12,121,200.00000 %");  
-                        FormatStringTest (67, 121212F, "P6", "12,121,200.000000 %");  
-                        FormatStringTest (68, 121212F, "P7", "12,121,200.0000000 %");  
-                        FormatStringTest (69, 121212F, "P8", "12,121,200.00000000 %");  
-                        FormatStringTest (70, 121212F, "P9", "12,121,200.000000000 %");  
-                        FormatStringTest (71, 121212F, "P67", "12,121,200.0000000000000000000000000000000000000000000000000000000000000000000 %");  
+                        FormatStringTest (60, 121212F, "P", GetPercent ("12,121,200.00"));  
+                        FormatStringTest (61, 121212F, "P0", GetPercent ("12,121,200"));
+                        FormatStringTest (62, 121212F, "P1", GetPercent ("12,121,200.0"));  
+                        FormatStringTest (63, 121212F, "P2", GetPercent ("12,121,200.00"));  
+                        FormatStringTest (64, 121212F, "P3", GetPercent ("12,121,200.000"));  
+                        FormatStringTest (65, 121212F, "P4", GetPercent ("12,121,200.0000"));  
+                        FormatStringTest (66, 121212F, "P5", GetPercent ("12,121,200.00000"));  
+                        FormatStringTest (67, 121212F, "P6", GetPercent ("12,121,200.000000"));  
+                        FormatStringTest (68, 121212F, "P7", GetPercent ("12,121,200.0000000"));  
+                        FormatStringTest (69, 121212F, "P8", GetPercent ("12,121,200.00000000"));  
+                        FormatStringTest (70, 121212F, "P9", GetPercent ("12,121,200.000000000"));  
+                        FormatStringTest (71, 121212F, "P67", GetPercent ("12,121,200.0000000000000000000000000000000000000000000000000000000000000000000"));  
                         FormatStringTest (72, 3.402823E+38F, "C", "$340,282,300,000,000,000,000,000,000,000,000,000,000.00");  
                         FormatStringTest (73, 3.402823E+38F, "C0", "$340,282,300,000,000,000,000,000,000,000,000,000,000");  
                         FormatStringTest (74, 3.402823E+38F, "C1", "$340,282,300,000,000,000,000,000,000,000,000,000,000.0");  
@@ -196,18 +207,18 @@ namespace MonoTests.System {
                         FormatStringTest (129, 3.402823E+38F, "N8", "340,282,300,000,000,000,000,000,000,000,000,000,000.00000000");  
                         FormatStringTest (130, 3.402823E+38F, "N9", "340,282,300,000,000,000,000,000,000,000,000,000,000.000000000");  
                         FormatStringTest (131, 3.402823E+38F, "N67", "340,282,300,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000");  
-                        FormatStringTest (132, 3.402823E+38F, "P", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.00 %");  
-                        FormatStringTest (133, 3.402823E+38F, "P0", "34,028,230,000,000,000,000,000,000,000,000,000,000,000 %");  
-                        FormatStringTest (134, 3.402823E+38F, "P1", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.0 %");  
-                        FormatStringTest (135, 3.402823E+38F, "P2", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.00 %");  
-                        FormatStringTest (136, 3.402823E+38F, "P3", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.000 %");  
-                        FormatStringTest (137, 3.402823E+38F, "P4", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000 %");  
-                        FormatStringTest (138, 3.402823E+38F, "P5", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000 %");  
-                        FormatStringTest (139, 3.402823E+38F, "P6", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000 %");  
-                        FormatStringTest (140, 3.402823E+38F, "P7", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000 %");  
-                        FormatStringTest (141, 3.402823E+38F, "P8", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000000 %");  
-                        FormatStringTest (142, 3.402823E+38F, "P9", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000000 %");  
-                        FormatStringTest (143, 3.402823E+38F, "P67", "34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000 %");  
+                        FormatStringTest (132, 3.402823E+38F, "P", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.00"));  
+                        FormatStringTest (133, 3.402823E+38F, "P0", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000"));  
+                        FormatStringTest (134, 3.402823E+38F, "P1", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.0"));  
+                        FormatStringTest (135, 3.402823E+38F, "P2", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.00"));  
+                        FormatStringTest (136, 3.402823E+38F, "P3", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.000"));  
+                        FormatStringTest (137, 3.402823E+38F, "P4", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000"));  
+                        FormatStringTest (138, 3.402823E+38F, "P5", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000"));  
+                        FormatStringTest (139, 3.402823E+38F, "P6", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000"));  
+                        FormatStringTest (140, 3.402823E+38F, "P7", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000"));  
+                        FormatStringTest (141, 3.402823E+38F, "P8", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000000"));  
+                        FormatStringTest (142, 3.402823E+38F, "P9", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000000"));  
+                        FormatStringTest (143, 3.402823E+38F, "P67", GetPercent ("34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000"));
                         FormatStringTest (144, -3.402823E+38F, "C", "($340,282,300,000,000,000,000,000,000,000,000,000,000.00)");  
                         FormatStringTest (145, -3.402823E+38F, "C0", "($340,282,300,000,000,000,000,000,000,000,000,000,000)");  
                         FormatStringTest (146, -3.402823E+38F, "C1", "($340,282,300,000,000,000,000,000,000,000,000,000,000.0)");  
@@ -268,18 +279,18 @@ namespace MonoTests.System {
                         FormatStringTest (201, -3.402823E+38F, "N8", "-340,282,300,000,000,000,000,000,000,000,000,000,000.00000000");  
                         FormatStringTest (202, -3.402823E+38F, "N9", "-340,282,300,000,000,000,000,000,000,000,000,000,000.000000000");  
                         FormatStringTest (203, -3.402823E+38F, "N67", "-340,282,300,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000");  
-                        FormatStringTest (204, -3.402823E+38F, "P", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00 %");  
-                        FormatStringTest (205, -3.402823E+38F, "P0", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000 %");  
-                        FormatStringTest (206, -3.402823E+38F, "P1", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0 %");  
-                        FormatStringTest (207, -3.402823E+38F, "P2", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00 %");  
-                        FormatStringTest (208, -3.402823E+38F, "P3", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000 %");  
-                        FormatStringTest (209, -3.402823E+38F, "P4", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000 %");  
-                        FormatStringTest (210, -3.402823E+38F, "P5", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000 %");  
-                        FormatStringTest (211, -3.402823E+38F, "P6", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000 %");  
-                        FormatStringTest (212, -3.402823E+38F, "P7", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000 %");  
-                        FormatStringTest (213, -3.402823E+38F, "P8", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000000 %");  
-                        FormatStringTest (214, -3.402823E+38F, "P9", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000000 %");  
-                        FormatStringTest (215, -3.402823E+38F, "P67", "-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000 %");  
+                        FormatStringTest (204, -3.402823E+38F, "P", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00"));  
+                        FormatStringTest (205, -3.402823E+38F, "P0", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000"));  
+                        FormatStringTest (206, -3.402823E+38F, "P1", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0"));  
+                        FormatStringTest (207, -3.402823E+38F, "P2", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00"));  
+                        FormatStringTest (208, -3.402823E+38F, "P3", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000"));  
+                        FormatStringTest (209, -3.402823E+38F, "P4", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000"));  
+                        FormatStringTest (210, -3.402823E+38F, "P5", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000"));  
+                        FormatStringTest (211, -3.402823E+38F, "P6", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000"));  
+                        FormatStringTest (212, -3.402823E+38F, "P7", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000"));  
+                        FormatStringTest (213, -3.402823E+38F, "P8", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.00000000"));  
+                        FormatStringTest (214, -3.402823E+38F, "P9", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.000000000"));  
+                        FormatStringTest (215, -3.402823E+38F, "P67", GetPercent ("-34,028,230,000,000,000,000,000,000,000,000,000,000,000.0000000000000000000000000000000000000000000000000000000000000000000"));  
                         FormatStringTest (216, 1E-10F, "C", "$0.00");  
                         FormatStringTest (217, 1E-10F, "C0", "$0");  
                         FormatStringTest (218, 1E-10F, "C1", "$0.0");  
@@ -340,18 +351,18 @@ namespace MonoTests.System {
                         FormatStringTest (273, 1E-10F, "N8", "0.00000000");  
                         FormatStringTest (274, 1E-10F, "N9", "0.000000000");  
                         FormatStringTest (275, 1E-10F, "N67", "0.0000000001000000000000000000000000000000000000000000000000000000000");  
-                        FormatStringTest (276, 1E-10F, "P", "0.00 %");  
-                        FormatStringTest (277, 1E-10F, "P0", "0 %");  
-                        FormatStringTest (278, 1E-10F, "P1", "0.0 %");  
-                        FormatStringTest (279, 1E-10F, "P2", "0.00 %");  
-                        FormatStringTest (280, 1E-10F, "P3", "0.000 %");  
-                        FormatStringTest (281, 1E-10F, "P4", "0.0000 %");  
-                        FormatStringTest (282, 1E-10F, "P5", "0.00000 %");  
-                        FormatStringTest (283, 1E-10F, "P6", "0.000000 %");  
-                        FormatStringTest (284, 1E-10F, "P7", "0.0000000 %");  
-                        FormatStringTest (285, 1E-10F, "P8", "0.00000001 %");  
-                        FormatStringTest (286, 1E-10F, "P9", "0.000000010 %");  
-                        FormatStringTest (287, 1E-10F, "P67", "0.0000000100000000000000000000000000000000000000000000000000000000000 %");  
+                        FormatStringTest (276, 1E-10F, "P", GetPercent ("0.00"));  
+                        FormatStringTest (277, 1E-10F, "P0", GetPercent ("0"));  
+                        FormatStringTest (278, 1E-10F, "P1", GetPercent ("0.0"));  
+                        FormatStringTest (279, 1E-10F, "P2", GetPercent ("0.00"));  
+                        FormatStringTest (280, 1E-10F, "P3", GetPercent ("0.000"));  
+                        FormatStringTest (281, 1E-10F, "P4", GetPercent ("0.0000"));  
+                        FormatStringTest (282, 1E-10F, "P5", GetPercent ("0.00000"));  
+                        FormatStringTest (283, 1E-10F, "P6", GetPercent ("0.000000"));  
+                        FormatStringTest (284, 1E-10F, "P7", GetPercent ("0.0000000"));  
+                        FormatStringTest (285, 1E-10F, "P8", GetPercent ("0.00000001"));  
+                        FormatStringTest (286, 1E-10F, "P9", GetPercent ("0.000000010"));  
+                        FormatStringTest (287, 1E-10F, "P67", GetPercent ("0.0000000100000000000000000000000000000000000000000000000000000000000"));  
                }
        }
 }