test-string-input-visitor: Add range overflow tests

Let's make sure that the range handling code can properly deal with
ranges that end at the biggest possible number.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20181121164421.20780-10-david@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
David Hildenbrand 2018-11-21 17:44:21 +01:00 committed by Markus Armbruster
parent cc871b1cdf
commit 345e4010c5

View File

@ -112,6 +112,7 @@ static void test_visitor_in_intList(TestInputVisitorData *data,
int64_t expect2[] = { 32767, -32768, -32767 }; int64_t expect2[] = { 32767, -32768, -32767 };
int64_t expect3[] = { INT64_MIN, INT64_MAX }; int64_t expect3[] = { INT64_MIN, INT64_MAX };
int64_t expect4[] = { 1 }; int64_t expect4[] = { 1 };
int64_t expect5[] = { INT64_MAX - 2, INT64_MAX - 1, INT64_MAX };
Error *err = NULL; Error *err = NULL;
int64List *res = NULL; int64List *res = NULL;
Visitor *v; Visitor *v;
@ -132,6 +133,10 @@ static void test_visitor_in_intList(TestInputVisitorData *data,
v = visitor_input_test_init(data, "1-1"); v = visitor_input_test_init(data, "1-1");
check_ilist(v, expect4, ARRAY_SIZE(expect4)); check_ilist(v, expect4, ARRAY_SIZE(expect4));
v = visitor_input_test_init(data,
"9223372036854775805-9223372036854775807");
check_ilist(v, expect5, ARRAY_SIZE(expect5));
/* Value too large */ /* Value too large */
v = visitor_input_test_init(data, "9223372036854775808"); v = visitor_input_test_init(data, "9223372036854775808");
@ -216,6 +221,7 @@ static void test_visitor_in_uintList(TestInputVisitorData *data,
uint64_t expect3[] = { INT64_MIN, INT64_MAX }; uint64_t expect3[] = { INT64_MIN, INT64_MAX };
uint64_t expect4[] = { 1 }; uint64_t expect4[] = { 1 };
uint64_t expect5[] = { UINT64_MAX }; uint64_t expect5[] = { UINT64_MAX };
uint64_t expect6[] = { UINT64_MAX - 2, UINT64_MAX - 1, UINT64_MAX };
Error *err = NULL; Error *err = NULL;
uint64List *res = NULL; uint64List *res = NULL;
Visitor *v; Visitor *v;
@ -239,6 +245,10 @@ static void test_visitor_in_uintList(TestInputVisitorData *data,
v = visitor_input_test_init(data, "18446744073709551615"); v = visitor_input_test_init(data, "18446744073709551615");
check_ulist(v, expect5, ARRAY_SIZE(expect5)); check_ulist(v, expect5, ARRAY_SIZE(expect5));
v = visitor_input_test_init(data,
"18446744073709551613-18446744073709551615");
check_ulist(v, expect6, ARRAY_SIZE(expect6));
/* Value too large */ /* Value too large */
v = visitor_input_test_init(data, "18446744073709551616"); v = visitor_input_test_init(data, "18446744073709551616");