2017-10-04 00:19:51 +02:00
|
|
|
From 5483b85712ce2d049b26ce8bf78b790dc9c2c34d Mon Sep 17 00:00:00 2001
|
2017-03-15 20:38:55 +01:00
|
|
|
From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
|
|
|
|
Date: Thu, 24 Sep 2015 19:24:23 +0200
|
|
|
|
Subject: [PATCH] test-string-input-visitor: Add uint64 test
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Test parsing of decimal and hexadecimal uint64 numbers with most
|
|
|
|
significant bit set.
|
|
|
|
|
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
|
---
|
|
|
|
tests/test-string-input-visitor.c | 23 +++++++++++++++++++++++
|
|
|
|
1 file changed, 23 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
|
2017-05-05 17:05:43 +02:00
|
|
|
index e00194a649..558782796a 100644
|
2017-03-15 20:38:55 +01:00
|
|
|
--- a/tests/test-string-input-visitor.c
|
|
|
|
+++ b/tests/test-string-input-visitor.c
|
2017-03-29 06:22:10 +02:00
|
|
|
@@ -78,6 +78,27 @@ static void test_visitor_in_int(TestInputVisitorData *data,
|
2017-03-15 20:38:55 +01:00
|
|
|
error_free_or_abort(&err);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void test_visitor_in_uint64(TestInputVisitorData *data,
|
|
|
|
+ const void *unused)
|
|
|
|
+{
|
|
|
|
+ uint64_t res = 0, value = UINT64_MAX;
|
|
|
|
+ Error *err = NULL;
|
|
|
|
+ Visitor *v;
|
|
|
|
+
|
|
|
|
+ v = visitor_input_test_init(data, g_strdup_printf("%" PRIu64, value));
|
|
|
|
+
|
|
|
|
+ visit_type_uint64(v, NULL, &res, &err);
|
|
|
|
+ g_assert(!err);
|
|
|
|
+ g_assert_cmpint(res, ==, value);
|
|
|
|
+ visitor_input_teardown(data, unused);
|
|
|
|
+
|
|
|
|
+ v = visitor_input_test_init(data, g_strdup_printf("0x%" PRIx64, value));
|
|
|
|
+
|
|
|
|
+ visit_type_uint64(v, NULL, &res, &err);
|
|
|
|
+ g_assert(!err);
|
|
|
|
+ g_assert_cmpint(res, ==, value);
|
|
|
|
+}
|
|
|
|
+
|
2017-03-29 06:22:10 +02:00
|
|
|
static void check_ilist(Visitor *v, int64_t *expected, size_t n)
|
2017-03-15 20:38:55 +01:00
|
|
|
{
|
2017-03-29 06:22:10 +02:00
|
|
|
int64List *res = NULL;
|
|
|
|
@@ -364,6 +385,8 @@ int main(int argc, char **argv)
|
2017-03-15 20:38:55 +01:00
|
|
|
|
|
|
|
input_visitor_test_add("/string-visitor/input/int",
|
|
|
|
&in_visitor_data, test_visitor_in_int);
|
|
|
|
+ input_visitor_test_add("/string-visitor/input/uint64",
|
|
|
|
+ &in_visitor_data, test_visitor_in_uint64);
|
|
|
|
input_visitor_test_add("/string-visitor/input/intList",
|
|
|
|
&in_visitor_data, test_visitor_in_intList);
|
|
|
|
input_visitor_test_add("/string-visitor/input/bool",
|