diff options
author | tripun <tripun@gmail.com> | 2014-08-11 00:39:41 +0530 |
---|---|---|
committer | tripun <tripun@gmail.com> | 2014-08-11 21:01:25 +0530 |
commit | c24fbd6dfb10904b01d048c8b7787f5ae7cb5eb2 (patch) | |
tree | ac5e34bcedf9cfe294c35515892353964103d2c1 /test/unit | |
parent | 763c8c1162c9e2318e5e78c8b71e71607bcfeeef (diff) | |
download | fork-ledger-c24fbd6dfb10904b01d048c8b7787f5ae7cb5eb2.tar.gz fork-ledger-c24fbd6dfb10904b01d048c8b7787f5ae7cb5eb2.tar.bz2 fork-ledger-c24fbd6dfb10904b01d048c8b7787f5ae7cb5eb2.zip |
add unit test negation for balance_t
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/t_balance.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc index b7f68b14..239bc626 100644 --- a/test/unit/t_balance.cc +++ b/test/unit/t_balance.cc @@ -280,4 +280,39 @@ BOOST_AUTO_TEST_CASE(testDivision) BOOST_CHECK(b6.valid()); } +BOOST_AUTO_TEST_CASE(testNegation) +{ + amount_t a1("0.00"); + amount_t a2("$ 123"); + amount_t a3("EUR 456"); + + balance_t b0; + balance_t b1; + balance_t b2; + balance_t b3; + + b1 += a1; + b1 += a2; + b1 += a3; + b2 += -a1; + b2 += -a2; + b2 += -a3; + b3 = -b1; + + BOOST_CHECK_EQUAL(b0.negated(), b0); + BOOST_CHECK_EQUAL(b2, b3); + BOOST_CHECK_EQUAL(b2, -b1); + BOOST_CHECK_EQUAL(b2.negated(), b1); + + b2.in_place_negate(); + + BOOST_CHECK_EQUAL(b2, b1); + BOOST_CHECK_EQUAL(b1, -b3); + + BOOST_CHECK(b0.valid()); + BOOST_CHECK(b1.valid()); + BOOST_CHECK(b2.valid()); + BOOST_CHECK(b3.valid()); +} + BOOST_AUTO_TEST_SUITE_END() |