]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tests/check-qnum: Cover qnum_to_string() for "unround" argument
authorMarkus Armbruster <armbru@redhat.com>
Thu, 10 Dec 2020 16:14:47 +0000 (17:14 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Sat, 19 Dec 2020 09:37:16 +0000 (10:37 +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>
Message-Id: <20201210161452.2813491-6-armbru@redhat.com>

tests/check-qnum.c

index 4105015872105a73d0c6eb95913826f0ffce1406..a73809d0215d4c984d96503a7159cd82e1a3e5fd 100644 (file)
@@ -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)