diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-12-10 17:14:46 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-12-19 10:37:16 +0100 |
commit | 780df5d42befde9293cd667e1e237f26bcf37e94 (patch) | |
tree | e66da2ca158115b570b29df5fb28476f72f44f3a /tests/check-qjson.c | |
parent | 4aea88335d5c824b7b63b73c12830b5db558d463 (diff) | |
download | qemu-780df5d42befde9293cd667e1e237f26bcf37e94.zip qemu-780df5d42befde9293cd667e1e237f26bcf37e94.tar.gz qemu-780df5d42befde9293cd667e1e237f26bcf37e94.tar.bz2 |
tests/check-qjson: Replace redundant large_number()
Move one of large_number()'s three checks to uint_number(), and the
other two to float_number().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20201210161452.2813491-5-armbru@redhat.com>
Diffstat (limited to 'tests/check-qjson.c')
-rw-r--r-- | tests/check-qjson.c | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 8cb8a40..98515b1 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -844,6 +844,7 @@ static void uint_number(void) const char *reencoded; } test_cases[] = { { "9223372036854775808", (uint64_t)1 << 63 }, + { "18446744073709551615", UINT64_MAX }, {}, }; int i; @@ -872,49 +873,6 @@ static void uint_number(void) } } -static void large_number(void) -{ - const char *maxu64 = "18446744073709551615"; /* 2^64-1 */ - const char *gtu64 = "18446744073709551616"; /* 2^64 */ - const char *lti64 = "-9223372036854775809"; /* -2^63 - 1 */ - QNum *qnum; - QString *str; - uint64_t val; - int64_t ival; - - qnum = qobject_to(QNum, qobject_from_json(maxu64, &error_abort)); - g_assert(qnum); - g_assert_cmpuint(qnum_get_uint(qnum), ==, 18446744073709551615U); - g_assert(!qnum_get_try_int(qnum, &ival)); - - str = qobject_to_json(QOBJECT(qnum)); - g_assert_cmpstr(qstring_get_str(str), ==, maxu64); - qobject_unref(str); - qobject_unref(qnum); - - qnum = qobject_to(QNum, qobject_from_json(gtu64, &error_abort)); - g_assert(qnum); - g_assert_cmpfloat(qnum_get_double(qnum), ==, 18446744073709552e3); - g_assert(!qnum_get_try_uint(qnum, &val)); - g_assert(!qnum_get_try_int(qnum, &ival)); - - str = qobject_to_json(QOBJECT(qnum)); - g_assert_cmpstr(qstring_get_str(str), ==, gtu64); - qobject_unref(str); - qobject_unref(qnum); - - qnum = qobject_to(QNum, qobject_from_json(lti64, &error_abort)); - g_assert(qnum); - g_assert_cmpfloat(qnum_get_double(qnum), ==, -92233720368547758e2); - g_assert(!qnum_get_try_uint(qnum, &val)); - g_assert(!qnum_get_try_int(qnum, &ival)); - - str = qobject_to_json(QOBJECT(qnum)); - g_assert_cmpstr(qstring_get_str(str), ==, "-9223372036854775808"); - qobject_unref(str); - qobject_unref(qnum); -} - static void float_number(void) { struct { @@ -926,6 +884,8 @@ static void float_number(void) { "0.222", 0.222 }, { "-32.12313", -32.12313 }, { "-32.20e-10", -32.20e-10, "-0" /* BUG */ }, + { "18446744073709551616", 0x1p64 }, + { "-9223372036854775809", -0x1p63, "-9223372036854775808" }, {}, }; int i; @@ -1525,7 +1485,6 @@ int main(int argc, char **argv) g_test_add_func("/literals/number/int", int_number); g_test_add_func("/literals/number/uint", uint_number); - g_test_add_func("/literals/number/large", large_number); g_test_add_func("/literals/number/float", float_number); g_test_add_func("/literals/keyword", keyword_literal); |