blob: 99645bd7ad0d9c9fc7b73362432e05cf24b3aeb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include <forstio/test/suite.hpp>
#include <forstio/codec/schema.hpp>
#include "../c++/unit.hpp"
namespace {
namespace sch {
using namespace saw::schema;
struct FantasyMeterEle {};
using FantasyMeter = Unit<
Int64,
UnitElement<FantasyMeterEle,1>
>;
using FantasySquareMeter = Unit<
Int64,
UnitElement<FantasyMeterEle,2>
>;
}
SAW_TEST("Codec Unit/Addition"){
using namespace saw;
data<sch::FantasyMeter> a{{5}}, b{{4}};
auto c = a + b;
SAW_EXPECT(c == data<sch::FantasyMeter>{9u}, "Expected result 9");
}
SAW_TEST("Codec Unit/Subtraction"){
using namespace saw;
data<sch::FantasyMeter> a{{5}}, b{{4}};
auto c = a - b;
SAW_EXPECT(c == data<sch::FantasyMeter>{1u}, "Expected result 1");
}
SAW_TEST("Codec Unit/Multiplication"){
using namespace saw;
data<sch::FantasyMeter> a{{5}}, b{{4}};
auto c = a * b;
SAW_EXPECT(c == data<sch::FantasySquareMeter>{20u}, "Expected result 20");
}
SAW_TEST("Codec Unit/Division"){
using namespace saw;
data<sch::FantasyMeter> a{{20}}, b{{4}};
auto c = a / b;
SAW_EXPECT(c == data<sch::Scalar<sch::Int64>>{5u}, "Expected result 5");
}
}
|