From 84b9ca73aac73b6c7938abea91f8f550a0fad101 Mon Sep 17 00:00:00 2001 From: tripun Date: Mon, 11 Aug 2014 02:46:01 +0530 Subject: add unit test printing for balance_t --- test/unit/t_balance.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test/unit') diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc index c4ec2f31..eac230be 100644 --- a/test/unit/t_balance.cc +++ b/test/unit/t_balance.cc @@ -522,4 +522,35 @@ BOOST_AUTO_TEST_CASE(testForZero) BOOST_CHECK(b1.valid()); } +BOOST_AUTO_TEST_CASE(testPrinting) +{ + amount_t a1("0.00"); + amount_t a2("$ 123"); + amount_t a3("EUR 456"); + + balance_t b0; + balance_t b1; + + b1 += a1; + b1 += a2; + b1 += a3; + + { + std::ostringstream bufstr; + b0.dump(bufstr); + BOOST_CHECK_EQUAL(std::string("BALANCE()"), bufstr.str()); + } + + { + std::ostringstream bufstr; + b1.dump(bufstr); + + BOOST_CHECK_EQUAL(std::string("BALANCE(EUR 456, $ 123.00)"), + bufstr.str()); + } + + BOOST_CHECK(b0.valid()); + BOOST_CHECK(b1.valid()); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3