about summary refs log tree commit diff
path: root/tests.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-11-03 18:13:05 +0100
committerLeah Neukirchen <leah@vuxu.org>2023-11-03 18:13:05 +0100
commit6cd51d52e177314a68c6c2f6c598798136ba1b52 (patch)
treeaa9053881d115610550f3a55f2e0fb64773f231a /tests.c
parentfce8d1ec3329a97fc8886cf71eb3d1a763d71ad7 (diff)
downloadlibste-master.tar.gz
libste-master.tar.xz
libste-master.zip
add steccpy HEAD master
Diffstat (limited to 'tests.c')
-rw-r--r--tests.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests.c b/tests.c
index fa2e0ff..14829a8 100644
--- a/tests.c
+++ b/tests.c
@@ -16,7 +16,7 @@ is(const char *desc, int ok)
 int
 main()
 {
-	printf("1..40\n");
+	printf("1..49\n");
 
 	printf("# stecpy\n");
 
@@ -125,5 +125,26 @@ main()
 	is("y not found in first 6 chars", y == buf2 + 6);
 
 
+	printf("# steccpy\n");
+	pos = buf;
+	pos = steccpy(pos, end, "abc,def", ',');
+	is("1x3 = 3", strlen(buf) == 3);
+	pos = steccpy(pos, end, "def:ghijkl", ':');
+	is("2x3 = 6", strlen(buf) == 6);
+	pos = steccpy(pos, end, ":ghi", ':');
+	pos = steccpy(pos, end, "ghi", ':');
+	is("3x3 = 9", strlen(buf) == 9);
+	pos = steccpy(pos, end, "jkl", '\0');
+	is("4x3 = 12", strlen(buf) == 12);
+	pos = steccpy(pos, end, "mnopqst", '!');
+	is("5x3 = 15", strlen(buf) == 15);
+	pos = steccpy(pos, end, "full", '!');
+	is("buffer is full", strlen(buf) == 15);
+	is("return value is end", pos == end);
+	pos = steccpy(pos, end, "fuller", 'r');
+	is("buffer doesn't get fuller", strlen(buf) == 15);
+	is("return value is end", pos == end);
+
+
 	return status;
 }