summaryrefslogtreecommitdiff
path: root/test/unit/t_balance.cc
diff options
context:
space:
mode:
authortripun <tripun@gmail.com>2014-08-11 00:46:32 +0530
committertripun <tripun@gmail.com>2014-08-11 21:01:25 +0530
commit264f8c553cefb328debaa07b82b00a95a4a5e644 (patch)
treee60e3c65282e54ffda961f6c2de4ff2f3637e1b0 /test/unit/t_balance.cc
parentc24fbd6dfb10904b01d048c8b7787f5ae7cb5eb2 (diff)
downloadfork-ledger-264f8c553cefb328debaa07b82b00a95a4a5e644.tar.gz
fork-ledger-264f8c553cefb328debaa07b82b00a95a4a5e644.tar.bz2
fork-ledger-264f8c553cefb328debaa07b82b00a95a4a5e644.zip
add unit test Absolute for balance_t
Diffstat (limited to 'test/unit/t_balance.cc')
-rw-r--r--test/unit/t_balance.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc
index 239bc626..d9242929 100644
--- a/test/unit/t_balance.cc
+++ b/test/unit/t_balance.cc
@@ -315,4 +315,29 @@ BOOST_AUTO_TEST_CASE(testNegation)
BOOST_CHECK(b3.valid());
}
+BOOST_AUTO_TEST_CASE(testAbs)
+{
+ amount_t a1("0.00");
+ amount_t a2("$ 123");
+ amount_t a3("EUR 456");
+
+ balance_t b0;
+ balance_t b1;
+ balance_t b2;
+
+ b1 += a1;
+ b1 += a2;
+ b1 += a3;
+ b2 += -a1;
+ b2 += -a2;
+ b2 += -a3;
+
+ BOOST_CHECK_EQUAL(b0.abs(), b0);
+ BOOST_CHECK_EQUAL(b2.abs(), b1.abs());
+
+ BOOST_CHECK(b0.valid());
+ BOOST_CHECK(b1.valid());
+ BOOST_CHECK(b2.valid());
+}
+
BOOST_AUTO_TEST_SUITE_END()