Skip to content

Commit 907279b

Browse files
Exercise StringBuilder paths that actually reach TryFormat
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
1 parent 44b194b commit 907279b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎PreciseNumber.Test/PreciseNumberTests.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,8 +2588,9 @@ public void TestTryFormatReturnsFalseWhenOnlyTheDestinationIsTooSmall()
25882588
[TestMethod]
25892589
public async Task TestInterpolationAndAppendAtExtremeExponentsFailPromptly()
25902590
{
2591-
// These callers grow their buffer and retry whenever TryFormat returns false, so they
2592-
// only stop if it throws. Each runs on its own task so a regression fails the test
2591+
// Most of these callers grow their buffer and retry whenever TryFormat returns false, so
2592+
// they only stop if it throws. Append(object) goes through ToString instead, and is here
2593+
// to show both paths agree. Each runs on its own task so a regression fails the test
25932594
// rather than hanging it.
25942595
foreach (string text in new[] { "1e-2147483648", "1e2147483647" })
25952596
{
@@ -2598,6 +2599,8 @@ public async Task TestInterpolationAndAppendAtExtremeExponentsFailPromptly()
25982599
[
25992600
() => $"{number}",
26002601
() => new System.Text.StringBuilder().Append(number).ToString(),
2602+
() => new System.Text.StringBuilder().Append($"{number}").ToString(),
2603+
() => new System.Text.StringBuilder().AppendFormat(CultureInfo.InvariantCulture, "{0}", number).ToString(),
26012604
() => string.Format(CultureInfo.InvariantCulture, "{0}", number),
26022605
];
26032606

0 commit comments

Comments
 (0)