#include #include "../c++/data.hpp" #include "../c++/simple.hpp" #include namespace { namespace schema { using namespace saw::schema; using ZeroDimArray = Array; using OneDimArray = Array; using TwoDimArray = Array; using ThreeDimArray = Array; using TestStruct = Struct< Member, Member >; } SAW_TEST("KelSimple Struct write and read back"){ using namespace saw; ring_buffer buffer{2048u}; data native; data simple; 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); codec codec; auto eov = codec.encode(native, simple); SAW_EXPECT(eov.is_value(), "Encoding error"); // Reset values native = {}; eov = codec.decode(simple, native); SAW_EXPECT(eov.is_value(), "Decoding error"); auto& dec_tda = native.template get<"two_dim_array">(); 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"); } }