summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/codec-json.cpp2
-rw-r--r--tests/codec.cpp55
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp
index 67253d7..9cbb7c3 100644
--- a/tests/codec-json.cpp
+++ b/tests/codec-json.cpp
@@ -13,7 +13,7 @@ using TestTuple = Tuple<
>;
using TestArray = Array<
- String
+ String, 1
>;
using TestStruct = Struct<
diff --git a/tests/codec.cpp b/tests/codec.cpp
new file mode 100644
index 0000000..852628a
--- /dev/null
+++ b/tests/codec.cpp
@@ -0,0 +1,55 @@
+#include <forstio/test/suite.h>
+#include <forstio/codec/data.h>
+
+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>;
+
+}
+SAW_TEST("One Dimensional Array") {
+ using namespace saw;
+
+ data<schema::OneDimArray, encode::Native> arr{20u};
+
+ int bar = 0;
+
+ for(size_t i = 0; i < arr.get_dim_size(0); ++i){
+ arr.at(i).set(bar++);
+ }
+}
+
+SAW_TEST("Two Dimensional Array") {
+ using namespace saw;
+
+ data<schema::TwoDimArray, encode::Native> arr{10,10u};
+
+ int bar = 0;
+
+ for(size_t i = 0; i < arr.get_dim_size(0); ++i){
+ for(size_t j = 0; j < arr.get_dim_size(1); ++j){
+ arr.at(i,j).set(bar++);
+ }
+ }
+}
+
+SAW_TEST("Three Dimensional Array") {
+ using namespace saw;
+
+ data<schema::ThreeDimArray, encode::Native> arr{10,10u,5};
+
+ int bar = 0;
+
+ for(size_t i = 0; i < arr.get_dim_size(0); ++i){
+ for(size_t j = 0; j < arr.get_dim_size(1); ++j){
+ for(size_t k = 0; k < arr.get_dim_size(2); ++k){
+ arr.at(i,j,k).set(bar++);
+ }
+ }
+ }
+}
+}