diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-20 17:00:38 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-20 17:00:38 +0200 |
commit | 056ab6893ca18c33c7fb01d24498f9149fba4e8a (patch) | |
tree | 8ab44a999552beb3cd72f80c1166ec94e849e4fc /tests/codec-json.cpp | |
parent | f5629bf0da55ebaaddc5cf551c36ed7362dc54b5 (diff) |
c++, codec-json: Minor progress on arrays for json decoding
Diffstat (limited to 'tests/codec-json.cpp')
-rw-r--r-- | tests/codec-json.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp index 030b1e4..fec82b0 100644 --- a/tests/codec-json.cpp +++ b/tests/codec-json.cpp @@ -292,12 +292,13 @@ SAW_TEST("Struct write"){ SAW_TEST("Int8 read"){ using namespace saw; data<schema::Int8, encode::Native> native_int; - data<schema::Int8, encode::Json> json_int; + data<schema::Int8, encode::Json> json_int{"43"}; codec<schema::Int8, encode::Json> json_codec; error_or<void> eov = json_codec.decode(json_int, native_int); - SAW_EXPECT(eov.is_value(), "Encoding error"); + std::string enc_val = convert_to_string(json_int.get_buffer()); + SAW_EXPECT(eov.is_value(), std::string{"Encoding error: "} + enc_val); /** * Currently doing this manually. Technically I should convert to std::string for tests @@ -305,4 +306,22 @@ SAW_TEST("Int8 read"){ typename native_data_type<schema::Int8>::type dec_val = 43; SAW_EXPECT( dec_val == native_int.get(), std::string{"Value is not being encoded correctly. Encoded: "} + std::to_string(static_cast<int>(native_int.get()))); } + +SAW_TEST("Int64 read"){ + using namespace saw; + data<schema::Int64, encode::Native> native_int; + data<schema::Int64, encode::Json> json_int{"-453"}; + + codec<schema::Int64, encode::Json> json_codec; + + error_or<void> eov = json_codec.decode(json_int, native_int); + std::string enc_val = convert_to_string(json_int.get_buffer()); + SAW_EXPECT(eov.is_value(), std::string{"Encoding error: "} + enc_val); + + /** + * Currently doing this manually. Technically I should convert to std::string for tests + */ + typename native_data_type<schema::Int64>::type dec_val = -453; + SAW_EXPECT( dec_val == native_int.get(), std::string{"Value is not being encoded correctly. Encoded: "} + std::to_string(static_cast<int>(native_int.get()))); +} } |