From: Andrew Au Date: Wed, 15 Apr 2020 16:00:28 +0000 (-0700) Subject: Fix Span length in TryFormatUInt64Slow (#34840) X-Git-Tag: submit/tizen/20210909.063632~8561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbc65f5fa3ac9593c3f93b0901187be0da850d89;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix Span length in TryFormatUInt64Slow (#34840) * Make the Span length right * Adding a regression test for the span problem * Avoid dependency on machine locale * Using customFormat --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs b/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs index 74fe7c0..9cba193 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs @@ -1069,7 +1069,7 @@ namespace System NumberFormatInfo info = NumberFormatInfo.GetInstance(provider); byte* pDigits = stackalloc byte[UInt64NumberBufferLength]; - NumberBuffer number = new NumberBuffer(NumberBufferKind.Integer, pDigits, UInt32NumberBufferLength); + NumberBuffer number = new NumberBuffer(NumberBufferKind.Integer, pDigits, UInt64NumberBufferLength); UInt64ToNumber(value, ref number); diff --git a/src/libraries/System.Runtime/tests/System/UInt64Tests.cs b/src/libraries/System.Runtime/tests/System/UInt64Tests.cs index fac4535..0cb48df 100644 --- a/src/libraries/System.Runtime/tests/System/UInt64Tests.cs +++ b/src/libraries/System.Runtime/tests/System/UInt64Tests.cs @@ -120,6 +120,7 @@ namespace System.Tests yield return new object[] { (ulong)123, "E", customFormat, "1~230000E&002" }; yield return new object[] { (ulong)123, "F", customFormat, "123~00" }; yield return new object[] { (ulong)123, "P", customFormat, "12,300.00000 @" }; + yield return new object[] { ulong.MaxValue, "n5", customFormat, "18*446*744*073*709*551*615~00000" }; } [Theory]