From 90f33e5e86ae5a646ab828085cad14b012276634 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Fri, 1 Nov 2013 18:21:43 +0100 Subject: [PATCH] test: Simplify timeval2timestring() tests Note that we have to use xmlStrcmp() instead of TEST_STRING_DUPLICITY due to xhlChar*. --- test/offline/isds-timeval2timestring.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/offline/isds-timeval2timestring.c b/test/offline/isds-timeval2timestring.c index 8f4d12c..e900171 100644 --- a/test/offline/isds-timeval2timestring.c +++ b/test/offline/isds-timeval2timestring.c @@ -1,35 +1,36 @@ #include "../test.h" #include "isds.c" +static void test_destructor(void *argument) { + if (NULL != argument) zfree(*(void **)argument); +} + static int test_timeval2timestring(const struct timeval* time, const isds_error error, const xmlChar *correct_string, xmlChar **new_string) { isds_error err; err = timeval2timestring(time, new_string); - if (err != error) { - if (new_string) zfree(*new_string); + TEST_DESTRUCTOR(test_destructor, new_string); + + if (err != error) FAIL_TEST("timeval2timetring() returned unexpected code: " "expected=%s got=%s", isds_strerror(error), isds_strerror(err)); - } - if (err) { - if (new_string) zfree(*new_string); + if (err) + PASS_TEST; + + if (NULL == new_string) PASS_TEST; - } - if (!*new_string && !correct_string) + if (NULL == correct_string && NULL == *new_string) PASS_TEST; - if (!correct_string || !*new_string || - xmlStrcmp(correct_string, *new_string)) { - FAILURE_REASON("Wrong time string returned: expected=`%s', got=`%s'", + if (NULL == correct_string || NULL == *new_string || + xmlStrcmp(correct_string, *new_string)) + FAIL_TEST("Wrong time string returned: expected=`%s', got=`%s'", correct_string, *new_string); - if (new_string) zfree(*new_string); - return 1; - } - if (new_string) zfree(*new_string); PASS_TEST; } -- 2.11.4.GIT