@@ -50,70 +50,50 @@ private enum CustomUnit
5050 // ReSharper restore UnusedMember.Local
5151 }
5252
53- // These cultures all use a comma for the radix point
5453 [ Theory ]
5554 [ InlineData ( "de-DE" ) ]
5655 [ InlineData ( "da-DK" ) ]
5756 [ InlineData ( "es-AR" ) ]
5857 [ InlineData ( "es-ES" ) ]
5958 [ InlineData ( "it-IT" ) ]
60- public void CommaRadixPointCultureFormatting ( string culture )
61- {
62- Assert . Equal ( "0,12 m" , Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
63- }
64-
65- // These cultures all use a decimal point for the radix point
66- [ Theory ]
6759 [ InlineData ( "en-CA" ) ]
6860 [ InlineData ( "en-US" ) ]
6961 [ InlineData ( "ar-EG" ) ]
7062 [ InlineData ( "en-GB" ) ]
7163 [ InlineData ( "es-MX" ) ]
72- public void DecimalRadixPointCultureFormatting ( string culture )
64+ public void RadixPointCultureFormatting ( string cultureName )
7365 {
74- Assert . Equal ( "0.12 m" , Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
66+ CultureInfo culture = GetCulture ( cultureName ) ;
67+ string ds = culture . NumberFormat . NumberDecimalSeparator ;
68+ Assert . Equal ( $ "0{ ds } 12 m", Length . FromMeters ( 0.12 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
7569 }
7670
77- // These cultures all use a comma in digit grouping
7871 [ Theory ]
7972 [ InlineData ( "en-CA" ) ]
73+ [ InlineData ( "en-GB" ) ]
8074 [ InlineData ( "en-US" ) ]
8175 [ InlineData ( "ar-EG" ) ]
82- [ InlineData ( "en-GB" ) ]
8376 [ InlineData ( "es-MX" ) ]
84- public void CommaDigitGroupingCultureFormatting ( string cultureName )
85- {
86- CultureInfo culture = GetCulture ( cultureName ) ;
87- Assert . Equal ( "1,111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
88-
89- // Feet/Inch and Stone/Pound combinations are only used (customarily) in the US, UK and maybe Ireland - all English speaking countries.
90- // FeetInches returns a whole number of feet, with the remainder expressed (rounded) in inches. Same for SonePounds.
91- Assert . Equal ( "2,222 ft 3 in" ,
92- Length . FromFeetInches ( 2222 , 3 ) . FeetInches . ToString ( culture ) ) ;
93- Assert . Equal ( "3,333 st 7 lb" ,
94- Mass . FromStonePounds ( 3333 , 7 ) . StonePounds . ToString ( culture ) ) ;
95- }
96-
97- // These cultures use a thin space in digit grouping
98- [ Theory ]
9977 [ InlineData ( "nn-NO" ) ]
10078 [ InlineData ( "fr-FR" ) ]
101- public void SpaceDigitGroupingCultureFormatting ( string culture )
102- {
103- // Note: the space used in digit groupings is actually a "thin space" Unicode character U+2009
104- Assert . Equal ( "1 111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
105- }
106-
107- // These cultures all use a decimal point in digit grouping
108- [ Theory ]
10979 [ InlineData ( "de-DE" ) ]
11080 [ InlineData ( "da-DK" ) ]
11181 [ InlineData ( "es-AR" ) ]
11282 [ InlineData ( "es-ES" ) ]
11383 [ InlineData ( "it-IT" ) ]
114- public void DecimalPointDigitGroupingCultureFormatting ( string culture )
84+ public void DigitGroupingCultureFormatting ( string cultureName )
11585 {
116- Assert . Equal ( "1.111 m" , Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( GetCulture ( culture ) ) ) ;
86+ CultureInfo culture = GetCulture ( cultureName ) ;
87+ string gs = culture . NumberFormat . NumberGroupSeparator ;
88+
89+ Assert . Equal ( $ "1{ gs } 111 m", Length . FromMeters ( 1111 ) . ToUnit ( LengthUnit . Meter ) . ToString ( culture ) ) ;
90+
91+ // Feet/Inch and Stone/Pound combinations are only used (customarily) in the US, UK and maybe Ireland - all English speaking countries.
92+ // FeetInches returns a whole number of feet, with the remainder expressed (rounded) in inches. Same for StonePounds.
93+ Assert . Equal ( $ "2{ gs } 222 ft 3 in",
94+ Length . FromFeetInches ( 2222 , 3 ) . FeetInches . ToString ( culture ) ) ;
95+ Assert . Equal ( $ "3{ gs } 333 st 7 lb",
96+ Mass . FromStonePounds ( 3333 , 7 ) . StonePounds . ToString ( culture ) ) ;
11797 }
11898
11999 // Due to rounding, the values will result in the same string representation regardless of the number of significant digits (up to a certain point)
0 commit comments