From: Ulrich Weigand Date: Tue, 29 Jun 2021 21:02:03 +0000 (+0200) Subject: Big-endian fix for DoubleTests.cs:ParsePatterns (#54818) X-Git-Tag: submit/tizen/20210909.063632~506 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36e0432547d7d734ef23fce40e8c278ef80c34c8;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Big-endian fix for DoubleTests.cs:ParsePatterns (#54818) The recently added DoubleTests.cs:ParsePatterns test case incorrectly swaps characters of the hexadecimal representation of the floating-point numbers under test on big-endian platforms. --- diff --git a/src/libraries/System.Runtime/tests/System/DoubleTests.cs b/src/libraries/System.Runtime/tests/System/DoubleTests.cs index a80eb05..79bbac4 100644 --- a/src/libraries/System.Runtime/tests/System/DoubleTests.cs +++ b/src/libraries/System.Runtime/tests/System/DoubleTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using Xunit; #pragma warning disable xUnit1025 // reporting duplicate test cases due to not distinguishing 0.0 from -0.0, NaN from -NaN @@ -349,15 +350,12 @@ namespace System.Tests internal static string SplitPairs(string input) { - string[] splitPairs = input.Split('-'); - string ret = ""; - foreach (var pair in splitPairs) + if (!BitConverter.IsLittleEndian) { - string reversedPair = Reverse(pair); - ret += reversedPair; + return input.Replace("-", ""); } - return ret; + return string.Concat(input.Split('-').Select(pair => Reverse(pair))); } internal static string Reverse(string s)