diff options
| author | 2023-10-10 11:20:05 -0400 | |
|---|---|---|
| committer | 2023-10-10 11:20:05 -0400 | |
| commit | dab8b0f3d8f0df6641af11d20c53a3bd5593180a (patch) | |
| tree | 2b0aa62b4c50943b41167452aa7d16469a77218e /tests | |
| parent | b07771669ae029d07b76a58ed526da7bc29ec27b (diff) | |
| download | libalabaster-dab8b0f3d8f0df6641af11d20c53a3bd5593180a.tar.gz libalabaster-dab8b0f3d8f0df6641af11d20c53a3bd5593180a.tar.bz2 libalabaster-dab8b0f3d8f0df6641af11d20c53a3bd5593180a.zip | |
Cleanup
- Remove al_str_tok
- Improve al_str_get_line
- Various consistency fixes
- Cleanup comments
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/str.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/str.c b/tests/str.c index 0dcd896..ce1c3b5 100644 --- a/tests/str.c +++ b/tests/str.c @@ -124,10 +124,26 @@ static bool str_test_get_line(void) str *lines = al_str_c("test\nasdf\ntest2\na\n"); str *lines_array[] = { al_str_c("test"), al_str_c("asdf"), al_str_c("test2"), al_str_c("a") }; - u32 count = 0; + str line; + al_memset(&line, 0, sizeof(str)); + u32 c = 0; - for (str line = { 0 }; al_str_get_line(lines, &line); ) { - AL_TEST_TRUE(al_str_eq(&line, lines_array[count++])); + for (; al_str_get_line(lines, '\n', &line); ) { + AL_TEST_LT(c, (u32)AL_ARRAY_SIZE(lines_array), u32); + AL_TEST_TRUE(al_str_eq(&line, lines_array[c++])); + } + + AL_TEST_EQ(c, (u32)AL_ARRAY_SIZE(lines_array), u32); + + lines = al_str_c(""); + + al_memset(&line, 0, sizeof(str)); + c = 0; + + for (; al_str_get_line(lines, '\n', &line); ) { + AL_TEST_LT(c, 1, u32); + AL_TEST_EQ(line.len, 0, u32); + c++; } AL_TEST_END(); |