|
@ -473,6 +473,62 @@ struct cbor_test : public test_scaffold { |
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
gp_config::assertion(serialized.begin() != ret_it, "could not encode"); |
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly"); |
|
|
} |
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
gp::vector<std::byte> str{alloc}; |
|
|
|
|
|
str.reserve(5); |
|
|
|
|
|
for(auto a : {'h', 'e', 'l', 'l', 'o'}) |
|
|
|
|
|
str.push_back((std::byte)a); |
|
|
|
|
|
gp::cbor_value data{alloc}; |
|
|
|
|
|
data = str; |
|
|
|
|
|
gp::vector<gp::pair<gp::cbor_value, gp::cbor_value>> meta{alloc}; |
|
|
|
|
|
gp::repeat(2, [&](){ |
|
|
|
|
|
meta.push_back(gp::make_pair(data, data)); |
|
|
|
|
|
}); |
|
|
|
|
|
data = meta; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gp::array<std::byte, 31> serialized; |
|
|
|
|
|
gp::array<std::byte, 31> serialized_manual{ |
|
|
|
|
|
std::byte(0b10100010), |
|
|
|
|
|
std::byte(0b01000101), |
|
|
|
|
|
std::byte('h'), |
|
|
|
|
|
std::byte('e'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('o'), |
|
|
|
|
|
std::byte(0b01000101), |
|
|
|
|
|
std::byte('h'), |
|
|
|
|
|
std::byte('e'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('o'), |
|
|
|
|
|
std::byte(0b01000101), |
|
|
|
|
|
std::byte('h'), |
|
|
|
|
|
std::byte('e'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('o'), |
|
|
|
|
|
std::byte(0b01000101), |
|
|
|
|
|
std::byte('h'), |
|
|
|
|
|
std::byte('e'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('l'), |
|
|
|
|
|
std::byte('o') |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
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"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|