aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-05-11 18:17:11 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-05-11 18:17:11 +0200
commit12ff05b3b7dcf90e60e1b666c9b3781fe2412dcd (patch)
tree0efe44b00d31c2ad2ed308f18b44cf1aa7c78447
parentb3f6133a327390df495954d8ae561a895805c0e1 (diff)
downloadstring2-master.tar.gz
string2-master.zip
Add a new testHEADmaster
-rw-r--r--test/main.c2
-rw-r--r--test/test_split.c18
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");
+}