summaryrefslogtreecommitdiff
path: root/modules/codec-unit/tests
diff options
context:
space:
mode:
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");
}
-*/
}