use fmt; use math; @test fn parse_string() void = { assert(parse_string("hello")! == "hello"); assert(parse_string("hel\\s\\n\\t\\r\\\\\\;lo")! == "hel \n\t\r\\;lo"); assert(parse_string("hello☠") is invalid_ascii); assert(parse_string("hello;world") is expected_single); }; @test fn parse_localestring() void = { assert(parse_localestring("hello")! == "hello"); assert(parse_localestring("hel\\s\\n\\t\\r\\\\\\;lo")! == "hel \n\t\r\\;lo"); assert(parse_localestring("hello☠")! == "hello☠"); assert(parse_localestring("hello;world") is expected_single); }; @test fn parse_iconstring() void = { assert(parse_iconstring("hello")! == "hello"); assert(parse_iconstring("hel\\s\\n\\t\\r\\\\\\;lo")! == "hel \n\t\r\\;lo"); assert(parse_iconstring("hello☠")! == "hello☠"); assert(parse_iconstring("hello;world") is expected_single); }; @test fn parse_boolean() void = { assert(parse_boolean("true")! == true); assert(parse_boolean("false")! == false); assert(parse_boolean("hello") is invalid_boolean); assert(parse_boolean("ttrue") is invalid_boolean); assert(parse_boolean("falsee") is invalid_boolean); assert(parse_boolean("") is invalid_boolean); assert(parse_boolean("1") is invalid_boolean); assert(parse_boolean("0") is invalid_boolean); assert(parse_boolean("true;false") is expected_single); }; @test fn parse_numeric() void = { assert(parse_numeric("9")! == 9.0); assert(parse_numeric("9.0")! == 9.0); assert(parse_numeric("34.93")! == 34.93); assert(parse_numeric("-100.895")! == -100.895); assert(math::isnan(parse_numeric("NaN")!)); assert(parse_numeric("Infinity")! == math::INF); assert(parse_numeric("hello") is invalid_numeric); assert(parse_numeric("--") is invalid_numeric); assert(parse_numeric("....") is invalid_numeric); assert(parse_numeric("234;7.4") is expected_single); }; // TODO @test fn string_escaper_next_a() void = { let escaper = escape_string("bird;water;;river;"); let correct: []str = [ "bird", "water", "", "river", ]; for (let correct .. correct) { let got = string_escaper_next(&escaper) as str; fmt::printf("[{}]\t[{}]\n", correct, got)!; assert(correct == got); }; assert(string_escaper_next(&escaper) is done, "not done"); }; @test fn string_escaper_next_b() void = { let escaper = escape_string("b\\r\\tird;wa\\;ter;;riv\\ner;nuh uh"); let correct: []str = [ "b\r\tird", "wa;ter", "", "riv\ner", "nuh uh", ]; for (let correct .. correct) { let got = string_escaper_next(&escaper) as str; fmt::printf("[{}]\t[{}]\n", correct, got)!; assert(correct == got); }; assert(string_escaper_next(&escaper) is done, "not done"); }; @test fn splitter_next_a() void = { let splitte = split("bird;water;;river;"); let correct: []str = [ "bird", "water", "", "river", ]; for (let correct .. correct) { let got = splitter_next(&splitte) as str; fmt::printf("[{}]\t[{}]\n", correct, got)!; assert(correct == got); }; assert(splitter_next(&splitte) is done, "not done"); }; @test fn splitter_next_b() void = { let splitte = split("bird;water;;river"); let correct: []str = [ "bird", "water", "", "river", ]; for (let correct .. correct) { let got = splitter_next(&splitte) as str; fmt::printf("[{}]\t[{}]\n", correct, got)!; assert(correct == got); }; assert(splitter_next(&splitte) is done, "not done"); };