extra-tsv/SaneTsvTest/Program.cs

39 lines
958 B
C#
Raw Normal View History

2024-02-14 03:15:07 +00:00
using NathanMcRae;
using System.Text;
2024-02-14 22:30:36 +00:00
{
string testName = "Bool test";
string testString1 = "column1:type:boolean\tcolumn2:binary\tcolumnthree\\nyep:string" +
"\nTRUE\tvalue\\\\t\0woo\tvaluetrhee" +
"\nFALSE\tnother\tno\\ther";
2024-02-14 03:15:07 +00:00
2024-02-14 22:30:36 +00:00
SaneTsv parsed = SaneTsv.Parse(Encoding.UTF8.GetBytes(testString1));
if (parsed.Records[0]["column1:type"] is bool result && result)
{
Console.WriteLine($"Passed {testName}");
}
else
{
Console.WriteLine($"Failed {testName}");
}
}
{
string testName = "Bad bool test";
try
{
string testString1 = "column1:type:boolean\tcolumn2:binary\tcolumnthree\\nyep:string" +
"\nTUE\tvalue\\\\t\0woo\tvaluetrhee" +
"\nFALSE\tnother\tno\\ther";
SaneTsv parsed = SaneTsv.Parse(Encoding.UTF8.GetBytes(testString1));
Console.WriteLine($"Failed {testName}");
}
catch (Exception)
{
Console.WriteLine($"Passed {testName}");
}
Console.WriteLine("Done with tests");
}