mirror of
https://github.com/curl/curl.git
synced 2026-08-26 09:53:32 +03:00
unit tests: use the unit test infrastructure better
Allow UNITTEST_STOP to return the error code, use the fail & abort macros to indicate test failure and return success instead of fail if the unit test can't test anything because of missing features at compile-time. A couple of tests could never fail because they were overriding the failure return code.
This commit is contained in:
parent
419a745da6
commit
a13ef31d0f
7 changed files with 60 additions and 79 deletions
|
|
@ -41,9 +41,6 @@ static void unit_stop(void)
|
|||
(!defined(HAVE_FSETXATTR) && \
|
||||
(!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
|
||||
UNITTEST_START
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#else
|
||||
|
||||
|
|
@ -68,7 +65,6 @@ static const struct checkthis tests[] = {
|
|||
UNITTEST_START
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
||||
for(i = 0; tests[i].input; i++) {
|
||||
const char *url = tests[i].input;
|
||||
|
|
@ -76,15 +72,10 @@ UNITTEST_START
|
|||
printf("Test %u got input \"%s\", output: \"%s\"\n",
|
||||
i, tests[i].input, stripped);
|
||||
|
||||
if(stripped && strcmp(tests[i].output, stripped)) {
|
||||
fprintf(stderr, "Test %u got input \"%s\", expected output \"%s\"\n"
|
||||
" Actual output: \"%s\"\n", i, tests[i].input, tests[i].output,
|
||||
stripped);
|
||||
rc++;
|
||||
}
|
||||
fail_if(stripped && strcmp(tests[i].output, stripped),
|
||||
tests[i].output);
|
||||
curl_free(stripped);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue