From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
Subject: [PATCH 07/10] test-string-output-visitor: Cover "unround" number
Date: Thu, 10 Dec 2020 17:14:49 +0100 [thread overview]
Message-ID: <20201210161452.2813491-8-armbru@redhat.com> (raw)
In-Reply-To: <20201210161452.2813491-1-armbru@redhat.com>
This demonstrates rounding error due to insufficient precision: double
3.1415926535897932 gets converted to JSON 3.141593.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/test-string-output-visitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index 9f6581439a..cec20848ea 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -130,13 +130,13 @@ static void test_visitor_out_bool(TestOutputVisitorData *data,
static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused)
{
- double value = 3.14;
+ double value = 3.1415926535897932;
char *str;
visit_type_number(data->ov, NULL, &value, &error_abort);
str = visitor_get(data);
- g_assert_cmpstr(str, ==, "3.140000");
+ g_assert_cmpstr(str, ==, "3.141593");
}
static void test_visitor_out_string(TestOutputVisitorData *data,
--
2.26.2
next prev parent reply other threads:[~2020-12-10 16:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-10 16:14 [PATCH 00/10] Fix floating-point -> text conversion precision Markus Armbruster
2020-12-10 16:14 ` [PATCH 01/10] tests/check-qjson: Don't skip funny QNumber to JSON conversions Markus Armbruster
2020-12-10 16:14 ` [PATCH 02/10] tests/check-qjson: Examine QNum more thoroughly Markus Armbruster
2020-12-10 16:14 ` [PATCH 03/10] tests/check-qjson: Cover number 2^63 Markus Armbruster
2020-12-10 16:14 ` [PATCH 04/10] tests/check-qjson: Replace redundant large_number() Markus Armbruster
2020-12-10 16:14 ` [PATCH 05/10] tests/check-qnum: Cover qnum_to_string() for "unround" argument Markus Armbruster
2020-12-10 16:14 ` [PATCH 06/10] qobject: Fix qnum_to_string() to use sufficient precision Markus Armbruster
2020-12-10 16:14 ` Markus Armbruster [this message]
2020-12-10 16:14 ` [PATCH 08/10] string-output-visitor: Fix " Markus Armbruster
2020-12-10 16:14 ` [PATCH 09/10] test-visitor-serialization: Drop insufficient precision workaround Markus Armbruster
2020-12-10 16:14 ` [PATCH 10/10] test-visitor-serialization: Clean up test_primitives() Markus Armbruster
2020-12-10 20:36 ` [PATCH 00/10] Fix floating-point -> text conversion precision no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201210161452.2813491-8-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).