summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.nix/derivation.nix1
-rw-r--r--tests/codec-netcdf.cpp25
-rw-r--r--tests/data/simple.ncbin0 -> 68 bytes
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/.nix/derivation.nix b/tests/.nix/derivation.nix
index 198095e..e096e70 100644
--- a/tests/.nix/derivation.nix
+++ b/tests/.nix/derivation.nix
@@ -19,6 +19,7 @@ stdenv.mkDerivation {
forstio.async
forstio.codec
forstio.codec-json
+ forstio.codec-netcdf
forstio.core
forstio.io
forstio.test
diff --git a/tests/codec-netcdf.cpp b/tests/codec-netcdf.cpp
new file mode 100644
index 0000000..df0037b
--- /dev/null
+++ b/tests/codec-netcdf.cpp
@@ -0,0 +1,25 @@
+#include <forstio/test/suite.h>
+#include <forstio/codec/netcdf/netcdf.h>
+
+namespace {
+namespace schema {
+using namespace saw::schema;
+using TestStruct = Struct<
+ Member<Int32, "rh">
+>;
+}
+
+SAW_TEST("NetCDF read"){
+ using namespace saw;
+
+ data<TestStruct, encode::Netcdf> net{"./data/simple.nc"};
+
+ data<TestStruct, encode::KelSimple> kel;
+
+ codec<TestStruct, encode::Netcdf> codec;
+
+ auto eov = codec.decode(net, kel);
+ SAW_EXPECT(eov.is_value(), "Decoding failed");
+ SAW_EXPECT(kel.get<"rh">.get() == 5, "Value incorrect");
+}
+}
diff --git a/tests/data/simple.nc b/tests/data/simple.nc
new file mode 100644
index 0000000..4fc2473
--- /dev/null
+++ b/tests/data/simple.nc
Binary files differ