summaryrefslogtreecommitdiff
path: root/modules/codec-unit/tests
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-05 12:51:35 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-05 12:51:35 +0200
commitf27d397e9ab2d5c020b04dde4361fffa933f103c (patch)
tree624a0890ba2aed0130b5e58f60098d69e4e304fe /modules/codec-unit/tests
parent89c37ae7d84beb08ed99539bee972c241075d45e (diff)
Implemented basic class and operations
Diffstat (limited to 'modules/codec-unit/tests')
-rw-r--r--modules/codec-unit/tests/codec-unit.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/modules/codec-unit/tests/codec-unit.cpp b/modules/codec-unit/tests/codec-unit.cpp
index 0c88e9d..39e590d 100644
--- a/modules/codec-unit/tests/codec-unit.cpp
+++ b/modules/codec-unit/tests/codec-unit.cpp
@@ -2,15 +2,63 @@
#include <forstio/codec/schema.hpp>
+#include "../c++/unit.hpp"
+
namespace {
namespace sch {
using namespace saw::schema;
+
+struct FanMeterEle {};
+
+using FanMeter = Unit<
+ Int64,
+ UnitElement<FanMeterEle,1>
+>;
+
+using FanSquareMeter = Unit<
+ Int64,
+ UnitElement<FanMeterEle,2>
+>;
+}
+
+
+SAW_TEST("Codec Unit/Addition"){
+ using namespace saw;
+
+ data<sch::FanMeter> a{{5}}, b{{4}};
+
+ auto c = a + b;
+
+ SAW_EXPECT(c == data<sch::FanMeter>{9u}, "Expected result 9");
+}
+
+SAW_TEST("Codec Unit/Subtraction"){
+ using namespace saw;
+
+ data<sch::FanMeter> a{{5}}, b{{4}};
+
+ auto c = a - b;
+
+ SAW_EXPECT(c == data<sch::FanMeter>{1u}, "Expected result 1");
}
-/*
-SAW_TEST("Dummy Test"){
+SAW_TEST("Codec Unit/Multiplication"){
using namespace saw;
- SAW_EXPECT( false, "Dummy" );
+
+ data<sch::FanMeter> a{{5}}, b{{4}};
+
+ auto c = a * b;
+
+ SAW_EXPECT(c == data<sch::FanSquareMeter>{20u}, "Expected result 20");
+}
+
+SAW_TEST("Codec Unit/Division"){
+ using namespace saw;
+
+ data<sch::FanMeter> a{{20}}, b{{4}};
+
+ auto c = a / b;
+
+ SAW_EXPECT(c == data<sch::Scalar<sch::Int64>>{5u}, "Expected result 5");
}
-*/
}