Add type parsing

This commit is contained in:
Nathan McRae
2024-02-14 14:30:36 -08:00
parent 695f98b67c
commit d199984364
2 changed files with 248 additions and 57 deletions

View File

@ -1,8 +1,38 @@
using NathanMcRae;
using System.Text;
string testString1 = "column1\tcolumn2\tcolumnthree\\nyep\nvalue1\tvalue\\\\twoo\tvaluetrhee\nthis\\nis\\na\\nvalue\tnother\tno\\ther";
{
string testName = "Bool test";
string testString1 = "column1:type:boolean\tcolumn2:binary\tcolumnthree\\nyep:string" +
"\nTRUE\tvalue\\\\t\0woo\tvaluetrhee" +
"\nFALSE\tnother\tno\\ther";
SaneTsv parsed = SaneTsv.Parse(Encoding.UTF8.GetBytes(testString1));
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
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");
}