xo-unit: + unary Quantity.operator-
This commit is contained in:
parent
e1fee23cdc
commit
8d1bdf5463
2 changed files with 8 additions and 0 deletions
|
|
@ -195,6 +195,10 @@ namespace xo {
|
|||
return x.scale() <=> y2.scale();
|
||||
}
|
||||
|
||||
Quantity operator-() const {
|
||||
return Quantity(-scale_, unit_);
|
||||
}
|
||||
|
||||
/* also works with Quantity2 = double, int, .. */
|
||||
template <typename Quantity2>
|
||||
Quantity & operator*= (const Quantity2 & x) {
|
||||
|
|
|
|||
|
|
@ -340,6 +340,10 @@ namespace xo {
|
|||
auto q1_minus_q2 = q1 - q2;
|
||||
REQUIRE(q1_minus_q2.unit() == q1.unit());
|
||||
REQUIRE(q1_minus_q2.scale() == Approx(1.0 - k2).epsilon(1.0e-6));
|
||||
|
||||
auto q1_neg = -q1;
|
||||
REQUIRE(q1_neg.unit() == q1.unit());
|
||||
REQUIRE(q1_neg.scale() == -q1.scale());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue