commit 547f5c55af03e0b004127e489c1447dacd0ee783 parent c3eb1d839343abc7edebdf22bcf72872ced83cb9 Author: Drew DeVault <sir@cmpwn.com> Date: Wed, 3 Feb 2021 16:23:24 -0500 strings: add test for iter Diffstat:
M | strings/iter.ha | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/strings/iter.ha b/strings/iter.ha @@ -20,3 +20,15 @@ export fn next(iter: *iterator) (rune | void) = { export fn iterstr(iter: *iterator) str = { return from_utf8(iter.src[iter.offs..]); }; + +@test fn iter_test() void = { + let i = iter("こんにちは"); + assert(next(&i) as rune == 'こ'); + assert(next(&i) as rune == 'ん'); + assert(iterstr(&i) == "にちは"); + assert(next(&i) as rune == 'に'); + assert(next(&i) as rune == 'ち'); + assert(next(&i) as rune == 'は'); + assert(next(&i) is void); + assert(next(&i) is void); +};