diff options
author | 2023-05-11 18:17:11 +0200 | |
---|---|---|
committer | 2023-05-11 18:17:11 +0200 | |
commit | 12ff05b3b7dcf90e60e1b666c9b3781fe2412dcd (patch) | |
tree | 0efe44b00d31c2ad2ed308f18b44cf1aa7c78447 | |
parent | b3f6133a327390df495954d8ae561a895805c0e1 (diff) | |
download | string2-12ff05b3b7dcf90e60e1b666c9b3781fe2412dcd.tar.gz string2-12ff05b3b7dcf90e60e1b666c9b3781fe2412dcd.zip |
-rw-r--r-- | test/main.c | 2 | ||||
-rw-r--r-- | test/test_split.c | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/main.c b/test/main.c index 479d529..7fff724 100644 --- a/test/main.c +++ b/test/main.c @@ -4,11 +4,13 @@ void test_split1(); void test_split2(); +void test_split3(); int main(int argc, char** argv) { test_split1(); test_split2(); + test_split3(); return EXIT_SUCCESS; } diff --git a/test/test_split.c b/test/test_split.c index 7b19caa..fc7513b 100644 --- a/test/test_split.c +++ b/test/test_split.c @@ -39,3 +39,21 @@ test_split2() log("OK\n"); } + +void +test_split3() +{ + log("Running..."); + + char *str = "\nSTR_1\nSTR_2\n"; + int size; + char **tokens = strsplit(str, '\n', &size); + + assert(size == 4); + assert(strlen(tokens[0]) == 0); + assert(strncmp("STR_1", tokens[1], 5) == 0); + assert(strncmp("STR_2", tokens[2], 5) == 0); + assert(strlen(tokens[3]) == 0); + + log("OK\n"); +} |