#include #include using namespace boost::ut; namespace { template constexpr std::array make_bytes(Bytes &&...bytes) { return {std::byte(std::forward(bytes))...}; } template constexpr bool wrong_types(auto const& obj) { auto err = tl::make_unexpected(msgpack::error::wrong_type); if (obj.template get() != err) return false; if constexpr (sizeof...(Others)) { return wrong_types(obj); } else { return true; } } template std::ostream &operator<<(std::ostream &os, tl::expected const &exp) { if (exp.has_value()) { os << "Value: '" << *exp << "'"; } else { os << "Error"; } return os; } } suite reader = [] { "construction"_test = [] { constexpr auto payload = make_bytes(0xce, 0x01, 0x02, 0x03, 0x09, 0xce); msgpack::token_reader reader(payload); auto token = reader.read_one(); expect(token && token->type() == msgpack::format::type::unsigned_int); expect(token->get() == tl::make_unexpected(msgpack::error::will_truncate)); expect(token->get() == 0x01020309); token = reader.read_one(); expect(token == tl::make_unexpected(msgpack::error::incomplete_message)); }; };