X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrndup.c;h=15c44be27f23dc717acc718dd8dddb60f7e28bdf;hp=e50f419ded982705b0e9e5530299f080c0a40f54;hb=5b64e18a94a184cc73392d563a1f3e0dbd3bdbf8;hpb=219271fd548949abce8bd75c34dd42e519418fc4 diff --git a/functions/string/strndup.c b/functions/string/strndup.c index e50f419..15c44be 100644 --- a/functions/string/strndup.c +++ b/functions/string/strndup.c @@ -4,6 +4,10 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#ifdef REGTEST +#define _POSIX_C_SOURCE 200809L +#endif + #include #include @@ -37,16 +41,16 @@ int main( void ) const char *teststr2 = "\xFE\x8C\n"; char *testres, *testres2; - TESTCASE(testres = strndup(teststr, 5)); - TESTCASE(testres2 = strndup(teststr2, 1)); + TESTCASE((testres = strndup(teststr, 5)) != NULL); + TESTCASE((testres2 = strndup(teststr2, 1)) != NULL); TESTCASE(strcmp(testres, teststr) != 0); TESTCASE(strncmp(testres, teststr, 5) == 0); TESTCASE(strcmp(testres2, teststr2) != 0); TESTCASE(strncmp(testres2, teststr2, 1) == 0); free(testres); free(testres2); - TESTCASE(testres = strndup(teststr, 20)); - TESTCASE(testres2 = strndup(teststr2, 5)); + TESTCASE((testres = strndup(teststr, 20)) != NULL); + TESTCASE((testres2 = strndup(teststr2, 5)) != NULL); TESTCASE(strcmp(testres, teststr) == 0); TESTCASE(strcmp(testres2, teststr2) == 0); free(testres);