Add Typed TSV test
This commit is contained in:
parent
aee67e457e
commit
221f4eeff5
@ -1,5 +1,4 @@
|
|||||||
using NathanMcRae;
|
using NathanMcRae;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -89,5 +88,58 @@ using System.Text;
|
|||||||
|
|
||||||
Console.WriteLine("Done with tests");
|
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
|
// TODO: Check qNaN, sNaN, +inf, -inf values for float types
|
||||||
|
Loading…
Reference in New Issue
Block a user