aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-12-10 17:14:46 +0100
committerMarkus Armbruster <armbru@redhat.com>2020-12-19 10:37:16 +0100
commit780df5d42befde9293cd667e1e237f26bcf37e94 (patch)
treee66da2ca158115b570b29df5fb28476f72f44f3a /tests
parent4aea88335d5c824b7b63b73c12830b5db558d463 (diff)
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')
-rw-r--r--tests/check-qjson.c47
1 files changed, 3 insertions, 44 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 8cb8a40524..98515b1fd6 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);