[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/10] tests/check-qjson: Replace redundant large_number()
From: |
Markus Armbruster |
Subject: |
[PATCH 04/10] tests/check-qjson: Replace redundant large_number() |
Date: |
Thu, 10 Dec 2020 17:14:46 +0100 |
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>
---
tests/check-qjson.c | 47 +++------------------------------------------
1 file 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);
--
2.26.2
- [PATCH 00/10] Fix floating-point -> text conversion precision, Markus Armbruster, 2020/12/10
- [PATCH 09/10] test-visitor-serialization: Drop insufficient precision workaround, Markus Armbruster, 2020/12/10
- [PATCH 05/10] tests/check-qnum: Cover qnum_to_string() for "unround" argument, Markus Armbruster, 2020/12/10
- [PATCH 03/10] tests/check-qjson: Cover number 2^63, Markus Armbruster, 2020/12/10
- [PATCH 07/10] test-string-output-visitor: Cover "unround" number, Markus Armbruster, 2020/12/10
- [PATCH 02/10] tests/check-qjson: Examine QNum more thoroughly, Markus Armbruster, 2020/12/10
- [PATCH 01/10] tests/check-qjson: Don't skip funny QNumber to JSON conversions, Markus Armbruster, 2020/12/10
- [PATCH 04/10] tests/check-qjson: Replace redundant large_number(),
Markus Armbruster <=
- [PATCH 10/10] test-visitor-serialization: Clean up test_primitives(), Markus Armbruster, 2020/12/10
- [PATCH 08/10] string-output-visitor: Fix to use sufficient precision, Markus Armbruster, 2020/12/10
- [PATCH 06/10] qobject: Fix qnum_to_string() to use sufficient precision, Markus Armbruster, 2020/12/10
- Re: [PATCH 00/10] Fix floating-point -> text conversion precision, no-reply, 2020/12/10