summaryrefslogtreecommitdiff
path: root/tests/codec-json.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codec-json.cpp')
-rw-r--r--tests/codec-json.cpp23
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())));
+}
}