diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-17 07:33:56 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:36 -0400 |
commit | f63ce064612b0fb98b21ff3e36203c56fb081a7c (patch) | |
tree | 93765cc9138df581e5f0e879f2aa1a813782e0d2 /tests/corelib/numerics | |
parent | f5956311af0425b6d1fd76752e84bd81a4c8ccd1 (diff) | |
download | fork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.tar.gz fork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.tar.bz2 fork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.zip |
Added stubs for several more commodity tests.
Diffstat (limited to 'tests/corelib/numerics')
-rw-r--r-- | tests/corelib/numerics/CommodityAmount.cc | 53 | ||||
-rw-r--r-- | tests/corelib/numerics/CommodityAmount.h | 8 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/corelib/numerics/CommodityAmount.cc b/tests/corelib/numerics/CommodityAmount.cc index b2429fc3..0eca3140 100644 --- a/tests/corelib/numerics/CommodityAmount.cc +++ b/tests/corelib/numerics/CommodityAmount.cc @@ -91,6 +91,10 @@ void CommodityAmountTestCase::testNegation() assertEqual(amount_t("-123.45€"), - x9); assertEqual(amount_t("123.45€"), - x10); + assertEqual(amount_t("$-123.45"), x1.negated()); + assertEqual(amount_t("$123.45"), x2.negated()); + assertEqual(amount_t("$123.45"), x3.negated()); + assertEqual(std::string("$-123.45"), (- x1).to_string()); assertEqual(std::string("$123.45"), (- x2).to_string()); assertEqual(std::string("$123.45"), (- x3).to_string()); @@ -102,6 +106,14 @@ void CommodityAmountTestCase::testNegation() assertEqual(std::string("-123.45€"), (- x9).to_string()); assertEqual(std::string("123.45€"), (- x10).to_string()); + x1.negate(); + x2.negate(); + x3.negate(); + + assertEqual(amount_t("$-123.45"), x1); + assertEqual(amount_t("$123.45"), x2); + assertEqual(amount_t("$123.45"), x3); + assertValid(x1); assertValid(x2); assertValid(x3); @@ -163,6 +175,7 @@ void CommodityAmountTestCase::testAssignment() void CommodityAmountTestCase::testEquality() { + amount_t x0; amount_t x1 = "$123.45"; amount_t x2 = "-$123.45"; amount_t x3 = "$-123.45"; @@ -174,6 +187,14 @@ void CommodityAmountTestCase::testEquality() amount_t x9 = "123.45€"; amount_t x10 = "-123.45€"; + assertTrue(x0.null()); + assertTrue(x0.zero()); + assertTrue(x0.realzero()); + assertTrue(x0.sign() == 0); + assertTrue(x0.compare(x1) < 0); + assertTrue(x0.compare(x2) > 0); + assertTrue(x0.compare(x0) == 0); + assertTrue(x1 != x2); assertTrue(x1 != x4); assertTrue(x1 != x7); @@ -184,6 +205,7 @@ void CommodityAmountTestCase::testEquality() assertTrue(x7 == - x8); assertTrue(x9 == - x10); + assertValid(x0); assertValid(x1); assertValid(x2); assertValid(x3); @@ -497,10 +519,20 @@ void CommodityAmountTestCase::testRound() assertEqual(amount_t("$-9876.5"), x4.round(1)); assertEqual(amount_t("$-9877"), x4.round(0)); + amount_t x5("$123.45"); + + x5 *= 100.12; + + assertEqual(internalAmount("$12359.814"), x5); + assertEqual(std::string("$12359.81"), x5.to_string()); + assertEqual(std::string("$12359.814"), x5.to_fullstring()); + assertEqual(std::string("$12359.814"), x5.unround().to_string()); + assertValid(x1); assertValid(x2); assertValid(x3); assertValid(x4); + assertValid(x5); } void CommodityAmountTestCase::testDisplayRound() @@ -633,6 +665,26 @@ void CommodityAmountTestCase::testAbs() assertValid(x2); } +void CommodityAmountTestCase::testPriceHistory() +{ + // jww (2007-04-17): tbd +} + +void CommodityAmountTestCase::testLots() +{ + // jww (2007-04-17): tbd +} + +void CommodityAmountTestCase::testScalingBase() +{ + // jww (2007-04-17): tbd +} + +void CommodityAmountTestCase::testReduction() +{ + // jww (2007-04-17): tbd +} + void CommodityAmountTestCase::testPrinting() { amount_t x0; @@ -673,3 +725,4 @@ void CommodityAmountTestCase::testPrinting() assertValid(x1); assertValid(x2); } + diff --git a/tests/corelib/numerics/CommodityAmount.h b/tests/corelib/numerics/CommodityAmount.h index 5ffa7810..70d55de4 100644 --- a/tests/corelib/numerics/CommodityAmount.h +++ b/tests/corelib/numerics/CommodityAmount.h @@ -24,6 +24,10 @@ class CommodityAmountTestCase : public CPPUNIT_NS::TestCase CPPUNIT_TEST(testSign); CPPUNIT_TEST(testAbs); CPPUNIT_TEST(testPrinting); + CPPUNIT_TEST(testPriceHistory); + CPPUNIT_TEST(testLots); + CPPUNIT_TEST(testScalingBase); + CPPUNIT_TEST(testReduction); CPPUNIT_TEST_SUITE_END(); @@ -51,6 +55,10 @@ public: void testSign(); void testAbs(); void testPrinting(); + void testPriceHistory(); + void testLots(); + void testScalingBase(); + void testReduction(); private: CommodityAmountTestCase(const CommodityAmountTestCase ©); |