From 88b85e7dd4bb54ec85bdbfe06cf0893a138cca54 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Sat, 17 Oct 2020 01:35:27 +0200 Subject: [PATCH] changed the variant to use a copy of the data --- include/gp/enveloppe/cbor.hpp | 6 +++--- tests/cbor_test.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/gp/enveloppe/cbor.hpp b/include/gp/enveloppe/cbor.hpp index 65ab6d8..0b3dc45 100644 --- a/include/gp/enveloppe/cbor.hpp +++ b/include/gp/enveloppe/cbor.hpp @@ -88,7 +88,7 @@ namespace gp { using cbor_composite = gp::fixed_variant< undefined_t, cbor_number, - gp::buffer, + gp::vector, bool, gp::vector, gp::vector>, @@ -227,8 +227,8 @@ namespace gp { ref.value ); } - case cbor_composite::alt>(): { - auto& ref = contents.value>(); + case cbor_composite::alt>(): { + auto& ref = contents.value>(); auto it = encode_length( dest, cbor_type::bstr, diff --git a/tests/cbor_test.cpp b/tests/cbor_test.cpp index 5f40213..c7c1961 100644 --- a/tests/cbor_test.cpp +++ b/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 str{'h', 'e', 'l', 'l', 'o'}; + gp::vector 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(); + data = str; gp::array serialized; gp::array serialized_manual{