]> sigrok.org Git - libsigrok.git/blobdiff - tests/strutil.c
kingst-la2016: fix segfault that often occurs when a capture is aborted
[libsigrok.git] / tests / strutil.c
index 82856f1dd4a4d8e719bc0c5b5b9326fa6334a2a7..ec2233329b769c5eecc9597bdeb6d8e7564f4694 100644 (file)
@@ -125,6 +125,15 @@ static void test_rational(const char *input, struct sr_rational expected)
                    input, rational.p, rational.q);
 }
 
+static void test_rational_fail(const char *input)
+{
+       int ret;
+       struct sr_rational rational;
+
+       ret = sr_parse_rational(input, &rational);
+       fail_unless(ret != SR_OK, "Unexpected success for '%s'.", input);
+}
+
 static void test_voltage(uint64_t v_p, uint64_t v_q, const char *expected)
 {
        char *s;
@@ -145,7 +154,7 @@ START_TEST(test_locale)
        fprintf(stderr, "Old locale = %s\n", old_locale);
        /* Copy the name so it won’t be clobbered by setlocale. */
        saved_locale = g_strdup(old_locale);
-       ck_assert_msg(saved_locale != NULL);
+       ck_assert(saved_locale != NULL);
 
 #ifdef _WIN32
        /*
@@ -395,6 +404,9 @@ START_TEST(test_fractional)
        test_rational("-.1", (struct sr_rational){-1, 10});
        test_rational(" .1", (struct sr_rational){1, 10});
        test_rational("+.1", (struct sr_rational){1, 10});
+       test_rational_fail(".");
+       test_rational_fail(".e");
+       test_rational_fail(".e1");
 }
 END_TEST