-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fix for test_msgpack_float and test_msgpack_object #2155
Changes from 1 commit
f557e67
3c400ba
ec541ae
bf42d61
959a01c
22a9ea0
f391728
9b5a580
cea31cc
d2fd5ac
8d1157c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<float>() == v.to<float>()); | ||
} | ||
|
||
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<std::string, double>{ | ||
{"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<value> with map items as vector elements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are we using an unordered map? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Its not using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw value constructor for std::initializer_list in value.cpp. In this case (where size is not 2 and elements have key) it is calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Where do you see this happening? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see it in the debugger during comparing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My suggestion since we do want to keep comparing the keys and the types are different for the values that we should either change operator== to have a specialization that can properly compare types, call the compare function directly if that will allow us to compare types or create a compare function that can compare the keys and compare with an explicit type conversion (passed as a template parameter). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So there is something wrong with either msgpack serialization or the value construction as it should be |
||
// value(std::vector<value>(m.begin(), m.end()), false) | ||
EXPECT(migraphx::from_msgpack(buffer).to_vector<double>() == v.to_vector<double>()); | ||
} | ||
|
||
TEST_CASE(test_msgpack_empty_object) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be converted to
float
first?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function migraphx::from_msgpack returns value which needs to be converted to other types (except for string and bool case) when we are comparing output values. The tests above convert value to appropriate type (here is the example for int).