|
|
@ -105,6 +105,92 @@ struct cbor_test : public test_scaffold { |
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
} |
|
|
|
{ |
|
|
|
gp::cbor_value data{alloc}; |
|
|
|
data = bool(false); |
|
|
|
|
|
|
|
gp::array<std::byte, 1> serialized; |
|
|
|
gp::array<std::byte, 1> serialized_manual{ |
|
|
|
std::byte(0b11100000+20) |
|
|
|
}; |
|
|
|
|
|
|
|
auto ret_it = data.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
|
|
|
|
gp::fill(serialized,(std::byte)0); |
|
|
|
|
|
|
|
auto decoded = gp::cbor_value::decode(alloc, serialized_manual.as_buffer()); |
|
|
|
ret_it = decoded.first.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
} |
|
|
|
{ |
|
|
|
gp::cbor_value data{alloc}; |
|
|
|
data = bool(true); |
|
|
|
|
|
|
|
gp::array<std::byte, 1> serialized; |
|
|
|
gp::array<std::byte, 1> serialized_manual{ |
|
|
|
std::byte(0b11100000+21) |
|
|
|
}; |
|
|
|
|
|
|
|
auto ret_it = data.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
|
|
|
|
gp::fill(serialized,(std::byte)0); |
|
|
|
|
|
|
|
auto decoded = gp::cbor_value::decode(alloc, serialized_manual.as_buffer()); |
|
|
|
ret_it = decoded.first.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
} |
|
|
|
{ |
|
|
|
gp::cbor_value data{gp::nullopt, alloc}; |
|
|
|
|
|
|
|
gp::array<std::byte, 1> serialized; |
|
|
|
gp::array<std::byte, 1> serialized_manual{ |
|
|
|
std::byte(0b11100000+22) |
|
|
|
}; |
|
|
|
|
|
|
|
auto ret_it = data.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
|
|
|
|
gp::fill(serialized,(std::byte)0); |
|
|
|
|
|
|
|
auto decoded = gp::cbor_value::decode(alloc, serialized_manual.as_buffer()); |
|
|
|
ret_it = decoded.first.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
} |
|
|
|
{ |
|
|
|
gp::cbor_value data{alloc}; |
|
|
|
|
|
|
|
gp::array<std::byte, 1> serialized; |
|
|
|
gp::array<std::byte, 1> serialized_manual{ |
|
|
|
std::byte(0b11100000+23) |
|
|
|
}; |
|
|
|
|
|
|
|
auto ret_it = data.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
|
|
|
|
gp::fill(serialized,(std::byte)0); |
|
|
|
|
|
|
|
auto decoded = gp::cbor_value::decode(alloc, serialized_manual.as_buffer()); |
|
|
|
ret_it = decoded.first.encode(serialized.as_buffer()); |
|
|
|
|
|
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
|
} |
|
|
|
{ |
|
|
|
gp::cbor_value data{alloc}; |
|
|
|
data = gp::cbor_number(128); |
|
|
|