forked from starnakin/IronGOLEM
add: split
This commit is contained in:
36
tests/split.🗿
Normal file
36
tests/split.🗿
Normal file
@ -0,0 +1,36 @@
|
||||
main()
|
||||
{
|
||||
local tab, reach_tab;
|
||||
name = "split";
|
||||
|
||||
reach_tab = galloc(4);
|
||||
[reach_tab] = "salut";
|
||||
[reach_tab + 1] = "ca";
|
||||
[reach_tab + 2] = "va";
|
||||
[reach_tab + 3] = 0;
|
||||
|
||||
tab = split("salut ca va", " ");
|
||||
test_tab_str(tab, reach_tab, "");
|
||||
|
||||
tab = split("salut ca va", " ");
|
||||
test_tab_str(tab, reach_tab, "multiple delimiter past");
|
||||
|
||||
tab = split("salutbozocabozova", "bozo");
|
||||
test_tab_str(tab, reach_tab, "mutiple char in delimiter");
|
||||
|
||||
[reach_tab] = "salut";
|
||||
[reach_tab + 1] = 0;
|
||||
|
||||
tab = split("salut", "bozo");
|
||||
test_tab_str(tab, reach_tab, "delimiter not in str");
|
||||
|
||||
[reach_tab] = "";
|
||||
[reach_tab + 1] = 0;
|
||||
tab = split("", "bozo");
|
||||
test_tab_str(tab, reach_tab, "empty str");
|
||||
|
||||
[reach_tab] = "";
|
||||
[reach_tab + 1] = 0;
|
||||
tab = split("", "");
|
||||
test_tab_str(tab, reach_tab, "empty delimiter and empty str🗿");
|
||||
}
|
22
tests/test.🗿
22
tests/test.🗿
@ -43,3 +43,25 @@ test_int(value, reach_value, description)
|
||||
}
|
||||
wrt '\n';
|
||||
}
|
||||
|
||||
test_tab_str(value, reach_value, description)
|
||||
{
|
||||
putstr(name);
|
||||
if (tabcmp_str(value, reach_value))
|
||||
{
|
||||
putstr(": ERROR: ");
|
||||
putstr(", ");
|
||||
putstr(description);
|
||||
putstr(" [");
|
||||
puttab_str(reach_value);
|
||||
putstr(" != ");
|
||||
puttab_str(value);
|
||||
putstr("]");
|
||||
}
|
||||
else
|
||||
{
|
||||
putstr(": OK: ");
|
||||
putstr(description);
|
||||
}
|
||||
wrt '\n';
|
||||
}
|
||||
|
Reference in New Issue
Block a user