Skip to content

Commit

Permalink
Added fix for test_msgpack_float and test_msgpack_object (#2155)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvukovic-amd authored Oct 6, 2023
1 parent 9316c00 commit f3f6598
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ TEST_CASE(test_msgpack_bool)

TEST_CASE(test_msgpack_float)
{
migraphx::value v = 3.0;
// 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.0));
EXPECT(buffer == msgpack_buffer(3.01));
EXPECT(migraphx::from_msgpack(buffer) == v);
}

Expand Down Expand Up @@ -129,10 +132,10 @@ 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<std::string, double>{
{"one", 1.0}, {"three", 3.0}, {"two", 2.0}}));
{"one", 1.01}, {"three", 3.01}, {"two", 2.01}}));
EXPECT(migraphx::from_msgpack(buffer) == v);
}

Expand All @@ -157,17 +160,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>{foo{1.0, "abc"}, foo{3.0, "xyz"}}));
EXPECT(buffer == msgpack_buffer(std::vector<foo>{foo{1.01, "abc"}, foo{3.01, "xyz"}}));
EXPECT(migraphx::from_msgpack(buffer) == v);
}

Expand Down

0 comments on commit f3f6598

Please sign in to comment.