diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-25 23:01:22 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-25 23:01:22 +0200 |
commit | 6912e596b839e658aa83538731a91c726e5973f5 (patch) | |
tree | eca9ef0baa1454172d1a40775ba115629de63eb3 /strndup.c | |
parent | Add more tests (diff) | |
download | libsimple-6912e596b839e658aa83538731a91c726e5973f5.tar.gz libsimple-6912e596b839e658aa83538731a91c726e5973f5.tar.bz2 libsimple-6912e596b839e658aa83538731a91c726e5973f5.tar.xz |
Some fixes and more tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | strndup.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -4,7 +4,7 @@ char * -libsimple_strndup(const char *s, size_t n) /* FIXME */ +libsimple_strndup(const char *s, size_t n) { char *ret; size_t m = strlen(s); @@ -25,29 +25,29 @@ libsimple_strndup(const char *s, size_t n) /* FIXME */ #include "test.h" int -main(void) /* TODO valgrind */ +main(void) { const char *s = "test"; void *p; - p = libsimple_memdup(s, 5); + p = libsimple_strndup(s, 5); assert(p && p != s); assert(!strcmpnul(p, "test")); memset(p, 0, 5); assert(!strcmpnul(s, "test")); free(p); - p = libsimple_memdup(s, 3); + p = libsimple_strndup(s, 3); assert(p && p != s); assert(!strcmpnul(p, "tes")); - memset(p, 0, 5); + memset(p, 0, 4); assert(!strcmpnul(s, "test")); free(p); - p = libsimple_memdup(s, 0); + p = libsimple_strndup(s, 0); assert(p && p != s); assert(!strcmpnul(p, "")); - memset(p, 0, 5); + memset(p, 0, 1); assert(!strcmpnul(s, "test")); free(p); |