Skip to content

Commit 7f94da0

Browse files
committed
proper fix
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
1 parent ed1b99a commit 7f94da0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/native_api_tests/test_api_serialization.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
#include <string>
1515
#include <vector>
1616

17+
namespace nlohmann::detail {
18+
template <> struct char_traits<std::byte> : char_traits<std::underlying_type_t<std::byte>> {
19+
using char_type = std::byte;
20+
21+
// Redefine to_int_type function
22+
static int_type to_int_type(char_type c) noexcept { return static_cast<int_type>(c); }
23+
};
24+
} // namespace nlohmann::detail
1725
namespace power_grid_model_cpp {
18-
1926
namespace {
20-
2127
using namespace std::string_literals;
2228

2329
constexpr char const* json_data =
@@ -83,9 +89,7 @@ TEST_CASE("API Serialization and Deserialization") {
8389
SUBCASE("Round trip") {
8490
std::vector<std::byte> msgpack_data{};
8591
msgpack_serializer.get_to_binary_buffer(0, msgpack_data);
86-
std::span<std::underlying_type_t<std::byte>> const msgpack_data_view{
87-
reinterpret_cast<std::underlying_type_t<std::byte>*>(msgpack_data.data()), msgpack_data.size()};
88-
auto const json_document = nlohmann::ordered_json::from_msgpack(msgpack_data_view);
92+
auto const json_document = nlohmann::ordered_json::from_msgpack(msgpack_data);
8993
auto const json_result = json_document.dump(-1);
9094
CHECK(json_result == json_data);
9195
}

0 commit comments

Comments
 (0)