diff options
Diffstat (limited to 'tests/codec-json.cpp')
-rw-r--r-- | tests/codec-json.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp new file mode 100644 index 0000000..d82db14 --- /dev/null +++ b/tests/codec-json.cpp @@ -0,0 +1,22 @@ +#include <forstio/test/suite.h> +#include <forstio/codec/json/json.h> + +namespace { +SAW_TEST("Int32 write"){ + using namespace saw; + data<schema::Int32, encode::Native> native_int; + data<schema::Int32, encode::Json> json_int; + + native_int.set(44123); + + codec<schema::Int32, encode::Json> json_codec; + + error_or<void> eov = json_codec.encode(native_int, json_int); + SAW_EXPECT(eov.is_value(), "Encoding error"); + + std::string_view str_view = "44123"; + for(std::size_t i = 0; i < str_view.size(); ++i){ + SAW_EXPECT( json_int.at(i) == str_view[i], "Value is not being encoded correctly" ); + } +} +} |