format::desktop_entry: Test integer parsing functions
This commit is contained in:
parent
fc0cab93bc
commit
fc533dbeea
@ -51,6 +51,14 @@ use strings;
|
|||||||
assert(parse_numeric("234;7.4") is expected_single);
|
assert(parse_numeric("234;7.4") is expected_single);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@test fn parse_integer() void = {
|
||||||
|
assert(parse_integer("9")! == 9);
|
||||||
|
assert(parse_integer("2348")! == 2348);
|
||||||
|
assert(parse_integer("-324")! == -324);
|
||||||
|
assert(parse_integer("324.9") is invalid_integer);
|
||||||
|
assert(parse_integer("324.0") is invalid_integer);
|
||||||
|
};
|
||||||
|
|
||||||
@test fn parse_strings() void = {
|
@test fn parse_strings() void = {
|
||||||
let correct: []str = [
|
let correct: []str = [
|
||||||
"b\r\tird",
|
"b\r\tird",
|
||||||
@ -134,6 +142,28 @@ use strings;
|
|||||||
assert(parse_numerics(";5;") is invalid_numeric);
|
assert(parse_numerics(";5;") is invalid_numeric);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@test fn parse_integers() void = {
|
||||||
|
let correct: []int = [
|
||||||
|
5,
|
||||||
|
34,
|
||||||
|
-29,
|
||||||
|
32498,
|
||||||
|
];
|
||||||
|
let got = parse_integers("5;34;-29;32498")!;
|
||||||
|
defer free(got);
|
||||||
|
for (let index = 0z; index < len(correct); index += 1) {
|
||||||
|
assert(index < len(got), "ran out");
|
||||||
|
let correct = correct[index];
|
||||||
|
let got = got[index];
|
||||||
|
fmt::printf("[{}]\t[{}]\n", correct, got)!;
|
||||||
|
assert(correct == got);
|
||||||
|
};
|
||||||
|
assert(len(got) == len(correct), "not done");
|
||||||
|
assert(parse_integers("hello;world") is invalid_integer);
|
||||||
|
assert(parse_integers("5;;") is invalid_integer);
|
||||||
|
assert(parse_integers(";5;") is invalid_integer);
|
||||||
|
};
|
||||||
|
|
||||||
@test fn string_escaper_next_a() void = {
|
@test fn string_escaper_next_a() void = {
|
||||||
let escaper = escape_string("bird;water;;river;");
|
let escaper = escape_string("bird;water;;river;");
|
||||||
let correct: []str = [
|
let correct: []str = [
|
||||||
|
Loading…
Reference in New Issue
Block a user