diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-28 11:43:03 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-28 11:43:03 +0200 |
commit | 95b870c811032436c209978d0e2fb6ab76707e8e (patch) | |
tree | 1af60dbca292b8191a7252cd156cad02812c70f0 /tests | |
parent | e41b18d6aee90a3e7c50d580836dc1211e5842ee (diff) |
c++,tests: Added test for String reading
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codec-json.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp index e6ecf35..5b4700f 100644 --- a/tests/codec-json.cpp +++ b/tests/codec-json.cpp @@ -186,16 +186,16 @@ SAW_TEST("Int64 write"){ SAW_EXPECT( enc_val == str_v, std::string{"Value is not being encoded correctly. Encoded: "} + enc_val ); } -SAW_TEST("String write"){ +SAW_TEST("String write and read"){ using namespace saw; data<schema::String, encode::Native> nat_str; data<schema::String, encode::Json> json_str; nat_str.set("foo"); - codec<schema::String, encode::Json> json_codec; + codec<schema::String, encode::Json> codec; - error_or<void> eov = json_codec.encode(nat_str, json_str); + error_or<void> eov = codec.encode(nat_str, json_str); SAW_EXPECT(eov.is_value(), "Encoding error"); /** @@ -205,6 +205,12 @@ SAW_TEST("String write"){ std::string encoded_value = convert_to_string(json_str.get_buffer()); SAW_EXPECT(encoded_value == str_view, "String not encoded correctly"); + + nat_str = {}; + eov = codec.decode(json_str, nat_str); + SAW_EXPECT(eov.is_value(), "Decoding error"); + + SAW_EXPECT(nat_str == "foo", "Incorrect value decoded"); } SAW_TEST("Tuple write"){ |