diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-15 15:07:55 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-15 15:07:55 +0200 |
commit | ad63897c74424cb1e0936bae59332c51b5ba73c4 (patch) | |
tree | 8610770faa456fbc8e1206c2803ea6a7d44988d0 /tests | |
parent | 7779119ea724987128ebd4bb4c0433dee8b5f877 (diff) |
c++, codec: Testing the native array class. Not really a unit test, but
test instantiation cases
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codec-json.cpp | 2 | ||||
-rw-r--r-- | tests/codec.cpp | 55 |
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++); + } + } + } +} +} |