diff mbox

[2/7] test-string-input-visitor: Add int test case

Message ID 1443184788-18859-3-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Sept. 25, 2015, 12:39 p.m. UTC
In addition to -42 also parse the maximum int64.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 tests/test-string-input-visitor.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Eric Blake Sept. 25, 2015, 2:50 p.m. UTC | #1
On 09/25/2015 06:39 AM, Andreas Färber wrote:
> In addition to -42 also parse the maximum int64.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  tests/test-string-input-visitor.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Shouldn't we also add tests of one-beyond-range, to have coverage of
expected error behavior when a number is too large in magnitude?
diff mbox

Patch

diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index 8e3433e..3c5c3d9 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -62,6 +62,14 @@  static void test_visitor_in_int(TestInputVisitorData *data,
     visit_type_int(v, &res, NULL, &err);
     g_assert(!err);
     g_assert_cmpint(res, ==, value);
+    visitor_input_teardown(data, unused);
+
+    value = INT64_MAX;
+    v = visitor_input_test_init(data, g_strdup_printf("%" PRId64, value));
+
+    visit_type_int(v, &res, NULL, &err);
+    g_assert(!err);
+    g_assert_cmpint(res, ==, value);
 }
 
 static void test_visitor_in_intList(TestInputVisitorData *data,