badvpn/ncd/tests/explode.ncd

34 lines
930 B
Plaintext

process main {
explode("FOO", "aaaFOObbbFOOcccFOOddd") l;
val_equal(l, {"aaa", "bbb", "ccc", "ddd"}) a;
assert(a);
compile_search("FOO") comp;
comp->explode("aaaFOObbbFOOcccFOOddd") l;
val_equal(l, {"aaa", "bbb", "ccc", "ddd"}) a;
assert(a);
explode("FOO", "FOObbbFOOFOO") l;
val_equal(l, {"", "bbb", "", ""}) a;
assert(a);
explode("FOO", "foo") l;
val_equal(l, {"foo"}) a;
assert(a);
explode("FOO", "FOO") l;
val_equal(l, {"", ""}) a;
assert(a);
explode("participate in parachute", "parachute in participation of participate in parachuteparparticipate in parachute participate in parachut") l;
val_equal(l, {"parachute in participation of ", "par", " participate in parachut"}) a;
assert(a);
concat("aaaFOObbbFOOcccFOOddd") e;
explode("FOO", e) l;
val_equal(l, {"aaa", "bbb", "ccc", "ddd"}) a;
assert(a);
exit("0");
}