Add Typed TSV test
This commit is contained in:
parent
dc0c300fdc
commit
52ed949529
@ -1,5 +1,4 @@
|
||||
using NathanMcRae;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
{
|
||||
@ -89,5 +88,58 @@ using System.Text;
|
||||
|
||||
Console.WriteLine("Done with tests");
|
||||
|
||||
{
|
||||
string testName = "Serde test";
|
||||
string[] headerNames =
|
||||
{
|
||||
"string-test",
|
||||
"bool-test",
|
||||
"float32-test",
|
||||
"float32-le-test",
|
||||
"float64-test",
|
||||
"float64-le-test",
|
||||
"uint32-test",
|
||||
"uint64-test",
|
||||
"int32-test",
|
||||
"int64-test",
|
||||
"binary-test",
|
||||
};
|
||||
|
||||
Type[] headerTypes =
|
||||
{
|
||||
typeof(SaneTsv.StringType),
|
||||
typeof(SaneTsv.BooleanType),
|
||||
typeof(SaneTsv.Float32Type),
|
||||
typeof(SaneTsv.Float32LEType),
|
||||
typeof(SaneTsv.Float64Type),
|
||||
typeof(SaneTsv.Float64LEType),
|
||||
typeof(SaneTsv.UInt32Type),
|
||||
typeof(SaneTsv.UInt64Type),
|
||||
typeof(SaneTsv.Int32Type),
|
||||
typeof(SaneTsv.Int64Type),
|
||||
typeof(SaneTsv.BinaryType),
|
||||
};
|
||||
|
||||
object[][] data =
|
||||
{
|
||||
new object[] { "test", true, 44.5f, 44.5f, -88e-3, -88e-3, 7773, 88888888, -7773, -88888888, new byte[] { 0, 1, 2, 3 } },
|
||||
new object[] { "test2", false, 44.5000005f, 44.5000005f, -88e-30, -88e-30, 7773, 88888888, -7773, -88888888, new byte[] { 0, 1, 2, 3, 4 } },
|
||||
new object[] { "test2", false, float.NaN, float.NaN, double.NaN, double.NaN, 7773, 88888888, -7773, -88888888, new byte[] { 0, 1, 2, 3, 4 } },
|
||||
new object[] { "test2", false, float.NegativeInfinity, float.NegativeInfinity, double.NegativeInfinity, double.NegativeInfinity, 7773, 88888888, -7773, -88888888, new byte[] { 0, 1, 2, 3, 4 } },
|
||||
new object[] { "test2", false, float.PositiveInfinity, float.PositiveInfinity, double.PositiveInfinity, double.PositiveInfinity, 7773, 88888888, -7773, -88888888, new byte[] { 0, 1, 2, 3, 4 } },
|
||||
};
|
||||
|
||||
byte[] serialized = SaneTsv.SerializeTypedTsv(headerTypes, headerNames, data);
|
||||
|
||||
SaneTsv parsed = SaneTsv.ParseTypedTsv(serialized);
|
||||
|
||||
if ((float)parsed.Records[1]["float32-test"] == 44.5000005)
|
||||
{
|
||||
Console.WriteLine($"Passed {testName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Failed {testName}");
|
||||
}
|
||||
}
|
||||
// TODO: Check qNaN, sNaN, +inf, -inf values for float types
|
||||
|
Loading…
Reference in New Issue
Block a user