From f557e67280310147d509c15e32be6a1c1eecf485 Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Mon, 4 Sep 2023 08:47:03 +0200 Subject: [PATCH 1/7] Added fix for test_msgpack_float and test_msgpack_object --- test/msgpack.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index 61c26e9457e..591b8c43e25 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -76,7 +76,7 @@ TEST_CASE(test_msgpack_float) migraphx::value v = 3.0; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.0)); - EXPECT(migraphx::from_msgpack(buffer) == v); + EXPECT(migraphx::from_msgpack(buffer).to() == v.to()); } TEST_CASE(test_msgpack_string) @@ -109,7 +109,11 @@ TEST_CASE(test_msgpack_object) auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(std::map{ {"one", 1.0}, {"three", 3.0}, {"two", 2.0}})); - EXPECT(migraphx::from_msgpack(buffer) == v); + + // converted to vector in the following line because in value.cpp value constructor with + // unordered map is creating vector with map items as vector elements + // value(std::vector(m.begin(), m.end()), false) + EXPECT(migraphx::from_msgpack(buffer).to_vector() == v.to_vector()); } TEST_CASE(test_msgpack_empty_object) From 3c400baa9843c9f47d75593315d1838fa45d2c1f Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Wed, 27 Sep 2023 19:26:34 +0200 Subject: [PATCH 2/7] Added warning fix for double equal --- test/msgpack.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index 591b8c43e25..c202c3e5e55 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -76,7 +76,8 @@ TEST_CASE(test_msgpack_float) migraphx::value v = 3.0; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.0)); - EXPECT(migraphx::from_msgpack(buffer).to() == v.to()); + double epsilon = 1e-9; + EXPECT(std::abs(migraphx::from_msgpack(buffer).to() - v.to()) < epsilon); } TEST_CASE(test_msgpack_string) From bf42d614b24dadc434999797e3404179d1b6a4eb Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Fri, 29 Sep 2023 09:29:08 +0200 Subject: [PATCH 3/7] Added test::within_abs in comparing float values --- test/msgpack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index e1c38db9902..a9d73ad79cd 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -101,7 +101,7 @@ TEST_CASE(test_msgpack_float) auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.0)); double epsilon = 1e-9; - EXPECT(std::abs(migraphx::from_msgpack(buffer).to() - v.to()) < epsilon); + EXPECT(test::within_abs(migraphx::from_msgpack(buffer).to(), v.to())); } TEST_CASE(test_msgpack_string) From 959a01c809d60b923c0a3e5939d5f07505a38707 Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Fri, 29 Sep 2023 09:29:08 +0200 Subject: [PATCH 4/7] Added test::within_abs in comparing float values --- test/msgpack.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index a9d73ad79cd..4543bbf94d5 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -100,7 +100,6 @@ TEST_CASE(test_msgpack_float) migraphx::value v = 3.0; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.0)); - double epsilon = 1e-9; EXPECT(test::within_abs(migraphx::from_msgpack(buffer).to(), v.to())); } From 9b5a5804b16c0de4ec8c4af225fdad0ff3e91695 Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Thu, 5 Oct 2023 11:00:28 +0200 Subject: [PATCH 5/7] Added Windows fix for double inputs in test --- test/msgpack.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index 4543bbf94d5..0028b7f8fbc 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -97,10 +97,10 @@ TEST_CASE(test_msgpack_bool) TEST_CASE(test_msgpack_float) { - migraphx::value v = 3.0; + migraphx::value v = 3.01; auto buffer = migraphx::to_msgpack(v); - EXPECT(buffer == msgpack_buffer(3.0)); - EXPECT(test::within_abs(migraphx::from_msgpack(buffer).to(), v.to())); + EXPECT(buffer == msgpack_buffer(3.01)); + EXPECT(test::within_abs(migraphx::from_msgpack(buffer), v)); } TEST_CASE(test_msgpack_string) @@ -129,15 +129,11 @@ TEST_CASE(test_msgpack_empty_array) TEST_CASE(test_msgpack_object) { - migraphx::value v = {{"one", 1.0}, {"three", 3.0}, {"two", 2.0}}; + migraphx::value v = {{"one", 1.01}, {"three", 3.01}, {"two", 2.01}}; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(std::map{ - {"one", 1.0}, {"three", 3.0}, {"two", 2.0}})); - - // converted to vector in the following line because in value.cpp value constructor with - // unordered map is creating vector with map items as vector elements - // value(std::vector(m.begin(), m.end()), false) - EXPECT(migraphx::from_msgpack(buffer).to_vector() == v.to_vector()); + {"one", 1.01}, {"three", 3.01}, {"two", 2.01}})); + EXPECT(migraphx::from_msgpack(buffer) == v); } TEST_CASE(test_msgpack_empty_object) @@ -161,17 +157,17 @@ struct foo TEST_CASE(test_msgpack_object_class) { - migraphx::value v = {{"a", 1.0}, {"b", "abc"}}; + migraphx::value v = {{"a", 1.01}, {"b", "abc"}}; auto buffer = migraphx::to_msgpack(v); - EXPECT(buffer == msgpack_buffer(foo{1.0, "abc"})); + EXPECT(buffer == msgpack_buffer(foo{1.01, "abc"})); EXPECT(migraphx::from_msgpack(buffer) == v); } TEST_CASE(test_msgpack_array_class) { - migraphx::value v = {{{"a", 1.0}, {"b", "abc"}}, {{"a", 3.0}, {"b", "xyz"}}}; + migraphx::value v = {{{"a", 1.01}, {"b", "abc"}}, {{"a", 3.01}, {"b", "xyz"}}}; auto buffer = migraphx::to_msgpack(v); - EXPECT(buffer == msgpack_buffer(std::vector{foo{1.0, "abc"}, foo{3.0, "xyz"}})); + EXPECT(buffer == msgpack_buffer(std::vector{foo{1.01, "abc"}, foo{3.01, "xyz"}})); EXPECT(migraphx::from_msgpack(buffer) == v); } From cea31cc166f9cb36c05fac3f916178b0ab20af19 Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Thu, 5 Oct 2023 11:00:28 +0200 Subject: [PATCH 6/7] Added Windows fix for double inputs in test --- test/msgpack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index 0028b7f8fbc..31f594a91d4 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -100,7 +100,7 @@ TEST_CASE(test_msgpack_float) migraphx::value v = 3.01; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.01)); - EXPECT(test::within_abs(migraphx::from_msgpack(buffer), v)); + EXPECT(migraphx::from_msgpack(buffer) == v); } TEST_CASE(test_msgpack_string) From d2fd5ac17b4ccb75ee7f9fc364c9817a681ba674 Mon Sep 17 00:00:00 2001 From: Tijana Vukovic Date: Thu, 5 Oct 2023 17:13:33 +0200 Subject: [PATCH 7/7] Added comments why double inputs are changed --- test/msgpack.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/msgpack.cpp b/test/msgpack.cpp index 31f594a91d4..82912aeac26 100644 --- a/test/msgpack.cpp +++ b/test/msgpack.cpp @@ -97,6 +97,9 @@ TEST_CASE(test_msgpack_bool) TEST_CASE(test_msgpack_float) { + // changed all double values in this code to not end with .0 because on msgpack for Windows if + // input type is double and ends with .0 it could be converted to uint64_t or int64_t and the + // goal of these functions is to test double without conversions migraphx::value v = 3.01; auto buffer = migraphx::to_msgpack(v); EXPECT(buffer == msgpack_buffer(3.01));