]> sigrok.org Git - libsigrok.git/commitdiff
tests: echo text input when rational conversion fails
authorGerhard Sittig <redacted>
Mon, 16 Jul 2018 19:00:06 +0000 (21:00 +0200)
committerUwe Hermann <redacted>
Sun, 22 Jul 2018 14:36:15 +0000 (16:36 +0200)
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.

tests/strutil.c

index e2a0a20a86e3444007aeb2e5c310671c26900546..14240f049f1f4c181d74cbe820803cb7d2f00072 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <config.h>
 #include <check.h>
+#include <errno.h>
 #include <locale.h>
 #include <libsigrok/libsigrok.h>
 #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);