aboutsummaryrefslogtreecommitdiffstats
path: root/strndup.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-19 13:23:21 +0200
committerMattias Andrée <maandree@kth.se>2018-08-19 13:23:21 +0200
commita405c151df74d4d3b4d06c38feff6458bef375a9 (patch)
tree7a06fe944e440134ab278623b909e73e9f83d3a7 /strndup.c
parentAdd str[r]n[case]str and str[n][case]cmpnul (diff)
downloadlibsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.gz
libsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.bz2
libsimple-a405c151df74d4d3b4d06c38feff6458bef375a9.tar.xz
Add str[n]caseeq[null] and some tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'strndup.c')
-rw-r--r--strndup.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/strndup.c b/strndup.c
index e2f144f..df2a69d 100644
--- a/strndup.c
+++ b/strndup.c
@@ -25,30 +25,30 @@ libsimple_strndup(const char *s, size_t n) /* FIXME */
#include "test.h"
int
-main(void)
+main(void) /* TODO valgrind */
{
const char *s = "test";
void *p;
p = libsimple_memdup(s, 5);
assert(p && p != s);
- assert(!strcmp(p, "test"));
+ assert(!strcmpnul(p, "test"));
memset(p, 0, 5);
- assert(!strcmp(s, "test"));
+ assert(!strcmpnul(s, "test"));
free(p);
p = libsimple_memdup(s, 3);
assert(p && p != s);
- assert(!strcmp(p, "tes"));
+ assert(!strcmpnul(p, "tes"));
memset(p, 0, 5);
- assert(!strcmp(s, "test"));
+ assert(!strcmpnul(s, "test"));
free(p);
p = libsimple_memdup(s, 0);
assert(p && p != s);
- assert(!strcmp(p, ""));
+ assert(!strcmpnul(p, ""));
memset(p, 0, 5);
- assert(!strcmp(s, "test"));
+ assert(!strcmpnul(s, "test"));
free(p);
return 0;