diff options
author | tripun <tripun@gmail.com> | 2014-08-10 23:32:11 +0530 |
---|---|---|
committer | tripun <tripun@gmail.com> | 2014-08-11 21:01:25 +0530 |
commit | 2db0bc9bf908ca1c1ba2c90a2e2d81d03d3e311a (patch) | |
tree | c5335fb8afe42c995c1b82a4d5434d9316ee739c /test/unit/t_balance.cc | |
parent | b9aef7b1ec3807149956fd0fd8567395064c7ad8 (diff) | |
download | fork-ledger-2db0bc9bf908ca1c1ba2c90a2e2d81d03d3e311a.tar.gz fork-ledger-2db0bc9bf908ca1c1ba2c90a2e2d81d03d3e311a.tar.bz2 fork-ledger-2db0bc9bf908ca1c1ba2c90a2e2d81d03d3e311a.zip |
add test for multiplication
Diffstat (limited to 'test/unit/t_balance.cc')
-rw-r--r-- | test/unit/t_balance.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc index eb47993d..1856ddb3 100644 --- a/test/unit/t_balance.cc +++ b/test/unit/t_balance.cc @@ -190,4 +190,49 @@ BOOST_AUTO_TEST_CASE(testEqaulity) BOOST_CHECK(b7.valid()); } +BOOST_AUTO_TEST_CASE(testMultiplication) +{ + amount_t a0; + amount_t a1("0.00"); + + balance_t b0; + balance_t b1(1.00); + balance_t b2(2UL); + balance_t b3("CAD -3"); + balance_t b4("EUR 4.99999"); + balance_t b5("$1"); + balance_t b6; + + BOOST_CHECK_EQUAL(b1 *= 2.00, amount_t(2.00)); + BOOST_CHECK_EQUAL(b2 *= 2L, amount_t(4L)); + BOOST_CHECK_EQUAL(b2 *= 2UL, amount_t(8UL)); + BOOST_CHECK_EQUAL(b3 *= amount_t("-8 CAD"), amount_t("CAD 24")); + BOOST_CHECK_EQUAL(b0 *= 2UL, b0); + BOOST_CHECK_EQUAL(b0 *= a1, a1); + + b6 += b3; + b3 += b4; + b3 += b5; + b3 *= 2L; + b6 *= 2L; + b4 *= 2L; + b5 *= 2L; + b6 += b4; + b6 += b5; + + BOOST_CHECK_EQUAL(b3, b6); + + BOOST_CHECK_THROW(b1 *= a0 , balance_error); + BOOST_CHECK_THROW(b4 *= amount_t("1 CAD") , balance_error); + BOOST_CHECK_THROW(b3 *= amount_t("1 CAD") , balance_error); + + BOOST_CHECK(b0.valid()); + BOOST_CHECK(b1.valid()); + BOOST_CHECK(b2.valid()); + BOOST_CHECK(b3.valid()); + BOOST_CHECK(b4.valid()); + BOOST_CHECK(b5.valid()); + BOOST_CHECK(b6.valid()); +} + BOOST_AUTO_TEST_SUITE_END() |