From c00a1811c5c8527da4a4e4af43fc819cc485db44 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 8 Nov 2008 20:26:56 +0000 Subject: [PATCH] add a test for setAmountDisplayPrefs precision handling --- Tests.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests.hs b/Tests.hs index aea0deb34..c33c2454d 100644 --- a/Tests.hs +++ b/Tests.hs @@ -105,8 +105,24 @@ unittests = TestList [ "transactionamount" ~: do assertparseequal (Mixed [dollars 47.18]) (parsewith transactionamount " $47.18") assertparseequal (Mixed [Amount (Commodity {symbol="$",side=L,spaced=False,comma=False,precision=0}) 1]) (parsewith transactionamount " $1.") + , + "setAmountDisplayPrefs" ~: do + let l = setAmountDisplayPrefs $ rawLedgerWithAmounts ["1","2.00"] + -- should be using the greatest precision everywhere + assertequal [2,2] (rawLedgerPrecisions l) + ] +rawLedgerPrecisions = map precision . rawLedgerCommodities +rawLedgerCommodities rl = concatMap (\(Mixed as) -> map commodity as) $ map amount $ rawLedgerTransactions rl +rawLedgerWithAmounts as = + RawLedger + [] + [] + [nullentry{etransactions=[nullrawtxn{tamount=parse a}]} | a <- as] + "" + where parse = fromparse . parsewith transactionamount . (" "++) + ------------------------------------------------------------------------------ functests = TestList [