Преглед на файлове

changed the variant to use a copy of the data

cbor
Ludovic 'Archivist' Lagouardette преди 3 години
родител
ревизия
88b85e7dd4
променени са 2 файла, в които са добавени 8 реда и са изтрити 5 реда
  1. +3
    -3
      include/gp/enveloppe/cbor.hpp
  2. +5
    -2
      tests/cbor_test.cpp

+ 3
- 3
include/gp/enveloppe/cbor.hpp Целия файл

@ -88,7 +88,7 @@ namespace gp {
using cbor_composite = gp::fixed_variant<
undefined_t,
cbor_number,
gp::buffer<std::byte>,
gp::vector<std::byte>,
bool,
gp::vector<T>,
gp::vector<gp::pair<T, T>>,
@ -227,8 +227,8 @@ namespace gp {
ref.value
);
}
case cbor_composite<cbor_value>::alt<gp::buffer<std::byte>>(): {
auto& ref = contents.value<gp::buffer<std::byte>>();
case cbor_composite<cbor_value>::alt<gp::vector<std::byte>>(): {
auto& ref = contents.value<gp::vector<std::byte>>();
auto it = encode_length(
dest,
cbor_type::bstr,

+ 5
- 2
tests/cbor_test.cpp Целия файл

@ -107,9 +107,12 @@ struct cbor_test : public test_scaffold {
gp_config::assertion(serialized == serialized_manual, "data did not serialize correctly");
}
{
gp::array<char, 5> str{'h', 'e', 'l', 'l', 'o'};
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.as_buffer().cast<std::byte>();
data = str;
gp::array<std::byte, 6> serialized;
gp::array<std::byte, 6> serialized_manual{

Зареждане…
Отказ
Запис