diff options
author | John Wiegley <johnw@newartisans.com> | 2007-05-03 06:11:04 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:36 -0400 |
commit | c59018c29ddfc7a46aeb951fbcd5cb5b93f47ec0 (patch) | |
tree | 204d28bfa2bdbfe8d7f550877faa114c1e93859f /tests/numerics | |
parent | f9f24fab933266ab8e12da7eef4cc2a906f77350 (diff) | |
download | fork-ledger-c59018c29ddfc7a46aeb951fbcd5cb5b93f47ec0.tar.gz fork-ledger-c59018c29ddfc7a46aeb951fbcd5cb5b93f47ec0.tar.bz2 fork-ledger-c59018c29ddfc7a46aeb951fbcd5cb5b93f47ec0.zip |
Revised how commodities are dealt with.
Diffstat (limited to 'tests/numerics')
-rw-r--r-- | tests/numerics/BasicAmount.cc | 8 | ||||
-rw-r--r-- | tests/numerics/BasicAmount.h | 2 | ||||
-rw-r--r-- | tests/numerics/Commodity.cc | 13 | ||||
-rw-r--r-- | tests/numerics/Commodity.h | 2 | ||||
-rw-r--r-- | tests/numerics/CommodityAmount.cc | 5 | ||||
-rw-r--r-- | tests/numerics/CommodityAmount.h | 2 |
6 files changed, 22 insertions, 10 deletions
diff --git a/tests/numerics/BasicAmount.cc b/tests/numerics/BasicAmount.cc index de249ae5..aed682a6 100644 --- a/tests/numerics/BasicAmount.cc +++ b/tests/numerics/BasicAmount.cc @@ -3,10 +3,10 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicAmountTestCase, "numerics"); void BasicAmountTestCase::setUp() { - ledger::initialize(); + ledger::set_session_context(&session); } void BasicAmountTestCase::tearDown() { - ledger::shutdown(); + ledger::set_session_context(); } void BasicAmountTestCase::testConstructors() @@ -17,8 +17,8 @@ void BasicAmountTestCase::testConstructors() amount_t x3(123.456); amount_t x5("123456"); amount_t x6("123.456"); - amount_t x7(string("123456")); - amount_t x8(string("123.456")); + amount_t x7(std::string("123456")); + amount_t x8(std::string("123.456")); amount_t x9(x3); amount_t x10(x6); amount_t x11(x8); diff --git a/tests/numerics/BasicAmount.h b/tests/numerics/BasicAmount.h index 12449e49..4d11821e 100644 --- a/tests/numerics/BasicAmount.h +++ b/tests/numerics/BasicAmount.h @@ -33,6 +33,8 @@ class BasicAmountTestCase : public CPPUNIT_NS::TestCase CPPUNIT_TEST_SUITE_END(); public: + ledger::session_t session; + BasicAmountTestCase() {} virtual ~BasicAmountTestCase() {} diff --git a/tests/numerics/Commodity.cc b/tests/numerics/Commodity.cc index e7e2a18c..25da9d42 100644 --- a/tests/numerics/Commodity.cc +++ b/tests/numerics/Commodity.cc @@ -3,10 +3,10 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CommodityTestCase, "numerics"); void CommodityTestCase::setUp() { - ledger::initialize(); + ledger::set_session_context(&session); } void CommodityTestCase::tearDown() { - ledger::shutdown(); + ledger::set_session_context(); } void CommodityTestCase::testPriceHistory() @@ -32,8 +32,13 @@ void CommodityTestCase::testPriceHistory() aapl.add_price(mar01_07, amount_t("$19.50")); aapl.add_price(apr15_07, amount_t("$21.22")); - assertEqual(amount_t("$1831.83"), x1.value(feb28_07sbm)); - assertEqual(amount_t("$2124.12"), x1.value(now)); + optional<amount_t> amt1 = x1.value(feb28_07sbm); + assertTrue(amt1); + assertEqual(amount_t("$1831.83"), *amt1); + + optional<amount_t> amt2 = x1.value(now); + assertTrue(amt2); + assertEqual(amount_t("$2124.12"), *amt2); assertValid(x1); } diff --git a/tests/numerics/Commodity.h b/tests/numerics/Commodity.h index dafa03e9..aebe9a9e 100644 --- a/tests/numerics/Commodity.h +++ b/tests/numerics/Commodity.h @@ -15,6 +15,8 @@ class CommodityTestCase : public CPPUNIT_NS::TestCase CPPUNIT_TEST_SUITE_END(); public: + ledger::session_t session; + CommodityTestCase() {} virtual ~CommodityTestCase() {} diff --git a/tests/numerics/CommodityAmount.cc b/tests/numerics/CommodityAmount.cc index e443d6a1..3b38ea96 100644 --- a/tests/numerics/CommodityAmount.cc +++ b/tests/numerics/CommodityAmount.cc @@ -6,7 +6,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CommodityAmountTestCase, "numerics"); void CommodityAmountTestCase::setUp() { - ledger::initialize(); + ledger::set_session_context(&session); // Cause the display precision for dollars to be initialized to 2. amount_t x1("$1.00"); @@ -17,7 +17,8 @@ void CommodityAmountTestCase::setUp() void CommodityAmountTestCase::tearDown() { amount_t::full_strings = false; - ledger::shutdown(); + + ledger::set_session_context(); } void CommodityAmountTestCase::testConstructors() diff --git a/tests/numerics/CommodityAmount.h b/tests/numerics/CommodityAmount.h index 5ffa7810..d80a3e15 100644 --- a/tests/numerics/CommodityAmount.h +++ b/tests/numerics/CommodityAmount.h @@ -28,6 +28,8 @@ class CommodityAmountTestCase : public CPPUNIT_NS::TestCase CPPUNIT_TEST_SUITE_END(); public: + ledger::session_t session; + CommodityAmountTestCase() {} virtual ~CommodityAmountTestCase() {} |