diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-28 20:49:26 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-28 20:49:26 -0400 |
commit | e851c02d2747be0acc336bc278da9e0460b75738 (patch) | |
tree | df813c5c572922cf05a6317b7eb1d6062dedac05 /test/unit/t_commodity.cc | |
parent | 3020f0f8513d8cef04d4a291dc9b5fa50e1b832c (diff) | |
download | fork-ledger-e851c02d2747be0acc336bc278da9e0460b75738.tar.gz fork-ledger-e851c02d2747be0acc336bc278da9e0460b75738.tar.bz2 fork-ledger-e851c02d2747be0acc336bc278da9e0460b75738.zip |
Unit test for Python are now auto-generated from the C++ tests.
Diffstat (limited to 'test/unit/t_commodity.cc')
-rw-r--r-- | test/unit/t_commodity.cc | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/test/unit/t_commodity.cc b/test/unit/t_commodity.cc index 62ec557e..a75fb727 100644 --- a/test/unit/t_commodity.cc +++ b/test/unit/t_commodity.cc @@ -17,14 +17,25 @@ void CommodityTestCase::tearDown() { void CommodityTestCase::testPriceHistory() { - datetime_t jan17_05 = parse_datetime("2005/01/17 00:00:00"); - datetime_t jan17_06 = parse_datetime("2006/01/17 00:00:00"); - datetime_t jan17_07 = parse_datetime("2007/01/17 00:00:00"); - datetime_t feb27_07 = parse_datetime("2007/02/27 18:00:00"); - datetime_t feb28_07 = parse_datetime("2007/02/28 06:00:00"); - datetime_t feb28_07sbm = parse_datetime("2007/02/28 11:59:59"); - datetime_t mar01_07 = parse_datetime("2007/03/01 00:00:00"); - datetime_t apr15_07 = parse_datetime("2007/04/15 13:00:00"); +#ifndef NOT_FOR_PYTHON + datetime_t jan17_05; + datetime_t jan17_06; + datetime_t jan17_07; + datetime_t feb27_07; + datetime_t feb28_07; + datetime_t feb28_07sbm; + datetime_t mar01_07; + datetime_t apr15_07; +#endif // NOT_FOR_PYTHON + + jan17_05 = parse_datetime("2005/01/17 00:00:00"); + jan17_06 = parse_datetime("2006/01/17 00:00:00"); + jan17_07 = parse_datetime("2007/01/17 00:00:00"); + feb27_07 = parse_datetime("2007/02/27 18:00:00"); + feb28_07 = parse_datetime("2007/02/28 06:00:00"); + feb28_07sbm = parse_datetime("2007/02/28 11:59:59"); + mar01_07 = parse_datetime("2007/03/01 00:00:00"); + apr15_07 = parse_datetime("2007/04/15 13:00:00"); amount_t x0; amount_t x1("100.10 AAPL"); @@ -45,15 +56,18 @@ void CommodityTestCase::testPriceHistory() aapl.add_price(jan17_05, amount_t("EUR 23.00")); aapl.add_price(jan17_06, amount_t("CAD 25.00")); - commodity_t& euro(amount_t("EUR 1.00").commodity()); + amount_t one_euro("EUR 1.00"); + commodity_t& euro(one_euro.commodity()); euro.add_price(feb27_07, amount_t("CAD 1.40")); euro.add_price(jan17_05, amount_t("$0.78")); - commodity_t& cad(amount_t("CAD 1.00").commodity()); + amount_t one_cad("CAD 1.00"); + commodity_t& cad(one_cad.commodity()); cad.add_price(jan17_06, amount_t("$1.11")); +#ifndef NOT_FOR_PYTHON optional<amount_t> amt = x1.value(feb28_07sbm); assertTrue(amt); assertEqual(amount_t("$1831.83"), *amt); @@ -76,6 +90,7 @@ void CommodityTestCase::testPriceHistory() amt = x1.value(current_time, cad); assertTrue(amt); assertEqual(amount_t("CAD 3223.22"), *amt); +#endif // NOT_FOR_PYTHON assertValid(x1); } @@ -83,15 +98,18 @@ void CommodityTestCase::testPriceHistory() void CommodityTestCase::testLots() { // jww (2007-04-17): tbd + int x = 1; } void CommodityTestCase::testScalingBase() { // jww (2007-04-17): tbd + int x = 1; } void CommodityTestCase::testReduction() { // jww (2007-04-17): tbd + int x = 1; } |