[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/33] test-visitor-serialization: Drop insufficient precision wor
From: |
Markus Armbruster |
Subject: |
[PULL 12/33] test-visitor-serialization: Drop insufficient precision workaround |
Date: |
Sat, 19 Dec 2020 11:55:11 +0100 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20201210161452.2813491-10-armbru@redhat.com>
---
tests/test-visitor-serialization.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/tests/test-visitor-serialization.c
b/tests/test-visitor-serialization.c
index 12275e56d8..cf19924068 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -311,17 +311,7 @@ static void test_primitives(gconstpointer opaque)
g_assert_cmpstr(pt->value.string, ==, pt_copy->value.string);
g_free((char *)pt_copy->value.string);
} else if (pt->type == PTYPE_NUMBER) {
- GString *double_expected = g_string_new("");
- GString *double_actual = g_string_new("");
- /* we serialize with %f for our reference visitors, so rather than
fuzzy
- * floating math to test "equality", just compare the formatted values
- */
- g_string_printf(double_expected, "%.6f", pt->value.number);
- g_string_printf(double_actual, "%.6f", pt_copy->value.number);
- g_assert_cmpstr(double_actual->str, ==, double_expected->str);
-
- g_string_free(double_expected, true);
- g_string_free(double_actual, true);
+ g_assert_cmpfloat(pt->value.number, ==, pt_copy->value.number);
} else if (pt->type == PTYPE_BOOLEAN) {
g_assert_cmpint(!!pt->value.max, ==, !!pt->value.max);
} else {
@@ -703,10 +693,6 @@ static PrimitiveType pt_values[] = {
.value.boolean = 0,
},
/* number tests (double) */
- /* note: we format these to %.6f before comparing, since that's how
- * we serialize them and it doesn't make sense to check precision
- * beyond that.
- */
{
.description = "number_sanity1",
.type = PTYPE_NUMBER,
@@ -715,7 +701,7 @@ static PrimitiveType pt_values[] = {
{
.description = "number_sanity2",
.type = PTYPE_NUMBER,
- .value.number = 3.14159265,
+ .value.number = 3.141593,
},
{
.description = "number_min",
--
2.26.2
- [PULL 00/33] QAPI patches patches for 2020-12-19, Markus Armbruster, 2020/12/19
- [PULL 04/33] tests/check-qjson: Don't skip funny QNumber to JSON conversions, Markus Armbruster, 2020/12/19
- [PULL 01/33] rocker: Revamp fp_port_get_info, Markus Armbruster, 2020/12/19
- [PULL 11/33] string-output-visitor: Fix to use sufficient precision, Markus Armbruster, 2020/12/19
- [PULL 05/33] tests/check-qjson: Examine QNum more thoroughly, Markus Armbruster, 2020/12/19
- [PULL 09/33] qobject: Fix qnum_to_string() to use sufficient precision, Markus Armbruster, 2020/12/19
- [PULL 06/33] tests/check-qjson: Cover number 2^63, Markus Armbruster, 2020/12/19
- [PULL 10/33] test-string-output-visitor: Cover "unround" number, Markus Armbruster, 2020/12/19
- [PULL 08/33] tests/check-qnum: Cover qnum_to_string() for "unround" argument, Markus Armbruster, 2020/12/19
- [PULL 12/33] test-visitor-serialization: Drop insufficient precision workaround,
Markus Armbruster <=
- [PULL 07/33] tests/check-qjson: Replace redundant large_number(), Markus Armbruster, 2020/12/19
- [PULL 02/33] migration: Refactor migrate_cap_add, Markus Armbruster, 2020/12/19
- [PULL 26/33] qobject: Drop qstring_get_try_str(), Markus Armbruster, 2020/12/19
- [PULL 13/33] test-visitor-serialization: Clean up test_primitives(), Markus Armbruster, 2020/12/19
- [PULL 19/33] Revert "qstring: add qstring_free()", Markus Armbruster, 2020/12/19
- [PULL 16/33] qobject: Make qobject_to_json_pretty() take a pretty argument, Markus Armbruster, 2020/12/19
- [PULL 15/33] monitor: Use GString instead of QString for output buffer, Markus Armbruster, 2020/12/19
- [PULL 22/33] qmp: Fix tracing of non-string command IDs, Markus Armbruster, 2020/12/19
- [PULL 20/33] hw/rdma: Replace QList by GQueue, Markus Armbruster, 2020/12/19
- [PULL 23/33] block: Avoid qobject_get_try_str(), Markus Armbruster, 2020/12/19