diff options
author | tripun <tripun@gmail.com> | 2014-08-18 02:33:26 +0530 |
---|---|---|
committer | tripun <tripun@gmail.com> | 2014-08-18 02:46:36 +0530 |
commit | c87dd21912b1ecd4cab3aba7de2e5412ce54281b (patch) | |
tree | c7f2c9e0ae3fe430dc2f333dd65a5c4a7cdea1be /test/unit | |
parent | f1c3f36e3bf45c9e74359bd64ff91f1aa4a5f525 (diff) | |
download | fork-ledger-c87dd21912b1ecd4cab3aba7de2e5412ce54281b.tar.gz fork-ledger-c87dd21912b1ecd4cab3aba7de2e5412ce54281b.tar.bz2 fork-ledger-c87dd21912b1ecd4cab3aba7de2e5412ce54281b.zip |
add unit test Negation for value
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/t_value.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/unit/t_value.cc b/test/unit/t_value.cc index eae71ea9..2fbfda3f 100644 --- a/test/unit/t_value.cc +++ b/test/unit/t_value.cc @@ -601,5 +601,51 @@ BOOST_AUTO_TEST_CASE(testForZero) BOOST_CHECK(v15.valid()); } +BOOST_AUTO_TEST_CASE(testNegation) +{ + value_t v1; + value_t v2(true); + value_t v3(boost::posix_time::from_time_t(time_t(NULL))); + value_t v4(date_t(parse_date("2014/08/09"))); + value_t v5(2L); + value_t v6(0UL); + value_t v7(1.00); + value_t v8(amount_t("4 GBP")); + value_t v9(balance_t("4 GBP")); + value_t v10(mask_t("")); + value_t v11(new value_t::sequence_t()); + value_t v12(string("$1")); + value_t v13("$-1"); + value_t v14("comment", true); + value_t v15(string("comment"), true); + + BOOST_CHECK_THROW(v1.negated(), value_error); + BOOST_CHECK_EQUAL(v2.negated(), value_t(false)); + v5.in_place_negate(); + BOOST_CHECK_EQUAL(v5, value_t(-2L)); + v8.in_place_negate(); + v9.in_place_negate(); + BOOST_CHECK_EQUAL(v8, v9); + BOOST_CHECK_THROW(v10.negated(), value_error); + BOOST_CHECK_EQUAL(-v12, v13); + BOOST_CHECK_THROW(-v14, value_error); + + BOOST_CHECK(v1.valid()); + BOOST_CHECK(v2.valid()); + BOOST_CHECK(v3.valid()); + BOOST_CHECK(v4.valid()); + BOOST_CHECK(v5.valid()); + BOOST_CHECK(v6.valid()); + BOOST_CHECK(v7.valid()); + BOOST_CHECK(v8.valid()); + BOOST_CHECK(v9.valid()); + BOOST_CHECK(v10.valid()); + BOOST_CHECK(v11.valid()); + BOOST_CHECK(v12.valid()); + BOOST_CHECK(v13.valid()); + BOOST_CHECK(v14.valid()); + BOOST_CHECK(v15.valid()); +} + BOOST_AUTO_TEST_SUITE_END() |