Add parsing for binary floats
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using NathanMcRae;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
{
|
||||
@ -68,6 +69,24 @@ using System.Text;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
string testName = "Float binary test";
|
||||
var bytes = new List<byte>();
|
||||
bytes.AddRange(Encoding.UTF8.GetBytes("somefloat:float64\tbinfloat:float64-le" +
|
||||
"\n1.5\t")); bytes.AddRange(BitConverter.GetBytes(1.5));
|
||||
bytes.AddRange(Encoding.UTF8.GetBytes("\n-8.0000005E-14\t")); bytes.AddRange(BitConverter.GetBytes(-8.0000005E-14));
|
||||
|
||||
SaneTsv parsed = SaneTsv.ParseTypedTsv(bytes.ToArray());
|
||||
if ((double)parsed.Records[0]["binfloat"] == (double)parsed.Records[0]["somefloat"])
|
||||
{
|
||||
Console.WriteLine($"Passed {testName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Failed {testName}");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Done with tests");
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user