From: Gerhard Sittig Date: Mon, 16 Jul 2018 19:00:06 +0000 (+0200) Subject: tests: echo text input when rational conversion fails X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=83a05ca9b3113b3c57658dead05a3bcd32713851;p=libsigrok.git tests: echo text input when rational conversion fails The previous implementation only echoed the p/q conversion results _if_ the return code signalled success but the result was unexpected. Although the errno value for failed conversion attempts (non-zero return codes) is not too helpful, seeing which text input failed the test is desirable. --- diff --git a/tests/strutil.c b/tests/strutil.c index e2a0a20a..14240f04 100644 --- a/tests/strutil.c +++ b/tests/strutil.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include "lib.h" @@ -117,7 +118,8 @@ static void test_rational(const char *input, struct sr_rational expected) struct sr_rational rational; ret = sr_parse_rational(input, &rational); - fail_unless(ret == SR_OK); + fail_unless(ret == SR_OK, "Unexpected rc for '%s': %d, errno %d.", + input, ret, errno); fail_unless((expected.p == rational.p) && (expected.q == rational.q), "Invalid result for '%s': %ld/%ld'.", input, rational.p, rational.q);