diff options
author | tripun <tripun@gmail.com> | 2014-08-11 02:02:05 +0530 |
---|---|---|
committer | tripun <tripun@gmail.com> | 2014-08-11 21:01:25 +0530 |
commit | c5f41b85195cb3f671888289071d26531f198a80 (patch) | |
tree | 8ca6769c0da8efd863e7dd8a3bc0664c5c7c93ee /test/unit | |
parent | 3a35d16c289e4f499fced36297e1313084e4d8ab (diff) | |
download | fork-ledger-c5f41b85195cb3f671888289071d26531f198a80.tar.gz fork-ledger-c5f41b85195cb3f671888289071d26531f198a80.tar.bz2 fork-ledger-c5f41b85195cb3f671888289071d26531f198a80.zip |
add unit test Round for balance_t
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/t_balance.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc index 19a1bd69..8f21e23f 100644 --- a/test/unit/t_balance.cc +++ b/test/unit/t_balance.cc @@ -426,4 +426,54 @@ BOOST_AUTO_TEST_CASE(testFloor) BOOST_CHECK(b4.valid()); } +BOOST_AUTO_TEST_CASE(testRound) +{ + amount_t a1("0.00"); + amount_t a2("$ 123.123"); + amount_t a3("EUR 456.567"); + amount_t a4("0.00"); + amount_t a5("$ 123.12"); + amount_t a6("EUR 456.57"); + + balance_t b0; + balance_t b1; + balance_t b2; + balance_t b3; + balance_t b4; + + b1 += a1; + b1 += a2; + b1 += a3; + b2 += a4; + b2 += a5; + b2 += a6; + + a1.in_place_roundto(2); + a2.in_place_roundto(2); + a3.in_place_roundto(2); + a4.in_place_roundto(2); + a5.in_place_roundto(2); + a6.in_place_roundto(2); + + b3 += a1; + b3 += a2; + b3 += a3; + b4 += a4; + b4 += a5; + b4 += a6; + + BOOST_CHECK_EQUAL(b0.rounded(), b0); + BOOST_CHECK_EQUAL(b2.rounded(), b4); + BOOST_CHECK_EQUAL(b1.rounded(), b4); + + b1.in_place_round(); + BOOST_CHECK_EQUAL(b1, b3); + + BOOST_CHECK(b0.valid()); + BOOST_CHECK(b1.valid()); + BOOST_CHECK(b2.valid()); + BOOST_CHECK(b3.valid()); + BOOST_CHECK(b4.valid()); +} + BOOST_AUTO_TEST_SUITE_END() |