add a test for setAmountDisplayPrefs precision handling

This commit is contained in:
Simon Michael 2008-11-08 20:26:56 +00:00
parent 0b23598138
commit c00a1811c5

View File

@ -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 [