Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ constexpr std::size_t msgpack_size_limit = std::numeric_limits<uint32_t>::max()
template <class Range>
static std::size_t msgpack_chunk_size(const Range& r)
{
return 1 + (r.size() - 1) / msgpack_size_limit;
return 1 + (std::max<size_t>(1, r.size()) - 1) / msgpack_size_limit;
}

template <class Iterator, class F>
Expand Down Expand Up @@ -81,6 +81,7 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
break;
}
case msgpack::type::FLOAT32:
/* Intentional Fall Through This is due to value encoding floats as double. */
case msgpack::type::FLOAT64: {
v = o.as<double>();
break;
Expand Down
15 changes: 15 additions & 0 deletions test/msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,20 @@ TEST_CASE(test_msgpack_binary2)
});
EXPECT(migraphx::to_msgpack(bin) == msgpack_buffer(bin));
}

TEST_CASE(test_msgpack_binary_empty)
{
migraphx::value::binary bin{};
EXPECT(migraphx::to_msgpack(bin) == msgpack_buffer(bin));
}

TEST_CASE(test_msgpack_binary_roundtrip_empty)
{
migraphx::value bin = migraphx::value::binary{};
auto buffer = migraphx::to_msgpack(bin);
auto mp = migraphx::from_msgpack(buffer);
EXPECT(mp == bin);
}

#endif
int main(int argc, const char* argv[]) { test::run(argc, argv); }
Loading