<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<runtimenativeSystemIOPortsVersion>6.0.0-preview.6.21314.1</runtimenativeSystemIOPortsVersion>
<!-- Runtime-Assets dependencies -->
+ <SystemRuntimeNumericsTestDataVersion>6.0.0-beta.21314.1</SystemRuntimeNumericsTestDataVersion>
<SystemComponentModelTypeConverterTestDataVersion>6.0.0-beta.21307.1</SystemComponentModelTypeConverterTestDataVersion>
<SystemDrawingCommonTestDataVersion>6.0.0-beta.21307.1</SystemDrawingCommonTestDataVersion>
<SystemIOCompressionTestDataVersion>6.0.0-beta.21307.1</SystemIOCompressionTestDataVersion>
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn),1718,SYSLIB0013</NoWarn>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="$(MoqVersion)" />
+ <PackageReference Include="System.Runtime.Numerics.TestData" Version="$(SystemRuntimeNumericsTestDataVersion)" GeneratePathProperty="true"/>
<ProjectReference Include="TestLoadAssembly\TestLoadAssembly.csproj" />
<ProjectReference Include="TestCollectibleAssembly\TestCollectibleAssembly.csproj" />
<ProjectReference Include="TestModule\System.Reflection.TestModule.ilproj" />
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using Xunit;
#pragma warning disable xUnit1025 // reporting duplicate test cases due to not distinguishing 0.0 from -0.0, NaN from -NaN
}
}
+ internal static string SplitPairs(string input)
+ {
+ string[] splitPairs = input.Split('-');
+ string ret = "";
+ foreach (var pair in splitPairs)
+ {
+ string reversedPair = Reverse(pair);
+ ret += reversedPair;
+ }
+
+ return ret;
+ }
+
+ internal static string Reverse(string s)
+ {
+ char[] charArray = s.ToCharArray();
+ Array.Reverse(charArray);
+ return new string(charArray);
+ }
+
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))]
+ public static void ParsePatterns()
+ {
+ string path = Directory.GetCurrentDirectory();
+ using (FileStream file = new FileStream(Path.Combine(path, "ibm-fpgen.txt"), FileMode.Open))
+ {
+ using (var streamReader = new StreamReader(file))
+ {
+ string line = streamReader.ReadLine();
+ while (line != null)
+ {
+ string[] data = line.Split(' ');
+ string inputHalfBytes = data[0];
+ string inputFloatBytes = data[1];
+ string inputDoubleBytes = data[2];
+ string correctValue = data[3];
+
+ double doubleValue = double.Parse(correctValue, NumberFormatInfo.InvariantInfo);
+ string doubleBytes = BitConverter.ToString(BitConverter.GetBytes(doubleValue));
+ float floatValue = float.Parse(correctValue, NumberFormatInfo.InvariantInfo);
+ string floatBytes = BitConverter.ToString(BitConverter.GetBytes(floatValue));
+ Half halfValue = Half.Parse(correctValue, NumberFormatInfo.InvariantInfo);
+ string halfBytes = BitConverter.ToString(BitConverter.GetBytes(halfValue));
+
+ doubleBytes = SplitPairs(doubleBytes);
+ floatBytes = SplitPairs(floatBytes);
+ halfBytes = SplitPairs(halfBytes);
+
+ if (BitConverter.IsLittleEndian)
+ {
+ doubleBytes = Reverse(doubleBytes);
+ floatBytes = Reverse(floatBytes);
+ halfBytes = Reverse(halfBytes);
+ }
+
+ Assert.Equal(doubleBytes, inputDoubleBytes);
+ Assert.Equal(floatBytes, inputFloatBytes);
+ Assert.Equal(halfBytes, inputHalfBytes);
+ line = streamReader.ReadLine();
+ }
+ }
+ }
+ }
+
public static IEnumerable<object[]> Parse_Invalid_TestData()
{
NumberStyles defaultStyle = NumberStyles.Float;