summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-09-11 10:18:30 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-09-11 10:25:49 +0200
commit7b1aea98a126e1a9f90afb7f1fb8ab0ebe2b6336 (patch)
tree2cfcf2e7b117545f4e846c5564d4c6618e85e241 /testsuite
parentrtemsbsd: remove dead code fb.c (diff)
downloadrtems-libbsd-7b1aea98a126e1a9f90afb7f1fb8ab0ebe2b6336.tar.bz2
Add wrapper for strndup()
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/program01/test_main.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/testsuite/program01/test_main.c b/testsuite/program01/test_main.c
index 3a200e62..7691b210 100644
--- a/testsuite/program01/test_main.c
+++ b/testsuite/program01/test_main.c
@@ -52,12 +52,13 @@
struct alloc_ctx {
enum alloc_type {
- ALLOC_MALLOC = 0,
- ALLOC_CALLOC = 1,
- ALLOC_REALLOC = 2,
- ALLOC_STRDUP = 3,
- ALLOC_ASPRINTF = 4,
- ALLOC_LAST = 5,
+ ALLOC_MALLOC,
+ ALLOC_CALLOC,
+ ALLOC_REALLOC,
+ ALLOC_STRDUP,
+ ALLOC_STRNDUP,
+ ALLOC_ASPRINTF,
+ ALLOC_LAST
} type;
unsigned free;
#define ALLOC_FREE_NONE 0x0
@@ -511,8 +512,25 @@ call_alloc(void *ctx)
break;
case ALLOC_STRDUP:
first = strdup(teststring);
+ assert(first != NULL);
+ assert(strcmp(first, teststring) == 0);
second = strdup(teststring);
+ assert(second != NULL);
+ assert(strcmp(second, teststring) == 0);
third = strdup(teststring);
+ assert(third != NULL);
+ assert(strcmp(third, teststring) == 0);
+ break;
+ case ALLOC_STRNDUP:
+ first = strndup(teststring, 1);
+ assert(first != NULL);
+ assert(strncmp(first, "t", 1) == 0);
+ second = strndup(teststring, 2);
+ assert(second != NULL);
+ assert(strncmp(second, "te", 2) == 0);
+ third = strndup(teststring, 4);
+ assert(third != NULL);
+ assert(strcmp(third, teststring) == 0);
break;
case ALLOC_ASPRINTF:
asprintf(&first, "a number %d", 0x123456);