summaryrefslogtreecommitdiff
path: root/test/unit/t_balance.cc
diff options
context:
space:
mode:
authortripun <tripun@gmail.com>2014-08-11 01:17:08 +0530
committertripun <tripun@gmail.com>2014-08-11 21:01:25 +0530
commite94efddfb60bd07525865658b83c324de446fe7d (patch)
treeb9b82a525da5a939f5c208c7f706545072b369f0 /test/unit/t_balance.cc
parent264f8c553cefb328debaa07b82b00a95a4a5e644 (diff)
downloadfork-ledger-e94efddfb60bd07525865658b83c324de446fe7d.tar.gz
fork-ledger-e94efddfb60bd07525865658b83c324de446fe7d.tar.bz2
fork-ledger-e94efddfb60bd07525865658b83c324de446fe7d.zip
add unit test Ceiling for balance_t
Diffstat (limited to 'test/unit/t_balance.cc')
-rw-r--r--test/unit/t_balance.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc
index d9242929..104e605e 100644
--- a/test/unit/t_balance.cc
+++ b/test/unit/t_balance.cc
@@ -340,4 +340,47 @@ BOOST_AUTO_TEST_CASE(testAbs)
BOOST_CHECK(b2.valid());
}
+BOOST_AUTO_TEST_CASE(testCeiling)
+{
+ amount_t a1("0.00");
+ amount_t a2("$ 123.123");
+ amount_t a3("EUR 456.56");
+ amount_t a4(-a1);
+ amount_t a5(-a2);
+ amount_t a6(-a3);
+
+ balance_t b0;
+ balance_t b1;
+ balance_t b2;
+ balance_t b3;
+ balance_t b4;
+
+ b1 += a1;
+ b1 += a2;
+ b1 += a3;
+ b2 += -a1;
+ b2 += -a2;
+ b2 += -a3;
+
+ b3 += a1.ceilinged();
+ b3 += a2.ceilinged();
+ b3 += a3.ceilinged();
+ b4 += a4.ceilinged();
+ b4 += a5.ceilinged();
+ b4 += a6.ceilinged();
+
+ BOOST_CHECK_EQUAL(b0.ceilinged(), b0);
+ BOOST_CHECK_EQUAL(b2.ceilinged(), b4);
+ BOOST_CHECK_EQUAL(b1.ceilinged(), b3);
+
+ b1.in_place_ceiling();
+ 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()