summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/codec-json.cpp21
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"){