aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--envaligned_allocn.c2
-rw-r--r--envcallocn.c2
-rw-r--r--envmallocn.c2
-rw-r--r--envmemalignn.c2
-rw-r--r--envmemalignzn.c2
-rw-r--r--envvallocn.c2
-rw-r--r--evaligned_allocn.c2
-rw-r--r--evaligned_alloczn.c2
-rw-r--r--evaligned_reallocn.c2
-rw-r--r--evcallocn.c2
-rw-r--r--evmallocn.c2
-rw-r--r--evmalloczn.c2
-rw-r--r--evmemalignn.c2
-rw-r--r--evmemalignzn.c2
-rw-r--r--evvallocn.c2
-rw-r--r--inchrcaseset.c2
-rw-r--r--inchrset.c7
-rw-r--r--libsimple.c790
-rw-r--r--memisutf8.c4
-rw-r--r--stpmove.c20
-rw-r--r--stpnmove.c74
-rw-r--r--stpnset.c21
-rw-r--r--stpntolower.c34
-rw-r--r--stpntoupper.c34
-rw-r--r--stpset.c11
-rw-r--r--stptolower.c9
-rw-r--r--stptoupper.c9
-rw-r--r--strcasecmpnul.c17
-rw-r--r--strcaseeq.c10
-rw-r--r--strcaseeqnul.c15
-rw-r--r--strcasestarts.c2
-rw-r--r--strccpy.c22
-rw-r--r--strcmpnul.c17
-rw-r--r--strend.c1
-rw-r--r--streq.c10
-rw-r--r--streqnul.c15
-rw-r--r--strisutf8.c56
-rw-r--r--strmove.c20
-rw-r--r--strncasecmpnul.c40
-rw-r--r--strncaseeq.c30
-rw-r--r--strncaseeqnul.c45
-rw-r--r--strnccpy.c70
-rw-r--r--strncmpnul.c40
-rw-r--r--strneq.c30
-rw-r--r--strneqnul.c45
-rw-r--r--strnisutf8.c60
-rw-r--r--strnmove.c74
-rw-r--r--strnreplace.c26
-rw-r--r--strnset.c21
-rw-r--r--strntolower.c39
-rw-r--r--strntoupper.c39
-rw-r--r--strrcaseeqlen.c21
-rw-r--r--strreplace.c6
-rw-r--r--strreqlen.c19
-rw-r--r--strrncaseeqlen.c26
-rw-r--r--strrneqlen.c24
-rw-r--r--strset.c11
-rw-r--r--strtolower.c12
-rw-r--r--strtoupper.c12
-rw-r--r--valigned_allocn.c2
-rw-r--r--valigned_reallocfn.c4
-rw-r--r--vcallocn.c2
-rw-r--r--vmallocn.c2
-rw-r--r--vmemalignn.c2
-rw-r--r--vmemalignzn.c2
-rw-r--r--vvallocn.c2
66 files changed, 1033 insertions, 903 deletions
diff --git a/envaligned_allocn.c b/envaligned_allocn.c
index fbb97f2..2c8611a 100644
--- a/envaligned_allocn.c
+++ b/envaligned_allocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envaligned_allocn(int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_enaligned_allocn */
}
#endif
diff --git a/envcallocn.c b/envcallocn.c
index 3c943ef..96aa31c 100644
--- a/envcallocn.c
+++ b/envcallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envcallocn(int, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_encallocn */
}
#endif
diff --git a/envmallocn.c b/envmallocn.c
index 9b37db4..68b2ab6 100644
--- a/envmallocn.c
+++ b/envmallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envmallocn(int, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_enmallocn */
}
#endif
diff --git a/envmemalignn.c b/envmemalignn.c
index 48a56fd..25f9142 100644
--- a/envmemalignn.c
+++ b/envmemalignn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envmemalignn(int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_enmemalignn */
}
#endif
diff --git a/envmemalignzn.c b/envmemalignzn.c
index fb4b464..ca4e16d 100644
--- a/envmemalignzn.c
+++ b/envmemalignzn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envmemalignzn(int, int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_enmemalignzn */
}
#endif
diff --git a/envvallocn.c b/envvallocn.c
index b351a14..9dc333f 100644
--- a/envvallocn.c
+++ b/envvallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_envvallocn(int, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_envallocn */
}
#endif
diff --git a/evaligned_allocn.c b/evaligned_allocn.c
index 2d14680..00dad49 100644
--- a/evaligned_allocn.c
+++ b/evaligned_allocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evaligned_allocn(size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ealigned_allocn */
}
#endif
diff --git a/evaligned_alloczn.c b/evaligned_alloczn.c
index ec2d305..26b9e1f 100644
--- a/evaligned_alloczn.c
+++ b/evaligned_alloczn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evaligned_alloczn(int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ealigned_alloczn */
}
#endif
diff --git a/evaligned_reallocn.c b/evaligned_reallocn.c
index 37e7133..e17545e 100644
--- a/evaligned_reallocn.c
+++ b/evaligned_reallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evaligned_reallocn(void *, size_t, size_t, va_list
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ealigned_reallocn */
}
#endif
diff --git a/evcallocn.c b/evcallocn.c
index 25770bc..1fe842d 100644
--- a/evcallocn.c
+++ b/evcallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evcallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ecallocn */
}
#endif
diff --git a/evmallocn.c b/evmallocn.c
index 67003f0..d61142d 100644
--- a/evmallocn.c
+++ b/evmallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evmallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_emallocn */
}
#endif
diff --git a/evmalloczn.c b/evmalloczn.c
index 7cf4abe..bae8f87 100644
--- a/evmalloczn.c
+++ b/evmalloczn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evmalloczn(int, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_emalloczn */
}
#endif
diff --git a/evmemalignn.c b/evmemalignn.c
index 5e1de37..99006ec 100644
--- a/evmemalignn.c
+++ b/evmemalignn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evmemalignn(size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ememalignn */
}
#endif
diff --git a/evmemalignzn.c b/evmemalignzn.c
index 304d5b8..34d9495 100644
--- a/evmemalignzn.c
+++ b/evmemalignzn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evmemalignzn(int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_ememalignzn */
}
#endif
diff --git a/evvallocn.c b/evvallocn.c
index 5e52d4f..5776f63 100644
--- a/evvallocn.c
+++ b/evvallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_evvallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_evallocn */
}
#endif
diff --git a/inchrcaseset.c b/inchrcaseset.c
index bd50fa3..bd92cf5 100644
--- a/inchrcaseset.c
+++ b/inchrcaseset.c
@@ -3,7 +3,7 @@
#ifndef TEST
-extern inline int libsimple_inchrcaseset(int, const char *);
+extern inline int libsimple_inchrcaseset(int, const char *); /* TODO test */
#else
diff --git a/inchrset.c b/inchrset.c
index 7358ede..591c2e9 100644
--- a/inchrset.c
+++ b/inchrset.c
@@ -12,6 +12,13 @@ extern inline int libsimple_inchrset(int, const char *);
int
main(void)
{
+ assert(libsimple_inchrset('a', "xyz") == 0);
+ assert(libsimple_inchrset('b', "xyz") == 0);
+ assert(libsimple_inchrset('c', "xyz") == 0);
+ assert(libsimple_inchrset('x', "xyz") == 1);
+ assert(libsimple_inchrset('y', "xyz") == 1);
+ assert(libsimple_inchrset('z', "xyz") == 1);
+ assert(libsimple_inchrset('\0', "xyz") == 0);
return 0;
}
diff --git a/libsimple.c b/libsimple.c
index 2cf7b62..2bb5139 100644
--- a/libsimple.c
+++ b/libsimple.c
@@ -92,9 +92,9 @@ main(void)
void *ptr, *old;
const char *cs;
const wchar_t *cws;
- char buf[1024], *s;
+ char *s;
wchar_t *ws;
- size_t i, j, n;
+ size_t i, n;
DEFINE_PAGESIZE;
DEFINE_CACHELINE;
@@ -280,342 +280,6 @@ main(void)
assert(TYPE_MIN(int64_t) == INT64_MIN);
assert(TYPE_MIN(uint64_t) == 0);
- assert(strcmpnul(libsimple_strend("abc\0xyz"), "xyz"));
-
- assert(libsimple_inchrset('a', "xyz") == 0);
- assert(libsimple_inchrset('b', "xyz") == 0);
- assert(libsimple_inchrset('c', "xyz") == 0);
- assert(libsimple_inchrset('x', "xyz") == 1);
- assert(libsimple_inchrset('y', "xyz") == 1);
- assert(libsimple_inchrset('z', "xyz") == 1);
- assert(libsimple_inchrset('\0', "xyz") == 0);
-
- assert(libsimple_streq("abc", "abc") == 1);
- assert(libsimple_streq("abc", "ab") == 0);
- assert(libsimple_streq("ab", "abc") == 0);
- assert(libsimple_streq("ab", "xy") == 0);
- assert(libsimple_streq("xy", "ab") == 0);
- assert(libsimple_streq("", "1") == 0);
- assert(libsimple_streq("1", "") == 0);
- assert(libsimple_streq("", "") == 1);
- assert(libsimple_streq("abc", "ABC") == 0);
- assert(libsimple_streq("ABC", "abc") == 0);
-
- assert(libsimple_strneq("abc", "abc", 5) == 1);
- assert(libsimple_strneq("abc", "ab", 5) == 0);
- assert(libsimple_strneq("ab", "abc", 5) == 0);
- assert(libsimple_strneq("ab", "xy", 5) == 0);
- assert(libsimple_strneq("xy", "ab", 5) == 0);
- assert(libsimple_strneq("", "1", 5) == 0);
- assert(libsimple_strneq("1", "", 5) == 0);
- assert(libsimple_strneq("", "", 5) == 1);
- assert(libsimple_strneq("abc", "ABC", 5) == 0);
- assert(libsimple_strneq("ABC", "abc", 5) == 0);
- assert(libsimple_strneq("abc", "abc", 1) == 1);
- assert(libsimple_strneq("abc", "ab", 1) == 1);
- assert(libsimple_strneq("ab", "abc", 1) == 1);
- assert(libsimple_strneq("ab", "xy", 1) == 0);
- assert(libsimple_strneq("xy", "ab", 1) == 0);
- assert(libsimple_strneq("", "1", 1) == 0);
- assert(libsimple_strneq("1", "", 1) == 0);
- assert(libsimple_strneq("", "", 1) == 1);
- assert(libsimple_strneq("abc", "ABC", 1) == 0);
- assert(libsimple_strneq("ABC", "abc", 1) == 0);
- assert(libsimple_strneq("abc", "abc", 0) == 1);
- assert(libsimple_strneq("abc", "ab", 0) == 1);
- assert(libsimple_strneq("ab", "abc", 0) == 1);
- assert(libsimple_strneq("ab", "xy", 0) == 1);
- assert(libsimple_strneq("xy", "ab", 0) == 1);
- assert(libsimple_strneq("", "1", 0) == 1);
- assert(libsimple_strneq("1", "", 0) == 1);
- assert(libsimple_strneq("", "", 0) == 1);
- assert(libsimple_strneq("abc", "ABC", 0) == 1);
- assert(libsimple_strneq("ABC", "abc", 0) == 1);
-
- assert(libsimple_streqnul("abc", "abc") == 1);
- assert(libsimple_streqnul("abc", "ab") == 0);
- assert(libsimple_streqnul("ab", "abc") == 0);
- assert(libsimple_streqnul("ab", "xy") == 0);
- assert(libsimple_streqnul("xy", "ab") == 0);
- assert(libsimple_streqnul("", "1") == 0);
- assert(libsimple_streqnul("1", "") == 0);
- assert(libsimple_streqnul("", "") == 1);
- assert(libsimple_streqnul("abc", "ABC") == 0);
- assert(libsimple_streqnul("ABC", "abc") == 0);
- assert(libsimple_streqnul("", NULL) == 0);
- assert(libsimple_streqnul("1", NULL) == 0);
- assert(libsimple_streqnul(NULL, "") == 0);
- assert(libsimple_streqnul(NULL, "1") == 0);
- assert(libsimple_streqnul(NULL, NULL) == 1);
-
- assert(libsimple_strneqnul("abc", "abc", 5) == 1);
- assert(libsimple_strneqnul("abc", "ab", 5) == 0);
- assert(libsimple_strneqnul("ab", "abc", 5) == 0);
- assert(libsimple_strneqnul("ab", "xy", 5) == 0);
- assert(libsimple_strneqnul("xy", "ab", 5) == 0);
- assert(libsimple_strneqnul("", "1", 5) == 0);
- assert(libsimple_strneqnul("1", "", 5) == 0);
- assert(libsimple_strneqnul("", "", 5) == 1);
- assert(libsimple_strneqnul("abc", "ABC", 5) == 0);
- assert(libsimple_strneqnul("ABC", "abc", 5) == 0);
- assert(libsimple_strneqnul("", NULL, 5) == 0);
- assert(libsimple_strneqnul("1", NULL, 5) == 0);
- assert(libsimple_strneqnul(NULL, "", 5) == 0);
- assert(libsimple_strneqnul(NULL, "1", 5) == 0);
- assert(libsimple_strneqnul(NULL, NULL, 5) == 1);
- assert(libsimple_strneqnul("abc", "abc", 1) == 1);
- assert(libsimple_strneqnul("abc", "ab", 1) == 1);
- assert(libsimple_strneqnul("ab", "abc", 1) == 1);
- assert(libsimple_strneqnul("ab", "xy", 1) == 0);
- assert(libsimple_strneqnul("xy", "ab", 1) == 0);
- assert(libsimple_strneqnul("", "1", 1) == 0);
- assert(libsimple_strneqnul("1", "", 1) == 0);
- assert(libsimple_strneqnul("", "", 1) == 1);
- assert(libsimple_strneqnul("abc", "ABC", 1) == 0);
- assert(libsimple_strneqnul("ABC", "abc", 1) == 0);
- assert(libsimple_strneqnul("", NULL, 1) == 0);
- assert(libsimple_strneqnul("1", NULL, 1) == 0);
- assert(libsimple_strneqnul(NULL, "", 1) == 0);
- assert(libsimple_strneqnul(NULL, "1", 1) == 0);
- assert(libsimple_strneqnul(NULL, NULL, 1) == 1);
- assert(libsimple_strneqnul("abc", "abc", 0) == 1);
- assert(libsimple_strneqnul("abc", "ab", 0) == 1);
- assert(libsimple_strneqnul("ab", "abc", 0) == 1);
- assert(libsimple_strneqnul("ab", "xy", 0) == 1);
- assert(libsimple_strneqnul("xy", "ab", 0) == 1);
- assert(libsimple_strneqnul("", "1", 0) == 1);
- assert(libsimple_strneqnul("1", "", 0) == 1);
- assert(libsimple_strneqnul("", "", 0) == 1);
- assert(libsimple_strneqnul("abc", "ABC", 0) == 1);
- assert(libsimple_strneqnul("ABC", "abc", 0) == 1);
- assert(libsimple_strneqnul("", NULL, 0) == 0);
- assert(libsimple_strneqnul("1", NULL, 0) == 0);
- assert(libsimple_strneqnul(NULL, "", 0) == 0);
- assert(libsimple_strneqnul(NULL, "1", 0) == 0);
- assert(libsimple_strneqnul(NULL, NULL, 0) == 1);
-
- assert(libsimple_strcaseeq("abc", "abc") == 1);
- assert(libsimple_strcaseeq("abc", "ab") == 0);
- assert(libsimple_strcaseeq("ab", "abc") == 0);
- assert(libsimple_strcaseeq("ab", "xy") == 0);
- assert(libsimple_strcaseeq("xy", "ab") == 0);
- assert(libsimple_strcaseeq("", "1") == 0);
- assert(libsimple_strcaseeq("1", "") == 0);
- assert(libsimple_strcaseeq("", "") == 1);
- assert(libsimple_strcaseeq("abc", "ABC") == 1);
- assert(libsimple_strcaseeq("ABC", "abc") == 1);
-
- assert(libsimple_strncaseeq("abc", "abc", 5) == 1);
- assert(libsimple_strncaseeq("abc", "ab", 5) == 0);
- assert(libsimple_strncaseeq("ab", "abc", 5) == 0);
- assert(libsimple_strncaseeq("ab", "xy", 5) == 0);
- assert(libsimple_strncaseeq("xy", "ab", 5) == 0);
- assert(libsimple_strncaseeq("", "1", 5) == 0);
- assert(libsimple_strncaseeq("1", "", 5) == 0);
- assert(libsimple_strncaseeq("", "", 5) == 1);
- assert(libsimple_strncaseeq("abc", "ABC", 5) == 1);
- assert(libsimple_strncaseeq("ABC", "abc", 5) == 1);
- assert(libsimple_strncaseeq("abc", "abc", 1) == 1);
- assert(libsimple_strncaseeq("abc", "ab", 1) == 1);
- assert(libsimple_strncaseeq("ab", "abc", 1) == 1);
- assert(libsimple_strncaseeq("ab", "xy", 1) == 0);
- assert(libsimple_strncaseeq("xy", "ab", 1) == 0);
- assert(libsimple_strncaseeq("", "1", 1) == 0);
- assert(libsimple_strncaseeq("1", "", 1) == 0);
- assert(libsimple_strncaseeq("", "", 1) == 1);
- assert(libsimple_strncaseeq("abc", "ABC", 1) == 1);
- assert(libsimple_strncaseeq("ABC", "abc", 1) == 1);
- assert(libsimple_strncaseeq("abc", "abc", 0) == 1);
- assert(libsimple_strncaseeq("abc", "ab", 0) == 1);
- assert(libsimple_strncaseeq("ab", "abc", 0) == 1);
- assert(libsimple_strncaseeq("ab", "xy", 0) == 1);
- assert(libsimple_strncaseeq("xy", "ab", 0) == 1);
- assert(libsimple_strncaseeq("", "1", 0) == 1);
- assert(libsimple_strncaseeq("1", "", 0) == 1);
- assert(libsimple_strncaseeq("", "", 0) == 1);
- assert(libsimple_strncaseeq("abc", "ABC", 0) == 1);
- assert(libsimple_strncaseeq("ABC", "abc", 0) == 1);
-
- assert(libsimple_strcaseeqnul("abc", "abc") == 1);
- assert(libsimple_strcaseeqnul("abc", "ab") == 0);
- assert(libsimple_strcaseeqnul("ab", "abc") == 0);
- assert(libsimple_strcaseeqnul("ab", "xy") == 0);
- assert(libsimple_strcaseeqnul("xy", "ab") == 0);
- assert(libsimple_strcaseeqnul("", "1") == 0);
- assert(libsimple_strcaseeqnul("1", "") == 0);
- assert(libsimple_strcaseeqnul("", "") == 1);
- assert(libsimple_strcaseeqnul("abc", "ABC") == 1);
- assert(libsimple_strcaseeqnul("ABC", "abc") == 1);
- assert(libsimple_strcaseeqnul("", NULL) == 0);
- assert(libsimple_strcaseeqnul("1", NULL) == 0);
- assert(libsimple_strcaseeqnul(NULL, "") == 0);
- assert(libsimple_strcaseeqnul(NULL, "1") == 0);
- assert(libsimple_strcaseeqnul(NULL, NULL) == 1);
-
- assert(libsimple_strncaseeqnul("abc", "abc", 5) == 1);
- assert(libsimple_strncaseeqnul("abc", "ab", 5) == 0);
- assert(libsimple_strncaseeqnul("ab", "abc", 5) == 0);
- assert(libsimple_strncaseeqnul("ab", "xy", 5) == 0);
- assert(libsimple_strncaseeqnul("xy", "ab", 5) == 0);
- assert(libsimple_strncaseeqnul("", "1", 5) == 0);
- assert(libsimple_strncaseeqnul("1", "", 5) == 0);
- assert(libsimple_strncaseeqnul("", "", 5) == 1);
- assert(libsimple_strncaseeqnul("abc", "ABC", 5) == 1);
- assert(libsimple_strncaseeqnul("ABC", "abc", 5) == 1);
- assert(libsimple_strncaseeqnul("", NULL, 5) == 0);
- assert(libsimple_strncaseeqnul("1", NULL, 5) == 0);
- assert(libsimple_strncaseeqnul(NULL, "", 5) == 0);
- assert(libsimple_strncaseeqnul(NULL, "1", 5) == 0);
- assert(libsimple_strncaseeqnul(NULL, NULL, 5) == 1);
- assert(libsimple_strncaseeqnul("abc", "abc", 1) == 1);
- assert(libsimple_strncaseeqnul("abc", "ab", 1) == 1);
- assert(libsimple_strncaseeqnul("ab", "abc", 1) == 1);
- assert(libsimple_strncaseeqnul("ab", "xy", 1) == 0);
- assert(libsimple_strncaseeqnul("xy", "ab", 1) == 0);
- assert(libsimple_strncaseeqnul("", "1", 1) == 0);
- assert(libsimple_strncaseeqnul("1", "", 1) == 0);
- assert(libsimple_strncaseeqnul("", "", 1) == 1);
- assert(libsimple_strncaseeqnul("abc", "ABC", 1) == 1);
- assert(libsimple_strncaseeqnul("ABC", "abc", 1) == 1);
- assert(libsimple_strncaseeqnul("", NULL, 1) == 0);
- assert(libsimple_strncaseeqnul("1", NULL, 1) == 0);
- assert(libsimple_strncaseeqnul(NULL, "", 1) == 0);
- assert(libsimple_strncaseeqnul(NULL, "1", 1) == 0);
- assert(libsimple_strncaseeqnul(NULL, NULL, 1) == 1);
- assert(libsimple_strncaseeqnul("abc", "abc", 0) == 1);
- assert(libsimple_strncaseeqnul("abc", "ab", 0) == 1);
- assert(libsimple_strncaseeqnul("ab", "abc", 0) == 1);
- assert(libsimple_strncaseeqnul("ab", "xy", 0) == 1);
- assert(libsimple_strncaseeqnul("xy", "ab", 0) == 1);
- assert(libsimple_strncaseeqnul("", "1", 0) == 1);
- assert(libsimple_strncaseeqnul("1", "", 0) == 1);
- assert(libsimple_strncaseeqnul("", "", 0) == 1);
- assert(libsimple_strncaseeqnul("abc", "ABC", 0) == 1);
- assert(libsimple_strncaseeqnul("ABC", "abc", 0) == 1);
- assert(libsimple_strncaseeqnul("", NULL, 0) == 0);
- assert(libsimple_strncaseeqnul("1", NULL, 0) == 0);
- assert(libsimple_strncaseeqnul(NULL, "", 0) == 0);
- assert(libsimple_strncaseeqnul(NULL, "1", 0) == 0);
- assert(libsimple_strncaseeqnul(NULL, NULL, 0) == 1);
-
- assert(libsimple_strcmpnul(NULL, NULL) == 0);
- assert(libsimple_strcmpnul(NULL, "") < 0);
- assert(libsimple_strcmpnul("", NULL) > 0);
- assert(libsimple_strcmpnul("", "") == 0);
- assert(libsimple_strcmpnul(NULL, "x") < 0);
- assert(libsimple_strcmpnul("x", NULL) > 0);
- assert(libsimple_strcmpnul("x", "x") == 0);
- assert(libsimple_strcmpnul("a", "b") < 0);
- assert(libsimple_strcmpnul("b", "a") > 0);
- assert(libsimple_strcmpnul("aa", "ab") < 0);
- assert(libsimple_strcmpnul("ab", "aa") > 0);
- assert(libsimple_strcmpnul("aa", "aa") == 0);
- assert(libsimple_strcmpnul("A", "a") < 0);
- assert(libsimple_strcmpnul("a", "A") > 0);
- assert(libsimple_strcmpnul("AA", "Aa") < 0);
- assert(libsimple_strcmpnul("Aa", "AA") > 0);
- assert(libsimple_strcmpnul("AA", "AA") == 0);
-
- assert(libsimple_strcasecmpnul(NULL, NULL) == 0);
- assert(libsimple_strcasecmpnul(NULL, "") < 0);
- assert(libsimple_strcasecmpnul("", NULL) > 0);
- assert(libsimple_strcasecmpnul("", "") == 0);
- assert(libsimple_strcasecmpnul(NULL, "x") < 0);
- assert(libsimple_strcasecmpnul("x", NULL) > 0);
- assert(libsimple_strcasecmpnul("x", "x") == 0);
- assert(libsimple_strcasecmpnul("a", "b") < 0);
- assert(libsimple_strcasecmpnul("b", "a") > 0);
- assert(libsimple_strcasecmpnul("aa", "ab") < 0);
- assert(libsimple_strcasecmpnul("ab", "aa") > 0);
- assert(libsimple_strcasecmpnul("aa", "aa") == 0);
- assert(libsimple_strcasecmpnul("A", "a") == 0);
- assert(libsimple_strcasecmpnul("a", "A") == 0);
- assert(libsimple_strcasecmpnul("AA", "Aa") == 0);
- assert(libsimple_strcasecmpnul("Aa", "AA") == 0);
- assert(libsimple_strcasecmpnul("AA", "AA") == 0);
-
- assert(libsimple_strncmpnul(NULL, NULL, 5) == 0);
- assert(libsimple_strncmpnul(NULL, "", 5) < 0);
- assert(libsimple_strncmpnul("", NULL, 5) > 0);
- assert(libsimple_strncmpnul("", "", 5) == 0);
- assert(libsimple_strncmpnul(NULL, "x", 5) < 0);
- assert(libsimple_strncmpnul("x", NULL, 5) > 0);
- assert(libsimple_strncmpnul("x", "x", 5) == 0);
- assert(libsimple_strncmpnul("a", "b", 5) < 0);
- assert(libsimple_strncmpnul("b", "a", 5) > 0);
- assert(libsimple_strncmpnul("aa", "ab", 5) < 0);
- assert(libsimple_strncmpnul("ab", "aa", 5) > 0);
- assert(libsimple_strncmpnul("aa", "aa", 5) == 0);
- assert(libsimple_strncmpnul("A", "a", 5) < 0);
- assert(libsimple_strncmpnul("a", "A", 5) > 0);
- assert(libsimple_strncmpnul("AA", "Aa", 5) < 0);
- assert(libsimple_strncmpnul("Aa", "AA", 5) > 0);
- assert(libsimple_strncmpnul("AA", "AA", 5) == 0);
- assert(libsimple_strncmpnul("aa", "ab", 1) == 0);
- assert(libsimple_strncmpnul("ab", "aa", 1) == 0);
- assert(libsimple_strncmpnul("aa", "aa", 1) == 0);
- assert(libsimple_strncmpnul("AA", "Aa", 1) == 0);
- assert(libsimple_strncmpnul("Aa", "AA", 1) == 0);
- assert(libsimple_strncmpnul("AA", "AA", 1) == 0);
- assert(libsimple_strncmpnul(NULL, NULL, 0) == 0);
- assert(libsimple_strncmpnul(NULL, "", 0) < 0);
- assert(libsimple_strncmpnul("", NULL, 0) > 0);
- assert(libsimple_strncmpnul("", "", 0) == 0);
- assert(libsimple_strncmpnul(NULL, "x", 0) < 0);
- assert(libsimple_strncmpnul("x", NULL, 0) > 0);
- assert(libsimple_strncmpnul("x", "x", 0) == 0);
- assert(libsimple_strncmpnul("a", "b", 0) == 0);
- assert(libsimple_strncmpnul("b", "a", 0) == 0);
- assert(libsimple_strncmpnul("aa", "ab", 0) == 0);
- assert(libsimple_strncmpnul("ab", "aa", 0) == 0);
- assert(libsimple_strncmpnul("aa", "aa", 0) == 0);
- assert(libsimple_strncmpnul("A", "a", 0) == 0);
- assert(libsimple_strncmpnul("a", "A", 0) == 0);
- assert(libsimple_strncmpnul("AA", "Aa", 0) == 0);
- assert(libsimple_strncmpnul("Aa", "AA", 0) == 0);
- assert(libsimple_strncmpnul("AA", "AA", 0) == 0);
-
- assert(libsimple_strncasecmpnul(NULL, NULL, 5) == 0);
- assert(libsimple_strncasecmpnul(NULL, "", 5) < 0);
- assert(libsimple_strncasecmpnul("", NULL, 5) > 0);
- assert(libsimple_strncasecmpnul("", "", 5) == 0);
- assert(libsimple_strncasecmpnul(NULL, "x", 5) < 0);
- assert(libsimple_strncasecmpnul("x", NULL, 5) > 0);
- assert(libsimple_strncasecmpnul("x", "x", 5) == 0);
- assert(libsimple_strncasecmpnul("a", "b", 5) < 0);
- assert(libsimple_strncasecmpnul("b", "a", 5) > 0);
- assert(libsimple_strncasecmpnul("aa", "ab", 5) < 0);
- assert(libsimple_strncasecmpnul("ab", "aa", 5) > 0);
- assert(libsimple_strncasecmpnul("aa", "aa", 5) == 0);
- assert(libsimple_strncasecmpnul("A", "a", 5) == 0);
- assert(libsimple_strncasecmpnul("a", "A", 5) == 0);
- assert(libsimple_strncasecmpnul("AA", "Aa", 5) == 0);
- assert(libsimple_strncasecmpnul("Aa", "AA", 5) == 0);
- assert(libsimple_strncasecmpnul("AA", "AA", 5) == 0);
- assert(libsimple_strncasecmpnul("aa", "ab", 1) == 0);
- assert(libsimple_strncasecmpnul("ab", "aa", 1) == 0);
- assert(libsimple_strncasecmpnul("aa", "aa", 1) == 0);
- assert(libsimple_strncasecmpnul("AA", "Aa", 1) == 0);
- assert(libsimple_strncasecmpnul("Aa", "AA", 1) == 0);
- assert(libsimple_strncasecmpnul("AA", "AA", 1) == 0);
- assert(libsimple_strncasecmpnul(NULL, NULL, 0) == 0);
- assert(libsimple_strncasecmpnul(NULL, "", 0) < 0);
- assert(libsimple_strncasecmpnul("", NULL, 0) > 0);
- assert(libsimple_strncasecmpnul("", "", 0) == 0);
- assert(libsimple_strncasecmpnul(NULL, "x", 0) < 0);
- assert(libsimple_strncasecmpnul("x", NULL, 0) > 0);
- assert(libsimple_strncasecmpnul("x", "x", 0) == 0);
- assert(libsimple_strncasecmpnul("a", "b", 0) == 0);
- assert(libsimple_strncasecmpnul("b", "a", 0) == 0);
- assert(libsimple_strncasecmpnul("aa", "ab", 0) == 0);
- assert(libsimple_strncasecmpnul("ab", "aa", 0) == 0);
- assert(libsimple_strncasecmpnul("aa", "aa", 0) == 0);
- assert(libsimple_strncasecmpnul("A", "a", 0) == 0);
- assert(libsimple_strncasecmpnul("a", "A", 0) == 0);
- assert(libsimple_strncasecmpnul("AA", "Aa", 0) == 0);
- assert(libsimple_strncasecmpnul("Aa", "AA", 0) == 0);
- assert(libsimple_strncasecmpnul("AA", "AA", 0) == 0);
-
#ifdef libsimple_strdupa
cs = "";
s = libsimple_strdupa(cs);
@@ -1524,456 +1188,6 @@ main(void)
fprintf(stderr, "warning: libsimple_vasprintfa missing\n");
#endif
- {
- char a[] = "abcdefgh", b[] = "abcdefgh";
- assert(libsimple_strreqlen("", "") == 0);
- assert(libsimple_strreqlen("x", "") == 0);
- assert(libsimple_strreqlen("x", "y") == 0);
- assert(libsimple_strreqlen("", "y") == 0);
- for (i = 0; i <= 8; i++) {
- for (j = 0; j <= 8; j++) {
- assert(libsimple_strreqlen(&a[i], &b[j]) == 8 - (i > j ? i : j));
- a[i] = b[j] = '\0';
- assert(libsimple_strreqlen(a, b) == (i == j ? i : 0));
- a[i] = "abcdefgh"[i];
- b[j] = "abcdefgh"[j];
- }
- }
- assert(libsimple_strreqlen("abc", "ABC") == 0);
- assert(libsimple_strreqlen("123", "123") == 3);
- }
-
- {
- char a[] = "abcdefgh", b[] = "ABCDEFGH";
- assert(libsimple_strrcaseeqlen("", "") == 0);
- assert(libsimple_strrcaseeqlen("x", "") == 0);
- assert(libsimple_strrcaseeqlen("x", "y") == 0);
- assert(libsimple_strrcaseeqlen("", "y") == 0);
- for (i = 0; i <= 8; i++) {
- for (j = 0; j <= 8; j++) {
- assert(libsimple_strrcaseeqlen(&a[i], &b[j]) == 8 - (i > j ? i : j));
- assert(libsimple_strrcaseeqlen(&b[i], &a[j]) == 8 - (i > j ? i : j));
- a[i] = b[j] = '\0';
- assert(libsimple_strrcaseeqlen(a, b) == (i == j ? i : 0));
- assert(libsimple_strrcaseeqlen(b, a) == (i == j ? i : 0));
- a[i] = "abcdefgh"[i];
- b[j] = "ABCDEFGH"[j];
- }
- }
- assert(libsimple_strrcaseeqlen("abc", "abc") == 3);
- assert(libsimple_strrcaseeqlen("123", "123") == 3);
- }
-
- for (n = 0; n < 10; n++) {
- char a[] = "abcdefgh", b[] = "abcdefgh";
- size_t I, J;
- assert(libsimple_strrneqlen("", "", n) == 0);
- assert(libsimple_strrneqlen("x", "", n) == 0);
- assert(libsimple_strrneqlen("x", "y", n) == 0);
- assert(libsimple_strrneqlen("", "y", n) == 0);
- for (i = 0; i <= 8; i++) {
- for (j = 0; j <= 8; j++) {
- I = 8 - i;
- J = 8 - j;
- assert(libsimple_strrneqlen(&a[i], &b[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
- a[i] = b[j] = '\0';
- assert(libsimple_strrneqlen(a, b, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
- a[i] = "abcdefgh"[i];
- b[j] = "abcdefgh"[j];
- }
- }
- assert(libsimple_strrneqlen("abc", "ABC", n) == 0);
- assert(libsimple_strrneqlen("123", "123", n) == MIN(3, n));
- }
-
- for (n = 0; n < 10; n++) {
- char a[] = "abcdefgh", b[] = "ABCDEFGH";
- size_t I, J;
- assert(libsimple_strrncaseeqlen("", "", n) == 0);
- assert(libsimple_strrncaseeqlen("x", "", n) == 0);
- assert(libsimple_strrncaseeqlen("x", "y", n) == 0);
- assert(libsimple_strrncaseeqlen("", "y", n) == 0);
- for (i = 0; i <= 8; i++) {
- for (j = 0; j <= 8; j++) {
- I = 8 - i;
- J = 8 - j;
- assert(libsimple_strrncaseeqlen(&a[i], &b[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
- assert(libsimple_strrncaseeqlen(&b[i], &a[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
- a[i] = b[j] = '\0';
- assert(libsimple_strrncaseeqlen(a, b, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
- assert(libsimple_strrncaseeqlen(b, a, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
- a[i] = "abcdefgh"[i];
- b[j] = "ABCDEFGH"[j];
- }
- }
- assert(libsimple_strrncaseeqlen("abc", "abc", n) == MIN(3, n));
- assert(libsimple_strrncaseeqlen("123", "123", n) == MIN(3, n));
- }
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strset(buf, 'x') == buf);
- assert(!strcmp(buf, "xxxxxxxxxxx"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strset(buf, '\0') == buf);
- assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpset(buf, 'x') == &buf[11]);
- assert(!strcmp(buf, "xxxxxxxxxxx"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpset(buf, '\0') == &buf[11]);
- assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnset(buf, 'x', SIZE_MAX) == buf);
- assert(!strcmp(buf, "xxxxxxxxxxx"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnset(buf, '\0', SIZE_MAX) == buf);
- assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpnset(buf, 'x', SIZE_MAX) == &buf[11]);
- assert(!strcmp(buf, "xxxxxxxxxxx"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpnset(buf, '\0', SIZE_MAX) == &buf[11]);
- assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnset(buf, 'x', 5) == buf);
- assert(!strcmp(buf, "xxxxx world"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnset(buf, '\0', 5) == buf);
- assert(!memcmp(buf, "\0\0\0\0\0 world\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpnset(buf, 'x', 5) == &buf[5]);
- assert(!strcmp(buf, "xxxxx world"));
- assert(!strcmp(&buf[12], "goodbye world"));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_stpnset(buf, '\0', 5) == &buf[5]);
- assert(!memcmp(buf, "\0\0\0\0\0 world\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strreplace(buf, 'o', 'x') == &buf[11]);
- assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
-
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', SIZE_MAX) == &buf[11]);
- assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', 12) == &buf[11]);
- assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', 11) == &buf[11]);
- assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', 6) == &buf[6]);
- assert(!memcmp(buf, "hellx world\0goodbye world", 26));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', 5) == &buf[5]);
- assert(!memcmp(buf, "hellx world\0goodbye world", 26));
-
- stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
- assert(libsimple_strnreplace(buf, 'o', 'x', 4) == &buf[4]);
- assert(!memcmp(buf, "hello world\0goodbye world", 26));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strmove(&buf[3], buf) == &buf[3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strmove(buf, &buf[3]) == buf);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strmove(buf, buf) == buf);
- assert(!strcmp(buf, "hello world"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(&buf[3], buf, SIZE_MAX) == &buf[3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, &buf[3], SIZE_MAX) == buf);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, buf, SIZE_MAX) == buf);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(&buf[3], buf, 12) == &buf[3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, &buf[3], 9) == buf);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, buf, 12) == buf);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(&buf[3], buf, 11) == &buf[3]);
- assert(!strncmp(buf, "helhello worldx", 15));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, &buf[3], 8) == buf);
- assert(!strcmp(buf, "lo worldrld"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, buf, 11) == buf);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(&buf[3], buf, 2) == &buf[3]);
- assert(!strcmp(buf, "helhe world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, &buf[3], 2) == buf);
- assert(!strcmp(buf, "lollo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_strnmove(buf, buf, 2) == buf);
- assert(!strcmp(buf, "hello world"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpmove(&buf[3], buf) == &buf[11 + 3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpmove(buf, &buf[3]) == &buf[11 - 3]);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpmove(buf, buf) == &buf[11]);
- assert(!strcmp(buf, "hello world"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(&buf[3], buf, SIZE_MAX) == &buf[11 + 3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, &buf[3], SIZE_MAX) == &buf[11 - 3]);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, buf, SIZE_MAX) == &buf[11]);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(&buf[3], buf, 12) == &buf[11 + 3]);
- assert(!strcmp(buf, "helhello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, &buf[3], 9) == &buf[11 - 3]);
- assert(!strcmp(buf, "lo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, buf, 12) == &buf[11]);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(&buf[3], buf, 11) == &buf[11 + 3]);
- assert(!strncmp(buf, "helhello worldx", 15));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, &buf[3], 8) == &buf[8]);
- assert(!strcmp(buf, "lo worldrld"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, buf, 11) == &buf[11]);
- assert(!strcmp(buf, "hello world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(&buf[3], buf, 2) == &buf[3 + 2]);
- assert(!strcmp(buf, "helhe world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, &buf[3], 2) == &buf[2]);
- assert(!strcmp(buf, "lollo world"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- strcpy(buf, "hello world");
- assert(libsimple_stpnmove(buf, buf, 2) == &buf[2]);
- assert(!strcmp(buf, "hello world"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strccpy(buf, "hello", '\0') == &buf[6]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strccpy(buf, "hello", 'o') == &buf[5]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strccpy(buf, "hello", 'l') == &buf[3]);
- assert(!strcmp(buf, "hel"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strccpy(buf, "hello", 'x') == NULL);
- assert(!strcmp(buf, "hello"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", '\0', 1024) == &buf[6]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'o', 1024) == &buf[5]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'l', 1024) == &buf[3]);
- assert(!strcmp(buf, "hel"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'x', 1024) == NULL);
- assert(!strcmp(buf, "hello"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", '\0', 6) == &buf[6]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'o', 6) == &buf[5]);
- assert(!strcmp(buf, "hello"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'l', 6) == &buf[3]);
- assert(!strcmp(buf, "hel"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'x', 6) == NULL);
- assert(!strcmp(buf, "hello"));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", '\0', 5) == NULL);
- assert(!strncmp(buf, "hellox", 6));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'o', 5) == &buf[5]);
- assert(!strncmp(buf, "hellox", 6));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'l', 5) == &buf[3]);
- assert(!strcmp(buf, "hel"));
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'x', 5) == NULL);
- assert(!strncmp(buf, "hellox", 6));
-
-
- memset(buf, 'x', sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- assert(libsimple_strnccpy(buf, "hello", 'o', 3) == NULL);
- assert(!strncmp(buf, "helx", 4));
-
if (!have_custom_malloc()) {
stderr_real = 1;
diff --git a/memisutf8.c b/memisutf8.c
index c7ffbd8..b477ab8 100644
--- a/memisutf8.c
+++ b/memisutf8.c
@@ -91,10 +91,6 @@ main(void)
assert(libsimple_memisutf8(STRING, sizeof(STRING) - 1, i) == (GOOD));\
assert(libsimple_memisutf8(STRING "\xFF", sizeof(STRING) - 1, i) == (GOOD));\
assert(libsimple_memisutf8(STRING "\x00", sizeof(STRING) - 1, i) == (GOOD));\
- assert(libsimple_strisutf8(STRING, i) == (GOOD));\
- assert(libsimple_strnisutf8(STRING, sizeof(STRING) - 1, i) == (GOOD));\
- assert(libsimple_strnisutf8(STRING "\xFF", sizeof(STRING) - 1, i) == (GOOD));\
- assert(libsimple_strnisutf8(STRING "\x00", sizeof(STRING) - 1, i) == (GOOD));\
} while (0)
int i;
diff --git a/stpmove.c b/stpmove.c
index 5457c21..e691c23 100644
--- a/stpmove.c
+++ b/stpmove.c
@@ -12,6 +12,26 @@ extern inline char *libsimple_stpmove(char *, const char *);
int
main(void)
{
+ char buf[1024];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpmove(&buf[3], buf) == &buf[11 + 3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpmove(buf, &buf[3]) == &buf[11 - 3]);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpmove(buf, buf) == &buf[11]);
+ assert(!strcmp(buf, "hello world"));
+
return 0;
}
diff --git a/stpnmove.c b/stpnmove.c
index 4f07cef..f96499e 100644
--- a/stpnmove.c
+++ b/stpnmove.c
@@ -12,6 +12,80 @@ extern inline char *libsimple_stpnmove(char *, const char *, size_t);
int
main(void)
{
+ char buf[1024];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(&buf[3], buf, SIZE_MAX) == &buf[11 + 3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, &buf[3], SIZE_MAX) == &buf[11 - 3]);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, buf, SIZE_MAX) == &buf[11]);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(&buf[3], buf, 12) == &buf[11 + 3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, &buf[3], 9) == &buf[11 - 3]);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, buf, 12) == &buf[11]);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(&buf[3], buf, 11) == &buf[11 + 3]);
+ assert(!strncmp(buf, "helhello worldx", 15));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, &buf[3], 8) == &buf[8]);
+ assert(!strcmp(buf, "lo worldrld"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, buf, 11) == &buf[11]);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(&buf[3], buf, 2) == &buf[3 + 2]);
+ assert(!strcmp(buf, "helhe world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, &buf[3], 2) == &buf[2]);
+ assert(!strcmp(buf, "lollo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_stpnmove(buf, buf, 2) == &buf[2]);
+ assert(!strcmp(buf, "hello world"));
+
return 0;
}
diff --git a/stpnset.c b/stpnset.c
index 59ce182..20da276 100644
--- a/stpnset.c
+++ b/stpnset.c
@@ -12,6 +12,27 @@ extern inline char *libsimple_stpnset(char *, int, size_t);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpnset(buf, 'x', SIZE_MAX) == &buf[11]);
+ assert(!strcmp(buf, "xxxxxxxxxxx"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpnset(buf, '\0', SIZE_MAX) == &buf[11]);
+ assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
+
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpnset(buf, 'x', 5) == &buf[5]);
+ assert(!strcmp(buf, "xxxxx world"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpnset(buf, '\0', 5) == &buf[5]);
+ assert(!memcmp(buf, "\0\0\0\0\0 world\0goodbye world", 26));
+
return 0;
}
diff --git a/stpntolower.c b/stpntolower.c
index 90e38d0..de4e74e 100644
--- a/stpntolower.c
+++ b/stpntolower.c
@@ -47,15 +47,6 @@ main(void)
stpcpy(buf, "ABCDEabcde12345");
assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], SIZE_MAX), ""));
assert(!strcmp(buf, "abcdeabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], SIZE_MAX), "abcdeabcde12345"));
- assert(!strcmp(buf, "ABCabcdeabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], SIZE_MAX), "deabcde12345"));
- assert(!strcmp(buf, "deabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], SIZE_MAX), "abcdeabcde12345"));
- assert(!strcmp(buf, "abcdeabcde12345"));
memset(buf, 0, sizeof(buf));
stpcpy(buf, "ABCDEabcde12345");
@@ -70,19 +61,6 @@ main(void)
stpcpy(buf, "ABCDEabcde12345X");
assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], 15), "X"));
assert(!strcmp(buf, "abcdeabcde12345X"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345");
- buf[18] = 'X';
- assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 15), "abcdeabcde12345X"));
- assert(!strcmp(buf, "ABCabcdeabcde12345X"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 12), "deabcde12345345"));
- assert(!strcmp(buf, "deabcde12345345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345X");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 15), "abcdeabcde12345X"));
- assert(!strcmp(buf, "abcdeabcde12345X"));
memset(buf, 0, sizeof(buf));
stpcpy(buf, "ABCDEabcde12345");
@@ -96,18 +74,6 @@ main(void)
stpcpy(buf, "ABCDEabcde12345");
assert(!strcmpnul(libsimple_stpntolower(&buf[0], &buf[0], 0), "ABCDEabcde12345"));
assert(!strcmp(buf, "ABCDEabcde12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 0), "DEabcde12345"));
- assert(!strcmp(buf, "ABCDEabcde12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 0), "ABCDEabcde12345"));
- assert(!strcmp(buf, "ABCDEabcde12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 0), "ABCDEabcde12345"));
- assert(!strcmp(buf, "ABCDEabcde12345"));
return 0;
}
diff --git a/stpntoupper.c b/stpntoupper.c
index 732a9d3..40552d7 100644
--- a/stpntoupper.c
+++ b/stpntoupper.c
@@ -47,15 +47,6 @@ main(void)
stpcpy(buf, "abcdeABCDE12345");
assert(!strcmpnul(libsimple_stpntoupper(&buf[0], &buf[0], SIZE_MAX), ""));
assert(!strcmp(buf, "ABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], SIZE_MAX), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "abcABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], SIZE_MAX), "DEABCDE12345"));
- assert(!strcmp(buf, "DEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], SIZE_MAX), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "ABCDEABCDE12345"));
memset(buf, 0, sizeof(buf));
stpcpy(buf, "abcdeABCDE12345");
@@ -70,19 +61,6 @@ main(void)
stpcpy(buf, "abcdeABCDE12345x");
assert(!strcmpnul(libsimple_stpntoupper(&buf[0], &buf[0], 15), "x"));
assert(!strcmp(buf, "ABCDEABCDE12345x"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345");
- buf[18] = 'x';
- assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], 15), "ABCDEABCDE12345x"));
- assert(!strcmp(buf, "abcABCDEABCDE12345x"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], 12), "DEABCDE12345345"));
- assert(!strcmp(buf, "DEABCDE12345345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345x");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], 15), "ABCDEABCDE12345x"));
- assert(!strcmp(buf, "ABCDEABCDE12345x"));
memset(buf, 0, sizeof(buf));
stpcpy(buf, "abcdeABCDE12345");
@@ -96,18 +74,6 @@ main(void)
stpcpy(buf, "abcdeABCDE12345");
assert(!strcmpnul(libsimple_stpntoupper(&buf[0], &buf[0], 0), "abcdeABCDE12345"));
assert(!strcmp(buf, "abcdeABCDE12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], 0), "deABCDE12345"));
- assert(!strcmp(buf, "abcdeABCDE12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], 0), "abcdeABCDE12345"));
- assert(!strcmp(buf, "abcdeABCDE12345"));
- memset(buf, 0, sizeof(buf));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], 0), "abcdeABCDE12345"));
- assert(!strcmp(buf, "abcdeABCDE12345"));
return 0;
}
diff --git a/stpset.c b/stpset.c
index 4e5c134..08651fa 100644
--- a/stpset.c
+++ b/stpset.c
@@ -12,6 +12,17 @@ extern inline char *libsimple_stpset(char *, int);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpset(buf, 'x') == &buf[11]);
+ assert(!strcmp(buf, "xxxxxxxxxxx"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_stpset(buf, '\0') == &buf[11]);
+ assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
+
return 0;
}
diff --git a/stptolower.c b/stptolower.c
index 7c21372..db63bf0 100644
--- a/stptolower.c
+++ b/stptolower.c
@@ -45,15 +45,6 @@ main(void)
stpcpy(buf, "ABCDEabcde12345");
assert(!strcmpnul(libsimple_stptolower(&buf[0], &buf[0]), ""));
assert(!strcmp(buf, "abcdeabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strtolower(&buf[3], &buf[0]), "abcdeabcde12345"));
- assert(!strcmp(buf, "ABCabcdeabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strtolower(&buf[0], &buf[3]), "deabcde12345"));
- assert(!strcmp(buf, "deabcde12345"));
- stpcpy(buf, "ABCDEabcde12345");
- assert(!strcmpnul(libsimple_strtolower(&buf[0], &buf[0]), "abcdeabcde12345"));
- assert(!strcmp(buf, "abcdeabcde12345"));
return 0;
}
diff --git a/stptoupper.c b/stptoupper.c
index 3b5f008..cbfc184 100644
--- a/stptoupper.c
+++ b/stptoupper.c
@@ -45,15 +45,6 @@ main(void)
stpcpy(buf, "abcdeABCDE12345");
assert(!strcmpnul(libsimple_stptoupper(&buf[0], &buf[0]), ""));
assert(!strcmp(buf, "ABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strtoupper(&buf[3], &buf[0]), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "abcABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strtoupper(&buf[0], &buf[3]), "DEABCDE12345"));
- assert(!strcmp(buf, "DEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_strtoupper(&buf[0], &buf[0]), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "ABCDEABCDE12345"));
return 0;
}
diff --git a/strcasecmpnul.c b/strcasecmpnul.c
index b6a9b7a..e996e01 100644
--- a/strcasecmpnul.c
+++ b/strcasecmpnul.c
@@ -12,6 +12,23 @@ extern inline int libsimple_strcasecmpnul(const char *, const char *);
int
main(void)
{
+ assert(libsimple_strcasecmpnul(NULL, NULL) == 0);
+ assert(libsimple_strcasecmpnul(NULL, "") < 0);
+ assert(libsimple_strcasecmpnul("", NULL) > 0);
+ assert(libsimple_strcasecmpnul("", "") == 0);
+ assert(libsimple_strcasecmpnul(NULL, "x") < 0);
+ assert(libsimple_strcasecmpnul("x", NULL) > 0);
+ assert(libsimple_strcasecmpnul("x", "x") == 0);
+ assert(libsimple_strcasecmpnul("a", "b") < 0);
+ assert(libsimple_strcasecmpnul("b", "a") > 0);
+ assert(libsimple_strcasecmpnul("aa", "ab") < 0);
+ assert(libsimple_strcasecmpnul("ab", "aa") > 0);
+ assert(libsimple_strcasecmpnul("aa", "aa") == 0);
+ assert(libsimple_strcasecmpnul("A", "a") == 0);
+ assert(libsimple_strcasecmpnul("a", "A") == 0);
+ assert(libsimple_strcasecmpnul("AA", "Aa") == 0);
+ assert(libsimple_strcasecmpnul("Aa", "AA") == 0);
+ assert(libsimple_strcasecmpnul("AA", "AA") == 0);
return 0;
}
diff --git a/strcaseeq.c b/strcaseeq.c
index 778c5b0..52e654c 100644
--- a/strcaseeq.c
+++ b/strcaseeq.c
@@ -12,6 +12,16 @@ extern inline int libsimple_strcaseeq(const char *, const char *);
int
main(void)
{
+ assert(libsimple_strcaseeq("abc", "abc") == 1);
+ assert(libsimple_strcaseeq("abc", "ab") == 0);
+ assert(libsimple_strcaseeq("ab", "abc") == 0);
+ assert(libsimple_strcaseeq("ab", "xy") == 0);
+ assert(libsimple_strcaseeq("xy", "ab") == 0);
+ assert(libsimple_strcaseeq("", "1") == 0);
+ assert(libsimple_strcaseeq("1", "") == 0);
+ assert(libsimple_strcaseeq("", "") == 1);
+ assert(libsimple_strcaseeq("abc", "ABC") == 1);
+ assert(libsimple_strcaseeq("ABC", "abc") == 1);
return 0;
}
diff --git a/strcaseeqnul.c b/strcaseeqnul.c
index a40aaf7..bd900d6 100644
--- a/strcaseeqnul.c
+++ b/strcaseeqnul.c
@@ -12,6 +12,21 @@ extern inline int libsimple_strcaseeqnul(const char *, const char *);
int
main(void)
{
+ assert(libsimple_strcaseeqnul("abc", "abc") == 1);
+ assert(libsimple_strcaseeqnul("abc", "ab") == 0);
+ assert(libsimple_strcaseeqnul("ab", "abc") == 0);
+ assert(libsimple_strcaseeqnul("ab", "xy") == 0);
+ assert(libsimple_strcaseeqnul("xy", "ab") == 0);
+ assert(libsimple_strcaseeqnul("", "1") == 0);
+ assert(libsimple_strcaseeqnul("1", "") == 0);
+ assert(libsimple_strcaseeqnul("", "") == 1);
+ assert(libsimple_strcaseeqnul("abc", "ABC") == 1);
+ assert(libsimple_strcaseeqnul("ABC", "abc") == 1);
+ assert(libsimple_strcaseeqnul("", NULL) == 0);
+ assert(libsimple_strcaseeqnul("1", NULL) == 0);
+ assert(libsimple_strcaseeqnul(NULL, "") == 0);
+ assert(libsimple_strcaseeqnul(NULL, "1") == 0);
+ assert(libsimple_strcaseeqnul(NULL, NULL) == 1);
return 0;
}
diff --git a/strcasestarts.c b/strcasestarts.c
index 7262f1e..df1fae3 100644
--- a/strcasestarts.c
+++ b/strcasestarts.c
@@ -3,7 +3,7 @@
#ifndef TEST
-extern inline int libsimple_strcasestarts(const char *, const char *);
+extern inline int libsimple_strcasestarts(const char *, const char *); /* TODO test */
#else
diff --git a/strccpy.c b/strccpy.c
index f4f7630..613ffbe 100644
--- a/strccpy.c
+++ b/strccpy.c
@@ -12,6 +12,28 @@ extern inline char *libsimple_strccpy(char *restrict, const char *restrict, int)
int
main(void)
{
+ char buf[100];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strccpy(buf, "hello", '\0') == &buf[6]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strccpy(buf, "hello", 'o') == &buf[5]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strccpy(buf, "hello", 'l') == &buf[3]);
+ assert(!strcmp(buf, "hel"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strccpy(buf, "hello", 'x') == NULL);
+ assert(!strcmp(buf, "hello"));
+
return 0;
}
diff --git a/strcmpnul.c b/strcmpnul.c
index 0a70610..d3d57fa 100644
--- a/strcmpnul.c
+++ b/strcmpnul.c
@@ -12,6 +12,23 @@ extern inline int libsimple_strcmpnul(const char *, const char *);
int
main(void)
{
+ assert(libsimple_strcmpnul(NULL, NULL) == 0);
+ assert(libsimple_strcmpnul(NULL, "") < 0);
+ assert(libsimple_strcmpnul("", NULL) > 0);
+ assert(libsimple_strcmpnul("", "") == 0);
+ assert(libsimple_strcmpnul(NULL, "x") < 0);
+ assert(libsimple_strcmpnul("x", NULL) > 0);
+ assert(libsimple_strcmpnul("x", "x") == 0);
+ assert(libsimple_strcmpnul("a", "b") < 0);
+ assert(libsimple_strcmpnul("b", "a") > 0);
+ assert(libsimple_strcmpnul("aa", "ab") < 0);
+ assert(libsimple_strcmpnul("ab", "aa") > 0);
+ assert(libsimple_strcmpnul("aa", "aa") == 0);
+ assert(libsimple_strcmpnul("A", "a") < 0);
+ assert(libsimple_strcmpnul("a", "A") > 0);
+ assert(libsimple_strcmpnul("AA", "Aa") < 0);
+ assert(libsimple_strcmpnul("Aa", "AA") > 0);
+ assert(libsimple_strcmpnul("AA", "AA") == 0);
return 0;
}
diff --git a/strend.c b/strend.c
index 4754daf..ff5fa34 100644
--- a/strend.c
+++ b/strend.c
@@ -12,6 +12,7 @@ extern inline char *libsimple_strend(const char *);
int
main(void)
{
+ assert(strcmpnul(libsimple_strend("abc\0xyz"), "xyz"));
return 0;
}
diff --git a/streq.c b/streq.c
index f54b8bb..2593238 100644
--- a/streq.c
+++ b/streq.c
@@ -12,6 +12,16 @@ extern inline int libsimple_streq(const char *, const char *);
int
main(void)
{
+ assert(libsimple_streq("abc", "abc") == 1);
+ assert(libsimple_streq("abc", "ab") == 0);
+ assert(libsimple_streq("ab", "abc") == 0);
+ assert(libsimple_streq("ab", "xy") == 0);
+ assert(libsimple_streq("xy", "ab") == 0);
+ assert(libsimple_streq("", "1") == 0);
+ assert(libsimple_streq("1", "") == 0);
+ assert(libsimple_streq("", "") == 1);
+ assert(libsimple_streq("abc", "ABC") == 0);
+ assert(libsimple_streq("ABC", "abc") == 0);
return 0;
}
diff --git a/streqnul.c b/streqnul.c
index b557a9a..adee9f8 100644
--- a/streqnul.c
+++ b/streqnul.c
@@ -12,6 +12,21 @@ extern inline int libsimple_streqnul(const char *, const char *);
int
main(void)
{
+ assert(libsimple_streqnul("abc", "abc") == 1);
+ assert(libsimple_streqnul("abc", "ab") == 0);
+ assert(libsimple_streqnul("ab", "abc") == 0);
+ assert(libsimple_streqnul("ab", "xy") == 0);
+ assert(libsimple_streqnul("xy", "ab") == 0);
+ assert(libsimple_streqnul("", "1") == 0);
+ assert(libsimple_streqnul("1", "") == 0);
+ assert(libsimple_streqnul("", "") == 1);
+ assert(libsimple_streqnul("abc", "ABC") == 0);
+ assert(libsimple_streqnul("ABC", "abc") == 0);
+ assert(libsimple_streqnul("", NULL) == 0);
+ assert(libsimple_streqnul("1", NULL) == 0);
+ assert(libsimple_streqnul(NULL, "") == 0);
+ assert(libsimple_streqnul(NULL, "1") == 0);
+ assert(libsimple_streqnul(NULL, NULL) == 1);
return 0;
}
diff --git a/strisutf8.c b/strisutf8.c
index ac0f4ca..c8244af 100644
--- a/strisutf8.c
+++ b/strisutf8.c
@@ -12,6 +12,62 @@ extern inline int libsimple_strisutf8(const char *, int);
int
main(void)
{
+#define ASSERT(STRING, GOOD)\
+ assert(libsimple_strisutf8(STRING, i) == (GOOD))
+
+ int i;
+ for (i = 0; i < 2; i++) {
+ ASSERT("", 1);
+ ASSERT("a", 1);
+ ASSERT("abc", 1);
+ ASSERT("123", 1);
+ ASSERT("åäö", 1);
+ ASSERT("𝖆𝖇𝖈", 1);
+ ASSERT("\x1b", 1);
+ ASSERT("\n\r\t\f", 1);
+ ASSERT("\xFF", 0);
+ ASSERT("\x01", 1);
+ ASSERT("\x7F", 1);
+ ASSERT("\x80", 0);
+ ASSERT("\xC0", 0);
+ ASSERT("\xC0\x80", i);
+ ASSERT("\xC0\x81", 0);
+ ASSERT("\xCF", 0);
+ ASSERT("\xEF", 0);
+ ASSERT("\xEF\x8F", 0);
+ ASSERT("\xF7", 0);
+ ASSERT("\xF7\x8F", 0);
+ ASSERT("\xF7\x8F\x8F", 0);
+ ASSERT("\xFA", 0);
+ ASSERT("\xFA\x8F", 0);
+ ASSERT("\xFA\x8F\x8F", 0);
+ ASSERT("\xFA\x8F\x8F\x8F", 0);
+ ASSERT("\xFD", 0);
+ ASSERT("\xFD\x8F", 0);
+ ASSERT("\xFD\x8F\x8F", 0);
+ ASSERT("\xFD\x8F\x8F\x8F", 0);
+ ASSERT("\xFD\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFE", 0);
+ ASSERT("\xFE\x8F", 0);
+ ASSERT("\xFE\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF", 0);
+ ASSERT("\xFF\x8F", 0);
+ ASSERT("\xFF\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xC1\x80", 0);
+ ASSERT("\xC2\x80", 1);
+ ASSERT("\xE1\x80\x80\x80", 0);
+ ASSERT("\xE1\x80\xC0\x80", 0);
+ ASSERT("\xE1\x80\x00\x80", 0);
+ ASSERT("\xF1\x80\x80\x80", 1);
+ ASSERT("\xFF\x80\x80\x80\x80\x80\x80\x80", 0);
+ }
return 0;
}
diff --git a/strmove.c b/strmove.c
index bd1f89f..bdf3803 100644
--- a/strmove.c
+++ b/strmove.c
@@ -12,6 +12,26 @@ extern inline char *libsimple_strmove(char *, const char *);
int
main(void)
{
+ char buf[1024];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strmove(&buf[3], buf) == &buf[3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strmove(buf, &buf[3]) == buf);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strmove(buf, buf) == buf);
+ assert(!strcmp(buf, "hello world"));
+
return 0;
}
diff --git a/strncasecmpnul.c b/strncasecmpnul.c
index e15bcfd..5df9e7d 100644
--- a/strncasecmpnul.c
+++ b/strncasecmpnul.c
@@ -12,6 +12,46 @@ extern inline int libsimple_strncasecmpnul(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strncasecmpnul(NULL, NULL, 5) == 0);
+ assert(libsimple_strncasecmpnul(NULL, "", 5) < 0);
+ assert(libsimple_strncasecmpnul("", NULL, 5) > 0);
+ assert(libsimple_strncasecmpnul("", "", 5) == 0);
+ assert(libsimple_strncasecmpnul(NULL, "x", 5) < 0);
+ assert(libsimple_strncasecmpnul("x", NULL, 5) > 0);
+ assert(libsimple_strncasecmpnul("x", "x", 5) == 0);
+ assert(libsimple_strncasecmpnul("a", "b", 5) < 0);
+ assert(libsimple_strncasecmpnul("b", "a", 5) > 0);
+ assert(libsimple_strncasecmpnul("aa", "ab", 5) < 0);
+ assert(libsimple_strncasecmpnul("ab", "aa", 5) > 0);
+ assert(libsimple_strncasecmpnul("aa", "aa", 5) == 0);
+ assert(libsimple_strncasecmpnul("A", "a", 5) == 0);
+ assert(libsimple_strncasecmpnul("a", "A", 5) == 0);
+ assert(libsimple_strncasecmpnul("AA", "Aa", 5) == 0);
+ assert(libsimple_strncasecmpnul("Aa", "AA", 5) == 0);
+ assert(libsimple_strncasecmpnul("AA", "AA", 5) == 0);
+ assert(libsimple_strncasecmpnul("aa", "ab", 1) == 0);
+ assert(libsimple_strncasecmpnul("ab", "aa", 1) == 0);
+ assert(libsimple_strncasecmpnul("aa", "aa", 1) == 0);
+ assert(libsimple_strncasecmpnul("AA", "Aa", 1) == 0);
+ assert(libsimple_strncasecmpnul("Aa", "AA", 1) == 0);
+ assert(libsimple_strncasecmpnul("AA", "AA", 1) == 0);
+ assert(libsimple_strncasecmpnul(NULL, NULL, 0) == 0);
+ assert(libsimple_strncasecmpnul(NULL, "", 0) < 0);
+ assert(libsimple_strncasecmpnul("", NULL, 0) > 0);
+ assert(libsimple_strncasecmpnul("", "", 0) == 0);
+ assert(libsimple_strncasecmpnul(NULL, "x", 0) < 0);
+ assert(libsimple_strncasecmpnul("x", NULL, 0) > 0);
+ assert(libsimple_strncasecmpnul("x", "x", 0) == 0);
+ assert(libsimple_strncasecmpnul("a", "b", 0) == 0);
+ assert(libsimple_strncasecmpnul("b", "a", 0) == 0);
+ assert(libsimple_strncasecmpnul("aa", "ab", 0) == 0);
+ assert(libsimple_strncasecmpnul("ab", "aa", 0) == 0);
+ assert(libsimple_strncasecmpnul("aa", "aa", 0) == 0);
+ assert(libsimple_strncasecmpnul("A", "a", 0) == 0);
+ assert(libsimple_strncasecmpnul("a", "A", 0) == 0);
+ assert(libsimple_strncasecmpnul("AA", "Aa", 0) == 0);
+ assert(libsimple_strncasecmpnul("Aa", "AA", 0) == 0);
+ assert(libsimple_strncasecmpnul("AA", "AA", 0) == 0);
return 0;
}
diff --git a/strncaseeq.c b/strncaseeq.c
index 4cec369..a0bfb02 100644
--- a/strncaseeq.c
+++ b/strncaseeq.c
@@ -12,6 +12,36 @@ extern inline int libsimple_strncaseeq(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strncaseeq("abc", "abc", 5) == 1);
+ assert(libsimple_strncaseeq("abc", "ab", 5) == 0);
+ assert(libsimple_strncaseeq("ab", "abc", 5) == 0);
+ assert(libsimple_strncaseeq("ab", "xy", 5) == 0);
+ assert(libsimple_strncaseeq("xy", "ab", 5) == 0);
+ assert(libsimple_strncaseeq("", "1", 5) == 0);
+ assert(libsimple_strncaseeq("1", "", 5) == 0);
+ assert(libsimple_strncaseeq("", "", 5) == 1);
+ assert(libsimple_strncaseeq("abc", "ABC", 5) == 1);
+ assert(libsimple_strncaseeq("ABC", "abc", 5) == 1);
+ assert(libsimple_strncaseeq("abc", "abc", 1) == 1);
+ assert(libsimple_strncaseeq("abc", "ab", 1) == 1);
+ assert(libsimple_strncaseeq("ab", "abc", 1) == 1);
+ assert(libsimple_strncaseeq("ab", "xy", 1) == 0);
+ assert(libsimple_strncaseeq("xy", "ab", 1) == 0);
+ assert(libsimple_strncaseeq("", "1", 1) == 0);
+ assert(libsimple_strncaseeq("1", "", 1) == 0);
+ assert(libsimple_strncaseeq("", "", 1) == 1);
+ assert(libsimple_strncaseeq("abc", "ABC", 1) == 1);
+ assert(libsimple_strncaseeq("ABC", "abc", 1) == 1);
+ assert(libsimple_strncaseeq("abc", "abc", 0) == 1);
+ assert(libsimple_strncaseeq("abc", "ab", 0) == 1);
+ assert(libsimple_strncaseeq("ab", "abc", 0) == 1);
+ assert(libsimple_strncaseeq("ab", "xy", 0) == 1);
+ assert(libsimple_strncaseeq("xy", "ab", 0) == 1);
+ assert(libsimple_strncaseeq("", "1", 0) == 1);
+ assert(libsimple_strncaseeq("1", "", 0) == 1);
+ assert(libsimple_strncaseeq("", "", 0) == 1);
+ assert(libsimple_strncaseeq("abc", "ABC", 0) == 1);
+ assert(libsimple_strncaseeq("ABC", "abc", 0) == 1);
return 0;
}
diff --git a/strncaseeqnul.c b/strncaseeqnul.c
index 6a4c42e..a8c5e01 100644
--- a/strncaseeqnul.c
+++ b/strncaseeqnul.c
@@ -12,6 +12,51 @@ extern inline int libsimple_strncaseeqnul(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strncaseeqnul("abc", "abc", 5) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ab", 5) == 0);
+ assert(libsimple_strncaseeqnul("ab", "abc", 5) == 0);
+ assert(libsimple_strncaseeqnul("ab", "xy", 5) == 0);
+ assert(libsimple_strncaseeqnul("xy", "ab", 5) == 0);
+ assert(libsimple_strncaseeqnul("", "1", 5) == 0);
+ assert(libsimple_strncaseeqnul("1", "", 5) == 0);
+ assert(libsimple_strncaseeqnul("", "", 5) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ABC", 5) == 1);
+ assert(libsimple_strncaseeqnul("ABC", "abc", 5) == 1);
+ assert(libsimple_strncaseeqnul("", NULL, 5) == 0);
+ assert(libsimple_strncaseeqnul("1", NULL, 5) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "", 5) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "1", 5) == 0);
+ assert(libsimple_strncaseeqnul(NULL, NULL, 5) == 1);
+ assert(libsimple_strncaseeqnul("abc", "abc", 1) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ab", 1) == 1);
+ assert(libsimple_strncaseeqnul("ab", "abc", 1) == 1);
+ assert(libsimple_strncaseeqnul("ab", "xy", 1) == 0);
+ assert(libsimple_strncaseeqnul("xy", "ab", 1) == 0);
+ assert(libsimple_strncaseeqnul("", "1", 1) == 0);
+ assert(libsimple_strncaseeqnul("1", "", 1) == 0);
+ assert(libsimple_strncaseeqnul("", "", 1) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ABC", 1) == 1);
+ assert(libsimple_strncaseeqnul("ABC", "abc", 1) == 1);
+ assert(libsimple_strncaseeqnul("", NULL, 1) == 0);
+ assert(libsimple_strncaseeqnul("1", NULL, 1) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "", 1) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "1", 1) == 0);
+ assert(libsimple_strncaseeqnul(NULL, NULL, 1) == 1);
+ assert(libsimple_strncaseeqnul("abc", "abc", 0) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ab", 0) == 1);
+ assert(libsimple_strncaseeqnul("ab", "abc", 0) == 1);
+ assert(libsimple_strncaseeqnul("ab", "xy", 0) == 1);
+ assert(libsimple_strncaseeqnul("xy", "ab", 0) == 1);
+ assert(libsimple_strncaseeqnul("", "1", 0) == 1);
+ assert(libsimple_strncaseeqnul("1", "", 0) == 1);
+ assert(libsimple_strncaseeqnul("", "", 0) == 1);
+ assert(libsimple_strncaseeqnul("abc", "ABC", 0) == 1);
+ assert(libsimple_strncaseeqnul("ABC", "abc", 0) == 1);
+ assert(libsimple_strncaseeqnul("", NULL, 0) == 0);
+ assert(libsimple_strncaseeqnul("1", NULL, 0) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "", 0) == 0);
+ assert(libsimple_strncaseeqnul(NULL, "1", 0) == 0);
+ assert(libsimple_strncaseeqnul(NULL, NULL, 0) == 1);
return 0;
}
diff --git a/strnccpy.c b/strnccpy.c
index 3d91c08..176c8a0 100644
--- a/strnccpy.c
+++ b/strnccpy.c
@@ -12,6 +12,76 @@ extern inline char *libsimple_strnccpy(char *restrict, const char *restrict, int
int
main(void)
{
+ char buf[1024];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", '\0', 1024) == &buf[6]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'o', 1024) == &buf[5]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'l', 1024) == &buf[3]);
+ assert(!strcmp(buf, "hel"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'x', 1024) == NULL);
+ assert(!strcmp(buf, "hello"));
+
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", '\0', 6) == &buf[6]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'o', 6) == &buf[5]);
+ assert(!strcmp(buf, "hello"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'l', 6) == &buf[3]);
+ assert(!strcmp(buf, "hel"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'x', 6) == NULL);
+ assert(!strcmp(buf, "hello"));
+
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", '\0', 5) == NULL);
+ assert(!strncmp(buf, "hellox", 6));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'o', 5) == &buf[5]);
+ assert(!strncmp(buf, "hellox", 6));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'l', 5) == &buf[3]);
+ assert(!strcmp(buf, "hel"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'x', 5) == NULL);
+ assert(!strncmp(buf, "hellox", 6));
+
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ assert(libsimple_strnccpy(buf, "hello", 'o', 3) == NULL);
+ assert(!strncmp(buf, "helx", 4));
+
return 0;
}
diff --git a/strncmpnul.c b/strncmpnul.c
index a5c9d7a..25fd49b 100644
--- a/strncmpnul.c
+++ b/strncmpnul.c
@@ -12,6 +12,46 @@ extern inline int libsimple_strncmpnul(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strncmpnul(NULL, NULL, 5) == 0);
+ assert(libsimple_strncmpnul(NULL, "", 5) < 0);
+ assert(libsimple_strncmpnul("", NULL, 5) > 0);
+ assert(libsimple_strncmpnul("", "", 5) == 0);
+ assert(libsimple_strncmpnul(NULL, "x", 5) < 0);
+ assert(libsimple_strncmpnul("x", NULL, 5) > 0);
+ assert(libsimple_strncmpnul("x", "x", 5) == 0);
+ assert(libsimple_strncmpnul("a", "b", 5) < 0);
+ assert(libsimple_strncmpnul("b", "a", 5) > 0);
+ assert(libsimple_strncmpnul("aa", "ab", 5) < 0);
+ assert(libsimple_strncmpnul("ab", "aa", 5) > 0);
+ assert(libsimple_strncmpnul("aa", "aa", 5) == 0);
+ assert(libsimple_strncmpnul("A", "a", 5) < 0);
+ assert(libsimple_strncmpnul("a", "A", 5) > 0);
+ assert(libsimple_strncmpnul("AA", "Aa", 5) < 0);
+ assert(libsimple_strncmpnul("Aa", "AA", 5) > 0);
+ assert(libsimple_strncmpnul("AA", "AA", 5) == 0);
+ assert(libsimple_strncmpnul("aa", "ab", 1) == 0);
+ assert(libsimple_strncmpnul("ab", "aa", 1) == 0);
+ assert(libsimple_strncmpnul("aa", "aa", 1) == 0);
+ assert(libsimple_strncmpnul("AA", "Aa", 1) == 0);
+ assert(libsimple_strncmpnul("Aa", "AA", 1) == 0);
+ assert(libsimple_strncmpnul("AA", "AA", 1) == 0);
+ assert(libsimple_strncmpnul(NULL, NULL, 0) == 0);
+ assert(libsimple_strncmpnul(NULL, "", 0) < 0);
+ assert(libsimple_strncmpnul("", NULL, 0) > 0);
+ assert(libsimple_strncmpnul("", "", 0) == 0);
+ assert(libsimple_strncmpnul(NULL, "x", 0) < 0);
+ assert(libsimple_strncmpnul("x", NULL, 0) > 0);
+ assert(libsimple_strncmpnul("x", "x", 0) == 0);
+ assert(libsimple_strncmpnul("a", "b", 0) == 0);
+ assert(libsimple_strncmpnul("b", "a", 0) == 0);
+ assert(libsimple_strncmpnul("aa", "ab", 0) == 0);
+ assert(libsimple_strncmpnul("ab", "aa", 0) == 0);
+ assert(libsimple_strncmpnul("aa", "aa", 0) == 0);
+ assert(libsimple_strncmpnul("A", "a", 0) == 0);
+ assert(libsimple_strncmpnul("a", "A", 0) == 0);
+ assert(libsimple_strncmpnul("AA", "Aa", 0) == 0);
+ assert(libsimple_strncmpnul("Aa", "AA", 0) == 0);
+ assert(libsimple_strncmpnul("AA", "AA", 0) == 0);
return 0;
}
diff --git a/strneq.c b/strneq.c
index 6946bef..f5ae440 100644
--- a/strneq.c
+++ b/strneq.c
@@ -12,6 +12,36 @@ extern inline int libsimple_strneq(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strneq("abc", "abc", 5) == 1);
+ assert(libsimple_strneq("abc", "ab", 5) == 0);
+ assert(libsimple_strneq("ab", "abc", 5) == 0);
+ assert(libsimple_strneq("ab", "xy", 5) == 0);
+ assert(libsimple_strneq("xy", "ab", 5) == 0);
+ assert(libsimple_strneq("", "1", 5) == 0);
+ assert(libsimple_strneq("1", "", 5) == 0);
+ assert(libsimple_strneq("", "", 5) == 1);
+ assert(libsimple_strneq("abc", "ABC", 5) == 0);
+ assert(libsimple_strneq("ABC", "abc", 5) == 0);
+ assert(libsimple_strneq("abc", "abc", 1) == 1);
+ assert(libsimple_strneq("abc", "ab", 1) == 1);
+ assert(libsimple_strneq("ab", "abc", 1) == 1);
+ assert(libsimple_strneq("ab", "xy", 1) == 0);
+ assert(libsimple_strneq("xy", "ab", 1) == 0);
+ assert(libsimple_strneq("", "1", 1) == 0);
+ assert(libsimple_strneq("1", "", 1) == 0);
+ assert(libsimple_strneq("", "", 1) == 1);
+ assert(libsimple_strneq("abc", "ABC", 1) == 0);
+ assert(libsimple_strneq("ABC", "abc", 1) == 0);
+ assert(libsimple_strneq("abc", "abc", 0) == 1);
+ assert(libsimple_strneq("abc", "ab", 0) == 1);
+ assert(libsimple_strneq("ab", "abc", 0) == 1);
+ assert(libsimple_strneq("ab", "xy", 0) == 1);
+ assert(libsimple_strneq("xy", "ab", 0) == 1);
+ assert(libsimple_strneq("", "1", 0) == 1);
+ assert(libsimple_strneq("1", "", 0) == 1);
+ assert(libsimple_strneq("", "", 0) == 1);
+ assert(libsimple_strneq("abc", "ABC", 0) == 1);
+ assert(libsimple_strneq("ABC", "abc", 0) == 1);
return 0;
}
diff --git a/strneqnul.c b/strneqnul.c
index b21fbe2..066d4e7 100644
--- a/strneqnul.c
+++ b/strneqnul.c
@@ -12,6 +12,51 @@ extern inline int libsimple_strneqnul(const char *, const char *, size_t);
int
main(void)
{
+ assert(libsimple_strneqnul("abc", "abc", 5) == 1);
+ assert(libsimple_strneqnul("abc", "ab", 5) == 0);
+ assert(libsimple_strneqnul("ab", "abc", 5) == 0);
+ assert(libsimple_strneqnul("ab", "xy", 5) == 0);
+ assert(libsimple_strneqnul("xy", "ab", 5) == 0);
+ assert(libsimple_strneqnul("", "1", 5) == 0);
+ assert(libsimple_strneqnul("1", "", 5) == 0);
+ assert(libsimple_strneqnul("", "", 5) == 1);
+ assert(libsimple_strneqnul("abc", "ABC", 5) == 0);
+ assert(libsimple_strneqnul("ABC", "abc", 5) == 0);
+ assert(libsimple_strneqnul("", NULL, 5) == 0);
+ assert(libsimple_strneqnul("1", NULL, 5) == 0);
+ assert(libsimple_strneqnul(NULL, "", 5) == 0);
+ assert(libsimple_strneqnul(NULL, "1", 5) == 0);
+ assert(libsimple_strneqnul(NULL, NULL, 5) == 1);
+ assert(libsimple_strneqnul("abc", "abc", 1) == 1);
+ assert(libsimple_strneqnul("abc", "ab", 1) == 1);
+ assert(libsimple_strneqnul("ab", "abc", 1) == 1);
+ assert(libsimple_strneqnul("ab", "xy", 1) == 0);
+ assert(libsimple_strneqnul("xy", "ab", 1) == 0);
+ assert(libsimple_strneqnul("", "1", 1) == 0);
+ assert(libsimple_strneqnul("1", "", 1) == 0);
+ assert(libsimple_strneqnul("", "", 1) == 1);
+ assert(libsimple_strneqnul("abc", "ABC", 1) == 0);
+ assert(libsimple_strneqnul("ABC", "abc", 1) == 0);
+ assert(libsimple_strneqnul("", NULL, 1) == 0);
+ assert(libsimple_strneqnul("1", NULL, 1) == 0);
+ assert(libsimple_strneqnul(NULL, "", 1) == 0);
+ assert(libsimple_strneqnul(NULL, "1", 1) == 0);
+ assert(libsimple_strneqnul(NULL, NULL, 1) == 1);
+ assert(libsimple_strneqnul("abc", "abc", 0) == 1);
+ assert(libsimple_strneqnul("abc", "ab", 0) == 1);
+ assert(libsimple_strneqnul("ab", "abc", 0) == 1);
+ assert(libsimple_strneqnul("ab", "xy", 0) == 1);
+ assert(libsimple_strneqnul("xy", "ab", 0) == 1);
+ assert(libsimple_strneqnul("", "1", 0) == 1);
+ assert(libsimple_strneqnul("1", "", 0) == 1);
+ assert(libsimple_strneqnul("", "", 0) == 1);
+ assert(libsimple_strneqnul("abc", "ABC", 0) == 1);
+ assert(libsimple_strneqnul("ABC", "abc", 0) == 1);
+ assert(libsimple_strneqnul("", NULL, 0) == 0);
+ assert(libsimple_strneqnul("1", NULL, 0) == 0);
+ assert(libsimple_strneqnul(NULL, "", 0) == 0);
+ assert(libsimple_strneqnul(NULL, "1", 0) == 0);
+ assert(libsimple_strneqnul(NULL, NULL, 0) == 1);
return 0;
}
diff --git a/strnisutf8.c b/strnisutf8.c
index dc76fd5..8c775ee 100644
--- a/strnisutf8.c
+++ b/strnisutf8.c
@@ -12,6 +12,66 @@ extern inline int libsimple_strnisutf8(const char *, size_t, int);
int
main(void)
{
+#define ASSERT(STRING, GOOD)\
+ do {\
+ assert(libsimple_strnisutf8(STRING, sizeof(STRING) - 1, i) == (GOOD));\
+ assert(libsimple_strnisutf8(STRING "\xFF", sizeof(STRING) - 1, i) == (GOOD));\
+ assert(libsimple_strnisutf8(STRING "\x00", sizeof(STRING) - 1, i) == (GOOD));\
+ } while (0)
+
+ int i;
+ for (i = 0; i < 2; i++) {
+ ASSERT("", 1);
+ ASSERT("a", 1);
+ ASSERT("abc", 1);
+ ASSERT("123", 1);
+ ASSERT("åäö", 1);
+ ASSERT("𝖆𝖇𝖈", 1);
+ ASSERT("\x1b", 1);
+ ASSERT("\n\r\t\f", 1);
+ ASSERT("\xFF", 0);
+ ASSERT("\x01", 1);
+ ASSERT("\x7F", 1);
+ ASSERT("\x80", 0);
+ ASSERT("\xC0", 0);
+ ASSERT("\xC0\x80", i);
+ ASSERT("\xC0\x81", 0);
+ ASSERT("\xCF", 0);
+ ASSERT("\xEF", 0);
+ ASSERT("\xEF\x8F", 0);
+ ASSERT("\xF7", 0);
+ ASSERT("\xF7\x8F", 0);
+ ASSERT("\xF7\x8F\x8F", 0);
+ ASSERT("\xFA", 0);
+ ASSERT("\xFA\x8F", 0);
+ ASSERT("\xFA\x8F\x8F", 0);
+ ASSERT("\xFA\x8F\x8F\x8F", 0);
+ ASSERT("\xFD", 0);
+ ASSERT("\xFD\x8F", 0);
+ ASSERT("\xFD\x8F\x8F", 0);
+ ASSERT("\xFD\x8F\x8F\x8F", 0);
+ ASSERT("\xFD\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFE", 0);
+ ASSERT("\xFE\x8F", 0);
+ ASSERT("\xFE\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFE\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF", 0);
+ ASSERT("\xFF\x8F", 0);
+ ASSERT("\xFF\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F\x8F", 0);
+ ASSERT("\xC1\x80", 0);
+ ASSERT("\xC2\x80", 1);
+ ASSERT("\xE1\x80\x80\x80", 0);
+ ASSERT("\xE1\x80\xC0\x80", 0);
+ ASSERT("\xE1\x80\x00\x80", 0);
+ ASSERT("\xF1\x80\x80\x80", 1);
+ ASSERT("\xFF\x80\x80\x80\x80\x80\x80\x80", 0);
+ }
return 0;
}
diff --git a/strnmove.c b/strnmove.c
index d88c662..4bbcaa0 100644
--- a/strnmove.c
+++ b/strnmove.c
@@ -12,6 +12,80 @@ extern inline char *libsimple_strnmove(char *, const char *, size_t);
int
main(void)
{
+ char buf[1024];
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(&buf[3], buf, SIZE_MAX) == &buf[3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, &buf[3], SIZE_MAX) == buf);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, buf, SIZE_MAX) == buf);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(&buf[3], buf, 12) == &buf[3]);
+ assert(!strcmp(buf, "helhello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, &buf[3], 9) == buf);
+ assert(!strcmp(buf, "lo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, buf, 12) == buf);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(&buf[3], buf, 11) == &buf[3]);
+ assert(!strncmp(buf, "helhello worldx", 15));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, &buf[3], 8) == buf);
+ assert(!strcmp(buf, "lo worldrld"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, buf, 11) == buf);
+ assert(!strcmp(buf, "hello world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(&buf[3], buf, 2) == &buf[3]);
+ assert(!strcmp(buf, "helhe world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, &buf[3], 2) == buf);
+ assert(!strcmp(buf, "lollo world"));
+
+ memset(buf, 'x', sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ strcpy(buf, "hello world");
+ assert(libsimple_strnmove(buf, buf, 2) == buf);
+ assert(!strcmp(buf, "hello world"));
+
return 0;
}
diff --git a/strnreplace.c b/strnreplace.c
index f8a2036..eb26ec9 100644
--- a/strnreplace.c
+++ b/strnreplace.c
@@ -12,6 +12,32 @@ extern inline char *libsimple_strnreplace(char *, int, int, size_t);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', SIZE_MAX) == &buf[11]);
+ assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', 12) == &buf[11]);
+ assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', 11) == &buf[11]);
+ assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', 6) == &buf[6]);
+ assert(!memcmp(buf, "hellx world\0goodbye world", 26));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', 5) == &buf[5]);
+ assert(!memcmp(buf, "hellx world\0goodbye world", 26));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnreplace(buf, 'o', 'x', 4) == &buf[4]);
+ assert(!memcmp(buf, "hello world\0goodbye world", 26));
+
return 0;
}
diff --git a/strnset.c b/strnset.c
index 909222f..b2e1da4 100644
--- a/strnset.c
+++ b/strnset.c
@@ -12,6 +12,27 @@ extern inline char *libsimple_strnset(char *, int, size_t);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnset(buf, 'x', SIZE_MAX) == buf);
+ assert(!strcmp(buf, "xxxxxxxxxxx"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnset(buf, '\0', SIZE_MAX) == buf);
+ assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
+
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnset(buf, 'x', 5) == buf);
+ assert(!strcmp(buf, "xxxxx world"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strnset(buf, '\0', 5) == buf);
+ assert(!memcmp(buf, "\0\0\0\0\0 world\0goodbye world", 26));
+
return 0;
}
diff --git a/strntolower.c b/strntolower.c
index 0dcad2a..33fdfa1 100644
--- a/strntolower.c
+++ b/strntolower.c
@@ -12,6 +12,45 @@ extern inline char *libsimple_strntolower(char *, const char *, size_t);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], SIZE_MAX), "abcdeabcde12345"));
+ assert(!strcmp(buf, "ABCabcdeabcde12345"));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], SIZE_MAX), "deabcde12345"));
+ assert(!strcmp(buf, "deabcde12345"));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], SIZE_MAX), "abcdeabcde12345"));
+ assert(!strcmp(buf, "abcdeabcde12345"));
+
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345");
+ buf[18] = 'X';
+ assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 15), "abcdeabcde12345X"));
+ assert(!strcmp(buf, "ABCabcdeabcde12345X"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 12), "deabcde12345345"));
+ assert(!strcmp(buf, "deabcde12345345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345X");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 15), "abcdeabcde12345X"));
+ assert(!strcmp(buf, "abcdeabcde12345X"));
+
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[3], &buf[0], 0), "DEabcde12345"));
+ assert(!strcmp(buf, "ABCDEabcde12345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[3], 0), "ABCDEabcde12345"));
+ assert(!strcmp(buf, "ABCDEabcde12345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strntolower(&buf[0], &buf[0], 0), "ABCDEabcde12345"));
+ assert(!strcmp(buf, "ABCDEabcde12345"));
+
return 0;
}
diff --git a/strntoupper.c b/strntoupper.c
index 801a7f3..2959af8 100644
--- a/strntoupper.c
+++ b/strntoupper.c
@@ -12,6 +12,45 @@ extern inline char *libsimple_strntoupper(char *, const char *, size_t);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], SIZE_MAX), "ABCDEABCDE12345"));
+ assert(!strcmp(buf, "abcABCDEABCDE12345"));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], SIZE_MAX), "DEABCDE12345"));
+ assert(!strcmp(buf, "DEABCDE12345"));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], SIZE_MAX), "ABCDEABCDE12345"));
+ assert(!strcmp(buf, "ABCDEABCDE12345"));
+
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345");
+ buf[18] = 'x';
+ assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], 15), "ABCDEABCDE12345x"));
+ assert(!strcmp(buf, "abcABCDEABCDE12345x"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], 12), "DEABCDE12345345"));
+ assert(!strcmp(buf, "DEABCDE12345345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345x");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], 15), "ABCDEABCDE12345x"));
+ assert(!strcmp(buf, "ABCDEABCDE12345x"));
+
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[3], &buf[0], 0), "deABCDE12345"));
+ assert(!strcmp(buf, "abcdeABCDE12345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[3], 0), "abcdeABCDE12345"));
+ assert(!strcmp(buf, "abcdeABCDE12345"));
+ memset(buf, 0, sizeof(buf));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strntoupper(&buf[0], &buf[0], 0), "abcdeABCDE12345"));
+ assert(!strcmp(buf, "abcdeABCDE12345"));
+
return 0;
}
diff --git a/strrcaseeqlen.c b/strrcaseeqlen.c
index d5176a1..351eaa6 100644
--- a/strrcaseeqlen.c
+++ b/strrcaseeqlen.c
@@ -12,6 +12,27 @@ extern inline size_t libsimple_strrcaseeqlen(const char *, const char *);
int
main(void)
{
+ size_t i, j;
+ char a[] = "abcdefgh", b[] = "ABCDEFGH";
+
+ assert(libsimple_strrcaseeqlen("", "") == 0);
+ assert(libsimple_strrcaseeqlen("x", "") == 0);
+ assert(libsimple_strrcaseeqlen("x", "y") == 0);
+ assert(libsimple_strrcaseeqlen("", "y") == 0);
+ for (i = 0; i <= 8; i++) {
+ for (j = 0; j <= 8; j++) {
+ assert(libsimple_strrcaseeqlen(&a[i], &b[j]) == 8 - (i > j ? i : j));
+ assert(libsimple_strrcaseeqlen(&b[i], &a[j]) == 8 - (i > j ? i : j));
+ a[i] = b[j] = '\0';
+ assert(libsimple_strrcaseeqlen(a, b) == (i == j ? i : 0));
+ assert(libsimple_strrcaseeqlen(b, a) == (i == j ? i : 0));
+ a[i] = "abcdefgh"[i];
+ b[j] = "ABCDEFGH"[j];
+ }
+ }
+ assert(libsimple_strrcaseeqlen("abc", "abc") == 3);
+ assert(libsimple_strrcaseeqlen("123", "123") == 3);
+
return 0;
}
diff --git a/strreplace.c b/strreplace.c
index f32da11..e427d7f 100644
--- a/strreplace.c
+++ b/strreplace.c
@@ -12,6 +12,12 @@ extern inline char *libsimple_strreplace(char *, int, int);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strreplace(buf, 'o', 'x') == &buf[11]);
+ assert(!memcmp(buf, "hellx wxrld\0goodbye world", 26));
+
return 0;
}
diff --git a/strreqlen.c b/strreqlen.c
index 29f85fc..5c7cece 100644
--- a/strreqlen.c
+++ b/strreqlen.c
@@ -12,6 +12,25 @@ extern inline size_t libsimple_strreqlen(const char *, const char *);
int
main(void)
{
+ size_t i, j;
+ char a[] = "abcdefgh", b[] = "abcdefgh";
+
+ assert(libsimple_strreqlen("", "") == 0);
+ assert(libsimple_strreqlen("x", "") == 0);
+ assert(libsimple_strreqlen("x", "y") == 0);
+ assert(libsimple_strreqlen("", "y") == 0);
+ for (i = 0; i <= 8; i++) {
+ for (j = 0; j <= 8; j++) {
+ assert(libsimple_strreqlen(&a[i], &b[j]) == 8 - (i > j ? i : j));
+ a[i] = b[j] = '\0';
+ assert(libsimple_strreqlen(a, b) == (i == j ? i : 0));
+ a[i] = "abcdefgh"[i];
+ b[j] = "abcdefgh"[j];
+ }
+ }
+ assert(libsimple_strreqlen("abc", "ABC") == 0);
+ assert(libsimple_strreqlen("123", "123") == 3);
+
return 0;
}
diff --git a/strrncaseeqlen.c b/strrncaseeqlen.c
index 5963afc..d904577 100644
--- a/strrncaseeqlen.c
+++ b/strrncaseeqlen.c
@@ -12,6 +12,32 @@ extern inline size_t libsimple_strrncaseeqlen(const char *, const char *, size_t
int
main(void)
{
+ size_t i, j, n;
+
+ for (n = 0; n < 10; n++) {
+ char a[] = "abcdefgh", b[] = "ABCDEFGH";
+ size_t I, J;
+ assert(libsimple_strrncaseeqlen("", "", n) == 0);
+ assert(libsimple_strrncaseeqlen("x", "", n) == 0);
+ assert(libsimple_strrncaseeqlen("x", "y", n) == 0);
+ assert(libsimple_strrncaseeqlen("", "y", n) == 0);
+ for (i = 0; i <= 8; i++) {
+ for (j = 0; j <= 8; j++) {
+ I = 8 - i;
+ J = 8 - j;
+ assert(libsimple_strrncaseeqlen(&a[i], &b[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
+ assert(libsimple_strrncaseeqlen(&b[i], &a[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
+ a[i] = b[j] = '\0';
+ assert(libsimple_strrncaseeqlen(a, b, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
+ assert(libsimple_strrncaseeqlen(b, a, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
+ a[i] = "abcdefgh"[i];
+ b[j] = "ABCDEFGH"[j];
+ }
+ }
+ assert(libsimple_strrncaseeqlen("abc", "abc", n) == MIN(3, n));
+ assert(libsimple_strrncaseeqlen("123", "123", n) == MIN(3, n));
+ }
+
return 0;
}
diff --git a/strrneqlen.c b/strrneqlen.c
index b5f56b4..f76cac8 100644
--- a/strrneqlen.c
+++ b/strrneqlen.c
@@ -12,6 +12,30 @@ extern inline size_t libsimple_strrneqlen(const char *, const char *, size_t);
int
main(void)
{
+ size_t i, j, n;
+
+ for (n = 0; n < 10; n++) {
+ char a[] = "abcdefgh", b[] = "abcdefgh";
+ size_t I, J;
+ assert(libsimple_strrneqlen("", "", n) == 0);
+ assert(libsimple_strrneqlen("x", "", n) == 0);
+ assert(libsimple_strrneqlen("x", "y", n) == 0);
+ assert(libsimple_strrneqlen("", "y", n) == 0);
+ for (i = 0; i <= 8; i++) {
+ for (j = 0; j <= 8; j++) {
+ I = 8 - i;
+ J = 8 - j;
+ assert(libsimple_strrneqlen(&a[i], &b[j], n) == (I == J ? MIN(I,n) : MIN(I,J) * (n >= MAX(I,J))));
+ a[i] = b[j] = '\0';
+ assert(libsimple_strrneqlen(a, b, n) == (MIN(i, n) == MIN(j, n) ? MIN(i, n) : 0));
+ a[i] = "abcdefgh"[i];
+ b[j] = "abcdefgh"[j];
+ }
+ }
+ assert(libsimple_strrneqlen("abc", "ABC", n) == 0);
+ assert(libsimple_strrneqlen("123", "123", n) == MIN(3, n));
+ }
+
return 0;
}
diff --git a/strset.c b/strset.c
index 2c62c0d..8d92f31 100644
--- a/strset.c
+++ b/strset.c
@@ -12,6 +12,17 @@ extern inline char *libsimple_strset(char *, int);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strset(buf, 'x') == buf);
+ assert(!strcmp(buf, "xxxxxxxxxxx"));
+ assert(!strcmp(&buf[12], "goodbye world"));
+
+ stpcpy(mempcpy(buf, "hello world", 12), "goodbye world");
+ assert(libsimple_strset(buf, '\0') == buf);
+ assert(!memcmp(buf, "\0\0\0\0\0\0\0\0\0\0\0\0goodbye world", 26));
+
return 0;
}
diff --git a/strtolower.c b/strtolower.c
index 34006d7..7f72eb0 100644
--- a/strtolower.c
+++ b/strtolower.c
@@ -12,6 +12,18 @@ extern inline char *libsimple_strtolower(char *, const char *);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strtolower(&buf[3], &buf[0]), "abcdeabcde12345"));
+ assert(!strcmp(buf, "ABCabcdeabcde12345"));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strtolower(&buf[0], &buf[3]), "deabcde12345"));
+ assert(!strcmp(buf, "deabcde12345"));
+ stpcpy(buf, "ABCDEabcde12345");
+ assert(!strcmpnul(libsimple_strtolower(&buf[0], &buf[0]), "abcdeabcde12345"));
+ assert(!strcmp(buf, "abcdeabcde12345"));
+
return 0;
}
diff --git a/strtoupper.c b/strtoupper.c
index ce7c147..d22da79 100644
--- a/strtoupper.c
+++ b/strtoupper.c
@@ -12,6 +12,18 @@ extern inline char *libsimple_strtoupper(char *, const char *);
int
main(void)
{
+ char buf[100];
+
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strtoupper(&buf[3], &buf[0]), "ABCDEABCDE12345"));
+ assert(!strcmp(buf, "abcABCDEABCDE12345"));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strtoupper(&buf[0], &buf[3]), "DEABCDE12345"));
+ assert(!strcmp(buf, "DEABCDE12345"));
+ stpcpy(buf, "abcdeABCDE12345");
+ assert(!strcmpnul(libsimple_strtoupper(&buf[0], &buf[0]), "ABCDEABCDE12345"));
+ assert(!strcmp(buf, "ABCDEABCDE12345"));
+
return 0;
}
diff --git a/valigned_allocn.c b/valigned_allocn.c
index 0fa84ac..a3625b8 100644
--- a/valigned_allocn.c
+++ b/valigned_allocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_valigned_allocn(size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_aligned_allocn */
}
#endif
diff --git a/valigned_reallocfn.c b/valigned_reallocfn.c
index 3c116b4..f74b07d 100644
--- a/valigned_reallocfn.c
+++ b/valigned_reallocfn.c
@@ -3,7 +3,7 @@
#ifndef TEST
-extern inline void *libsimple_valigned_reallocfn(void *, size_t, size_t, va_list); /* TODO test (aligned_reallocfn) */
+extern inline void *libsimple_valigned_reallocfn(void *, size_t, size_t, va_list);
#else
@@ -12,7 +12,7 @@ extern inline void *libsimple_valigned_reallocfn(void *, size_t, size_t, va_list
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_aligned_reallocfn */
}
#endif
diff --git a/vcallocn.c b/vcallocn.c
index 7007739..ab3850c 100644
--- a/vcallocn.c
+++ b/vcallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_vcallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_callocn */
}
#endif
diff --git a/vmallocn.c b/vmallocn.c
index ab3a340..1cdb61b 100644
--- a/vmallocn.c
+++ b/vmallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_vmallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_mallocn */
}
#endif
diff --git a/vmemalignn.c b/vmemalignn.c
index f0eae81..1c75088 100644
--- a/vmemalignn.c
+++ b/vmemalignn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_vmemalignn(size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_memalignn */
}
#endif
diff --git a/vmemalignzn.c b/vmemalignzn.c
index 8ae1831..46cfc25 100644
--- a/vmemalignzn.c
+++ b/vmemalignzn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_vmemalignzn(int, size_t, size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_memalignzn */
}
#endif
diff --git a/vvallocn.c b/vvallocn.c
index 84c0ef7..04b8d55 100644
--- a/vvallocn.c
+++ b/vvallocn.c
@@ -12,7 +12,7 @@ extern inline void *libsimple_vvallocn(size_t, va_list);
int
main(void)
{
- return 0;
+ return 0; /* Tested via libsimple_vallocn */
}
#endif