#include #include namespace { namespace schema { using namespace saw::schema; using TestStruct = Struct< Member, Member >; using TestArrayStruct = Struct< Member, "data"> >; } SAW_TEST("NetCDF Struct Primitive read"){ using namespace saw; data netcdf{"./data/primitive.nc"}; data native; codec codec; auto eov = codec.decode(netcdf, native); SAW_EXPECT(eov.is_value(), "Decoding failed"); SAW_EXPECT(native.get<"data">().get() == 5, "Int Value incorrect"); SAW_EXPECT(native.get<"other">().get() == 32.0, "Double Value incorrect"); } SAW_TEST("NetCDF Struct Array read"){ using namespace saw; data netcdf{"./data/array.nc"}; data native; codec codec; auto eov = codec.decode(netcdf, native); SAW_EXPECT(eov.is_value(), "Decoding failed"); auto& arr = native.get<"data">(); SAW_EXPECT(arr.get_dim_size(0) == 5, "Incorrect dimension 0"); SAW_EXPECT(arr.get_dim_size(1) == 3, "Incorrect dimension 1"); for(std::size_t i = 0; i < 5; ++i){ for(std::size_t j = 0; j < 3; ++j){ int64_t exp_val = i * 3 + j; SAW_EXPECT(arr.at(i,j).get() == exp_val, "Incorrect value"); } } } }