diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-19 17:48:27 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-19 17:48:27 -0400 |
commit | 009dd3969a5cf965a685702b71aee53bf957b206 (patch) | |
tree | 8e469bc3133bb55698ebb7f68d9dabaa71ff2a10 /test/unit/t_commodity.cc | |
parent | dc91fdeff280a85b5157cf0aea56eae0bd1ae209 (diff) | |
download | fork-ledger-009dd3969a5cf965a685702b71aee53bf957b206.tar.gz fork-ledger-009dd3969a5cf965a685702b71aee53bf957b206.tar.bz2 fork-ledger-009dd3969a5cf965a685702b71aee53bf957b206.zip |
Added a recursive, date-based commodity price searching capability. This
makes it possible to find all possible prices for a commodity by walking the
map of pricing relationships to all other commodities, even if the relation is
distant.
Diffstat (limited to 'test/unit/t_commodity.cc')
-rw-r--r-- | test/unit/t_commodity.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/unit/t_commodity.cc b/test/unit/t_commodity.cc index a96bed72..7a2a2dea 100644 --- a/test/unit/t_commodity.cc +++ b/test/unit/t_commodity.cc @@ -35,14 +35,29 @@ void CommodityTestCase::testPriceHistory() aapl.add_price(feb28_07sbm, amount_t("$18.30")); aapl.add_price(mar01_07, amount_t("$19.50")); aapl.add_price(apr15_07, amount_t("$21.22")); + aapl.add_price(apr15_07, amount_t("EUR 23.00")); optional<amount_t> amt1 = x1.value(feb28_07sbm); assertTrue(amt1); assertEqual(amount_t("$1831.83"), *amt1); - optional<amount_t> amt2 = x1.value(current_time); + commodity_t& euro(amount_t("EUR 1.00").commodity()); + + optional<amount_t> amt2 = x1.value(current_time, euro); assertTrue(amt2); - assertEqual(amount_t("$2124.12"), *amt2); + assertEqual(amount_t("EUR 2302.30"), *amt2); + + optional<amount_t> amt3 = x1.value(current_time); + assertTrue(amt3); + assertEqual(amount_t("$2124.12"), *amt3); + + euro.add_price(feb27_07, amount_t("CAD 40.00")); + + commodity_t& cad(amount_t("CAD 1.00").commodity()); + + optional<amount_t> amt4 = x1.value(current_time, cad); + assertTrue(amt4); + assertEqual(amount_t("CAD 92092.00"), *amt4); assertValid(x1); } |