summaryrefslogtreecommitdiff
path: root/modules/codec/tests/csv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec/tests/csv.cpp')
-rw-r--r--modules/codec/tests/csv.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/codec/tests/csv.cpp b/modules/codec/tests/csv.cpp
new file mode 100644
index 0000000..507d4cb
--- /dev/null
+++ b/modules/codec/tests/csv.cpp
@@ -0,0 +1,50 @@
+#include <forstio/test/suite.h>
+#include "../c++/data.h"
+#include "../c++/csv.h"
+
+#include <iostream>
+
+namespace {
+namespace schema {
+using namespace saw::schema;
+
+using ZeroDimArray = Array<Int32,0>;
+using OneDimArray = Array<Int32,1>;
+using TwoDimArray = Array<Int32,2>;
+using ThreeDimArray = Array<Int32,3>;
+
+using TestStruct = Struct<
+ Member<String, "string">,
+ Member<UInt64, "number">
+>;
+
+using TestUnion = Union<
+ Member<TwoDimArray, "two_dim_array">,
+ Member<UInt64, "number">
+>;
+
+using TestTuple = Tuple<
+ TwoDimArray,
+ UInt64
+>;
+
+using TestInt32Pair = Tuple<
+ Int32,
+ Int32
+>;
+
+SAW_TEST("Codec Csv Encode Basic"){
+ using namespace saw;
+
+ data <TestStruct, encode::Native> native_data;
+ native_data.template get<"string">().set("foo");
+ native_data.template get<"number">().set(140u);
+
+ data <TestStruct, encode::Csv> csv_data;
+ codec<TestStruct, encode::Csv> csv_codec;
+
+ auto eov = csv_codec.encode(native_data, csv_data);
+ SAW_EXPECT(eov.is_value(), "Couldn't encode data");
+}
+}
+}