@@ -257,6 +257,37 @@ public void Ctor_LargeScale_ThrowsArgumentOutOfRangeException()
257257 AssertExtensions . Throws < ArgumentOutOfRangeException > ( "scale" , ( ) => new Decimal ( 1 , 2 , 3 , false , 29 ) ) ;
258258 }
259259
260+ public static IEnumerable < object [ ] > Scale_TestData ( )
261+ {
262+ yield return new object [ ] { 10m , 0 } ;
263+ yield return new object [ ] { 1m , 0 } ;
264+ yield return new object [ ] { - 1m , 0 } ;
265+ yield return new object [ ] { 1.0m , 1 } ;
266+ yield return new object [ ] { - 1.0m , 1 } ;
267+ yield return new object [ ] { 1.1m , 1 } ;
268+ yield return new object [ ] { 1.00m , 2 } ;
269+ yield return new object [ ] { 1.01m , 2 } ;
270+ yield return new object [ ] { 1.0000000000000000000000000000m , 28 } ;
271+ }
272+
273+ [ Theory ]
274+ [ MemberData ( nameof ( Scale_TestData ) ) ]
275+ public static void Scale ( decimal value , byte expectedScale )
276+ {
277+ Assert . Equal ( expectedScale , value . Scale ) ;
278+ }
279+
280+ [ Theory ]
281+ [ InlineData ( new int [ ] { 1 , 0 , 0 , 0 } , 0 ) ] // 1
282+ [ InlineData ( new int [ ] { 10 , 0 , 0 , 65536 } , 1 ) ] // 1.0
283+ [ InlineData ( new int [ ] { 100 , 0 , 0 , 131072 } , 2 ) ] // 1.00
284+ [ InlineData ( new int [ ] { 268435456 , 1042612833 , 542101086 , 1835008 } , 28 ) ] // 1.0000000000000000000000000000
285+ [ InlineData ( new int [ ] { 10 , 0 , 0 , - 2147418112 } , 1 ) ] // -1.0
286+ public static void ScaleFromBits ( int [ ] bits , byte expectedScale )
287+ {
288+ Assert . Equal ( expectedScale , new decimal ( bits ) . Scale ) ;
289+ }
290+
260291 public static IEnumerable < object [ ] > Add_Valid_TestData ( )
261292 {
262293 yield return new object [ ] { 1m , 1m , 2m } ;
@@ -968,7 +999,7 @@ public static void Parse_Span_Invalid(string value, NumberStyles style, IFormatP
968999 Assert . Equal ( 0 , result ) ;
9691000 }
9701001 }
971-
1002+
9721003 public static IEnumerable < object [ ] > Remainder_Valid_TestData ( )
9731004 {
9741005 decimal NegativeZero = new decimal ( 0 , 0 , 0 , true , 0 ) ;
0 commit comments