16 inline void static_autotests() {
23 static_assert(a < b && b < c,
"test fail");
24 static_assert(a.getNF() == 1 && b.getNF() == 2,
"test fail");
27 constexpr
auto d = a + b;
28 static_assert(d.getNI() == 9,
"test fail");
29 static_assert(d.getNF() == 2,
"test fail");
30 static_assert((a + c).getNF() == 1,
"test fail");
31 static_assert(d.asRaw() == 258,
"test fail");
32 constexpr
auto e = d + b + c;
33 static_assert(e.getNI() == 10,
"test fail");
34 static_assert(e.getNF() == 2,
"test fail");
36 static_assert((d + d).getNI() == 10,
"test fail");
37 static_assert((e + e).getNF() == 2,
"test fail");
38 static_assert((d + e).getNI() == 11,
"test fail");
41 static_assert(SFixAuto<-128>().getNI() == 7,
"test fail");
42 static_assert(SFixAuto<127>().getNI() == 7,
"test fail");
43 static_assert(SFixAuto<128>().getNI() == 8,
"test fail");
45 #if (__cplusplus >= 202002L)
47 static_assert((s+s).getNI() == 8,
"test fail");
48 static_assert((-s).getNI() == 8,
"test fail");
52 static_assert((zero - s).getNI() == 8,
"test fail");
53 static_assert(-(zero - s) == s,
"test fail");
54 static_assert((s*negone).getNI() == 8,
"test fail");
56 static_assert((-SFixAuto<-127>()).getNI() == 7,
"test fail");
58 static_assert((-UFixAuto<127>()).getNI() == 7,
"test fail");
63 constexpr
auto large =
UFix<32,0>(1LL << 31,
true);
64 static_assert(
sizeof(decltype(large.asRaw())) == 4,
"test fail");
65 static_assert((large+large).asRaw() == (1LL << 32),
"test fail");
66 static_assert(
sizeof(decltype((large+large).asRaw())) > 4,
"test fail");
69 static_assert(b - a == c - b,
"test fail");
70 static_assert(c -
UFix<17,8>(1) == a,
"test fail");
71 static_assert(c -
SFix<13,9>(1) == a,
"test fail");
72 static_assert(b + a - b == a,
"test fail");
73 static_assert(b + a + (-b) == a,
"test fail");
74 static_assert(-(-a) == a,
"test fail");
75 #if (__cplusplus >= 202002L)
78 static_assert(
UFix<43,9>(0) - b - a == -(a+b),
"test fail");
92 static_assert(a.getNI() == a.asSFix().getNI(),
"test fail");
93 static_assert(a.getNF() == a.asSFix().getNF(),
"test fail");
96 static_assert(FixMathPrivate::NIcount<0>() == 0,
"test fail");
97 static_assert(FixMathPrivate::NIcount<1>() == 1,
"test fail");
98 static_assert(FixMathPrivate::NIcount<2>() == 2,
"test fail");
99 static_assert(FixMathPrivate::NIcount<3>() == 2,
"test fail");
100 static_assert(FixMathPrivate::NIcount<4>() == 3,
"test fail");
102 UFixAuto<3>().assertSize<2>();
103 UFixAuto<3>().sR<2>().assertSize<2>();
105 SFixAuto<16>().assertSize<6>();
constexpr UFix< 0, sizeof(T) *8 > toUFraction(T val)
Definition: FixMath.h:703
Definition: FixMath.h:754
Definition: FixMath.h:170
Definition: FixMath.h:126