diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-02 15:50:52 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-02 15:50:52 +0200 |
commit | 95145a733d15bef84aa294f31d5cf8cefc66a1e0 (patch) | |
tree | a770debfc73f4bca8fad3ec531a289b82b75f060 | |
parent | 465c1379ceec8db1fc8990a3fe3bda2f2786d339 (diff) |
wip
-rw-r--r-- | modules/codec/tests/transport.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/modules/codec/tests/transport.cpp b/modules/codec/tests/transport.cpp index cffee24..e24fae6 100644 --- a/modules/codec/tests/transport.cpp +++ b/modules/codec/tests/transport.cpp @@ -20,22 +20,24 @@ using TestStruct = Struct< } -SAW_TEST("KelSimple Struct write and read back"){ +SAW_TEST("Transport FixedLen Struct write and slice"){ using namespace saw; - ring_buffer buffer{2048u}; + return; + ring_buffer buff{2048u}; data<schema::TestStruct,encode::Native> native; - data<schema::TestStruct,encode::KelSimple> simple; + data<schema::TestStruct,encode::KelSimple> simple{heap<buffer_view>(buff)}; - auto& tda = native.template get<"two_dim_array">(); - tda = {1,2}; + { + auto& tda = native.template get<"two_dim_array">(); + tda = {1,2}; - tda.at(0,0).set(5); - tda.at(0,1).set(3); - native.template get<"number">().set(410); - + tda.at(0,0).set(5); + tda.at(0,1).set(3); + native.template get<"number">().set(410); + } codec<schema::TestStruct, encode::KelSimple> codec; auto eov = codec.encode(native, simple); @@ -43,15 +45,19 @@ SAW_TEST("KelSimple Struct write and read back"){ // Reset values native = {}; + simple = {heap<buffer_view>(buff)}; + { + auto& tda = native.template get<"two_dim_array">(); + tda = {1,2}; - eov = codec.decode(simple, native); - SAW_EXPECT(eov.is_value(), "Decoding error"); + tda.at(0,0).set(2); + tda.at(0,1).set(4); + native.template get<"number">().set(709); + } - auto& dec_tda = native.template get<"two_dim_array">(); + auto eov = codec.encode(native, simple); + SAW_EXPECT(eov.is_value(), "Encoding error"); - SAW_EXPECT(dec_tda.at(0,0).get() == 5, "Incorrect Decoding in array 0,0"); - SAW_EXPECT(dec_tda.at(0,1).get() == 3, "Incorrect Decoding in array 0,1"); - SAW_EXPECT(native.template get<"number">().get() == 410, "Incorrect Decoding in number"); } } |