Skip to content

Commit ad5a46a

Browse files
Updated tests regarding issue dotnet#48119 (dotnet#52994)
* added tests for parsing decimal/double/half/single with . at different positions * adjusted string length for testing . at or after max digit count for single/half * Fix test cases with decimal separators to work in localized runs Co-authored-by: Jeff Handley <jeff.handley@microsoft.com>
1 parent 16e1d9b commit ad5a46a

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/libraries/System.Runtime/tests/System/DecimalTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,11 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
791791
yield return new object[] { (-567.89m).ToString(), defaultStyle, null, -567.89m };
792792
yield return new object[] { "0.6666666666666666666666666666500000000000000000000000000000000000000000000000000000000000000", defaultStyle, invariantFormat, 0.6666666666666666666666666666m };
793793

794+
yield return new object[] { emptyFormat.NumberDecimalSeparator + "234", defaultStyle, null, 0.234m };
795+
yield return new object[] { "234" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 234.0m };
796+
yield return new object[] { "7" + new string('0', 28) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 7E28m };
797+
yield return new object[] { "07" + new string('0', 28) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 7E28m };
798+
794799
yield return new object[] { "79228162514264337593543950335", defaultStyle, null, 79228162514264337593543950335m };
795800
yield return new object[] { "-79228162514264337593543950335", defaultStyle, null, -79228162514264337593543950335m };
796801
yield return new object[] { "79,228,162,514,264,337,593,543,950,335", NumberStyles.AllowThousands, customFormat3, 79228162514264337593543950335m };

src/libraries/System.Runtime/tests/System/DoubleTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
284284
yield return new object[] { "5.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005", defaultStyle, invariantFormat, 5.0 };
285285
yield return new object[] { "5.0050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", defaultStyle, invariantFormat, 5.005 };
286286

287+
yield return new object[] { emptyFormat.NumberDecimalSeparator + "234", defaultStyle, null, 0.234 };
288+
yield return new object[] { "234" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 234.0 };
289+
yield return new object[] { new string('0', 458) + "1" + new string('0', 308) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 1E308 };
290+
yield return new object[] { new string('0', 459) + "1" + new string('0', 308) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 1E308 };
291+
287292
yield return new object[] { "5005.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", defaultStyle, invariantFormat, 5005.0 };
288293
yield return new object[] { "50050.0", defaultStyle, invariantFormat, 50050.0 };
289294
yield return new object[] { "5005", defaultStyle, invariantFormat, 5005.0 };

src/libraries/System.Runtime/tests/System/HalfTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
663663
yield return new object[] { (-567.89f).ToString(), defaultStyle, null, -567.89f };
664664
yield return new object[] { "1E23", defaultStyle, null, 1E23f };
665665

666+
yield return new object[] { emptyFormat.NumberDecimalSeparator + "234", defaultStyle, null, 0.234f };
667+
yield return new object[] { "234" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 234.0f };
668+
yield return new object[] { new string('0', 13) + "65504" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 65504f };
669+
yield return new object[] { new string('0', 14) + "65504" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 65504f };
670+
666671
// 2^11 + 1. Not exactly representable
667672
yield return new object[] { "2049.0", defaultStyle, invariantFormat, 2048.0f };
668673
yield return new object[] { "2049.000000000000001", defaultStyle, invariantFormat, 2050.0f };

src/libraries/System.Runtime/tests/System/SingleTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ public static IEnumerable<object[]> Parse_Valid_TestData()
273273
yield return new object[] { (-567.89f).ToString(), defaultStyle, null, -567.89f };
274274
yield return new object[] { "1E23", defaultStyle, null, 1E23f };
275275

276+
yield return new object[] { emptyFormat.NumberDecimalSeparator + "234", defaultStyle, null, 0.234f };
277+
yield return new object[] { "234" + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 234.0f };
278+
yield return new object[] { new string('0', 72) + "3" + new string('0', 38) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 3E38f };
279+
yield return new object[] { new string('0', 73) + "3" + new string('0', 38) + emptyFormat.NumberDecimalSeparator, defaultStyle, null, 3E38f };
280+
276281
// 2^24 + 1. Not exactly representable
277282
yield return new object[] { "16777217.0", defaultStyle, invariantFormat, 16777216.0f };
278283
yield return new object[] { "16777217.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", defaultStyle, invariantFormat, 16777218.0f };

0 commit comments

Comments
 (0)