From 7250a86b7eab2692d5c17d071436c84bac4574df Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 29 Jun 2023 14:40:16 +0200 Subject: c++,codec-json: Implemented Tuple Decoding --- tests/codec-json.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/codec-json.cpp') 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 native_tup; data 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"){ -- cgit v1.2.3