From e8255f0a8525a82c9097d9a2c920126aaa010b08 Mon Sep 17 00:00:00 2001 From: Akuli Date: Wed, 6 Dec 2023 17:18:03 +0200 Subject: [PATCH] Add tests for split_by_ascii_whitespace (#428) --- tests/should_succeed/ascii_test.jou | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/should_succeed/ascii_test.jou b/tests/should_succeed/ascii_test.jou index 1b0d332c..a3d57ebf 100644 --- a/tests/should_succeed/ascii_test.jou +++ b/tests/should_succeed/ascii_test.jou @@ -1,4 +1,6 @@ import "stdlib/ascii.jou" +import "stdlib/io.jou" +import "stdlib/mem.jou" import "stdlib/str.jou" def main() -> int: @@ -35,9 +37,20 @@ def main() -> int: assert not is_ascii_whitespace('.') assert not is_ascii_whitespace('\0') - s: byte[100] - strcpy(s, " hello world \r\n \t ") + s: byte[100] = " hello world \r\n \t " trim_ascii_whitespace(s) assert strcmp(s, "hello world") == 0 + s = " hello world \r\n \t " + words = split_by_ascii_whitespace(s) + # Output: hello + # Output: world + for w = words; *w != NULL; w++: + puts(*w) + # Output: hello + # Output: world + for i = 0; words[i] != NULL; i++: + puts(words[i]) + free(words) + return 0