From 73fac05aa07a0dd16f7061baddd4b934c7855fed Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 10 Jun 2023 23:45:17 +0200 Subject: c++: Setting up testing progress --- tests/codec-json.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/codec-json.cpp (limited to 'tests/codec-json.cpp') 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 +#include + +namespace { +SAW_TEST("Int32 write"){ + using namespace saw; + data native_int; + data json_int; + + native_int.set(44123); + + codec json_codec; + + error_or 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" ); + } +} +} -- cgit v1.2.3