Add further unittest for `UDecimal`

This commit is contained in:
Elias Batek 2025-01-28 02:12:50 +01:00
parent 425fb918db
commit 7f91abfc0a
1 changed files with 14 additions and 0 deletions

View File

@ -625,6 +625,20 @@ struct UDecimal {
assert((UDecimal(10) / 5).ceil().castTo!uint == 2);
}
@safe unittest {
UDecimal val;
val = (UDecimal(1) / 2);
assert(val.roundEven().castTo!uint == 0);
assert(val.castTo!double > 0.49);
assert(val.castTo!double < 0.51);
val = (UDecimal(3) / 2);
assert(val.roundEven().castTo!uint == 2);
assert(val.castTo!double > 1.49);
assert(val.castTo!double < 1.51);
}
@safe unittest {
UDecimal val;