From 7f91abfc0ac3ecbe9d045174397d05c1aa960f55 Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Tue, 28 Jan 2025 02:12:50 +0100 Subject: [PATCH] Add further unittest for `UDecimal` --- pixmappaint.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pixmappaint.d b/pixmappaint.d index 1bf8368..c8e87af 100644 --- a/pixmappaint.d +++ b/pixmappaint.d @@ -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;