[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/10] tests/check-qnum: Cover qnum_to_string() for "unround" arg
From: |
Markus Armbruster |
Subject: |
[PATCH 05/10] tests/check-qnum: Cover qnum_to_string() for "unround" argument |
Date: |
Thu, 10 Dec 2020 17:14:47 +0100 |
qnum_to_string() has a FIXME comment about rounding errors due to
insufficient precision. Cover it: 2.718281828459045 gets converted to
"2.718282". The next commit will fix it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/check-qnum.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/check-qnum.c b/tests/check-qnum.c
index 4105015872..a73809d021 100644
--- a/tests/check-qnum.c
+++ b/tests/check-qnum.c
@@ -150,6 +150,12 @@ static void qnum_to_string_test(void)
g_assert_cmpstr(tmp, ==, "0.42");
g_free(tmp);
qobject_unref(qn);
+
+ qn = qnum_from_double(2.718281828459045);
+ tmp = qnum_to_string(qn);
+ g_assert_cmpstr(tmp, ==, "2.718282"); /* BUG */
+ g_free(tmp);
+ qobject_unref(qn);
}
int main(int argc, char **argv)
--
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 <=
- [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, 2020/12/10
- [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