summaryrefslogtreecommitdiff
path: root/tests/codec-json.cpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-06-29 14:40:16 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-06-29 14:40:16 +0200
commit7250a86b7eab2692d5c17d071436c84bac4574df (patch)
tree35598c441ce7985425ff787e59bdba2437a3ff09 /tests/codec-json.cpp
parentdd5d61330032511f5b0e05e813bbfe2054841f5d (diff)
c++,codec-json: Implemented Tuple Decoding
Diffstat (limited to 'tests/codec-json.cpp')
-rw-r--r--tests/codec-json.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp
index 926f550..e1b8b5c 100644
--- a/tests/codec-json.cpp
+++ b/tests/codec-json.cpp
@@ -213,7 +213,7 @@ SAW_TEST("String write and read"){
SAW_EXPECT(nat_str == "foo", "Incorrect value decoded");
}
-SAW_TEST("Tuple write"){
+SAW_TEST("Tuple read and write"){
using namespace saw;
data<schema::TestTuple, encode::Native> native_tup;
data<schema::TestTuple, encode::Json> json_tup;
@@ -233,6 +233,13 @@ SAW_TEST("Tuple write"){
std::string enc_val = convert_to_string(json_tup.get_buffer());
SAW_EXPECT(enc_val == str_v, std::string{"Tuple not encoded correctly. Encoded: "} + enc_val + std::string{" Expected: "} + std::string{str_v});
+ native_tup = {};
+
+ eov = json_codec.decode(json_tup, native_tup);
+ SAW_EXPECT(eov.is_value(), "Decoding error");
+
+ SAW_EXPECT(native_tup.template get<0>() == "bar", "Invalid Value 0");
+ SAW_EXPECT(native_tup.template get<1>().get() == 34, "Invalid Value 1");
}
SAW_TEST("Array write"){