diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-11-09 21:56:18 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-11-09 21:56:18 +0100 |
commit | 0302bb7d3b1ab2ac936911a4466a2530650c7b83 (patch) | |
tree | 40e2a1555cb0c1c8f41ef5ce8241374d5cb816f9 /tests | |
parent | f40fe73cbd8f61be11721babb1e3615326466041 (diff) |
codec-netcdf: Basic struct and primitive write in working order
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codec-netcdf.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/codec-netcdf.cpp b/tests/codec-netcdf.cpp index 11e53c3..67dc122 100644 --- a/tests/codec-netcdf.cpp +++ b/tests/codec-netcdf.cpp @@ -43,6 +43,28 @@ std::array<uint8_t,156> tests_data_array_nc = { 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e }; +SAW_TEST("NetCDF Struct Primitive write"){ + using namespace saw; + + data<schema::TestStruct, encode::Native> native; + + native.get<"data">().set(5); + native.get<"other">().set(32.0); + + codec<schema::TestStruct, encode::Netcdf> codec; + + data<schema::TestStruct, encode::Netcdf> netcdf; + + auto eov = codec.encode(native, netcdf); + SAW_EXPECT(eov.is_value(), "Encoding failed"); + auto& nc_data = netcdf.get_data(); + SAW_EXPECT(nc_data.size() == tests_data_primitive_nc.size(), "Incorrect size"); + + for(std::size_t i = 0; i < nc_data.size(); ++i){ + SAW_EXPECT(nc_data.at(i) == tests_data_primitive_nc.at(i), "Incorrect Value"); + } +} + SAW_TEST("NetCDF Struct Primitive read"){ using namespace saw; |