diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-27 19:16:46 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-27 19:16:46 +0200 |
commit | 0bd38cdec70c3a07467fccd81b570b754996eb95 (patch) | |
tree | e45adfb584cb0a5a1650be164751cb74e5f7c7b8 /tests/codec-json.cpp | |
parent | 5688c721c610e2a8931d6ec6f84dee2d4d65c763 (diff) |
c++,codec-json,codec: Working on fixes for JSON Array decoding. Test
failing currently
Diffstat (limited to 'tests/codec-json.cpp')
-rw-r--r-- | tests/codec-json.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp index fec82b0..9406a5c 100644 --- a/tests/codec-json.cpp +++ b/tests/codec-json.cpp @@ -259,15 +259,24 @@ SAW_TEST("Three Dim Array write"){ native.at(1,0,0).set("foo"); native.at(1,0,1).set("bar"); - codec<schema::TestMultiArray, encode::Json> json_codec; + codec<schema::TestMultiArray, encode::Json> codec; - error_or<void> eov = json_codec.encode(native, json); + error_or<void> eov = codec.encode(native, json); SAW_EXPECT(eov.is_value(), "Encoding error"); std::string_view str_v = "[[[\"multi\",\"baz\"]],[[\"foo\",\"bar\"]]]"; std::string enc_val = convert_to_string(json.get_buffer()); SAW_EXPECT(enc_val == str_v, std::string{"Array not encoded correctly. Encoded: "} + enc_val + std::string{" Expected: "} + std::string{str_v}); + + native = {}; + eov = codec.decode(json, native); + SAW_EXPECT(eov.is_value(), "Decoding error"); + SAW_EXPECT(native.at(0,0,0) == "multi", "Invalid Value at 0,0,0"); + SAW_EXPECT(native.at(0,0,1) == "baz", "Invalid Value at 0,0,1"); + SAW_EXPECT(native.at(1,0,0) == "foo", "Invalid Value at 1,0,0"); + SAW_EXPECT(native.at(1,0,1) == "bar", "Invalid Value at 1,0,1"); + } SAW_TEST("Struct write"){ @@ -287,6 +296,14 @@ SAW_TEST("Struct write"){ std::string enc_val = convert_to_string(json.get_buffer()); SAW_EXPECT(enc_val == str_v, std::string{"Struct not encoded correctly. Encoded: "} + enc_val + std::string{" Expected: "} + std::string{str_v}); + + /* + native = {}; + eov = json_codec.decode(json, native); + SAW_EXPECT(eov.is_value(), "Decoding error"); + SAW_EXPECT(native.get<"foo">().get() == 5, "Invalid value for foo"); + SAW_EXPECT(native.get<"bar">().get() == "baz", "Invalid value for bar"); + */ } SAW_TEST("Int8 read"){ |