diff options
author | tripun <tripun@gmail.com> | 2014-08-17 18:53:30 +0530 |
---|---|---|
committer | tripun <tripun@gmail.com> | 2014-08-17 18:53:30 +0530 |
commit | 2e5520a5cfcbcd17a4eebbc5a180fe465796fe55 (patch) | |
tree | 74e46ad2f9e2aba58804d7f1a59b2dea29356c36 /test/unit/t_value.cc | |
parent | 6c7a951a2da1e2aeb395930b573b1bc0f531efaa (diff) | |
download | fork-ledger-2e5520a5cfcbcd17a4eebbc5a180fe465796fe55.tar.gz fork-ledger-2e5520a5cfcbcd17a4eebbc5a180fe465796fe55.tar.bz2 fork-ledger-2e5520a5cfcbcd17a4eebbc5a180fe465796fe55.zip |
add unit test of equality for value
Diffstat (limited to 'test/unit/t_value.cc')
-rw-r--r-- | test/unit/t_value.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/unit/t_value.cc b/test/unit/t_value.cc index b6068652..8d398214 100644 --- a/test/unit/t_value.cc +++ b/test/unit/t_value.cc @@ -103,5 +103,69 @@ BOOST_AUTO_TEST_CASE(testAssignment) BOOST_CHECK(v15.valid()); } +BOOST_AUTO_TEST_CASE(testEquality) +{ + struct tm localtime; + strptime("10 February 2010", "%d %b %Y", &localtime); + time_t time_var = mktime(&localtime); + + value_t v1; + value_t v2(true); + value_t v3(boost::posix_time::from_time_t(time_var)); + value_t v4(date_t(parse_date("2014/08/14"))); + value_t v5(2L); + value_t v6(2UL); + value_t v7(1.00); + value_t v8(amount_t("4 GBP")); + value_t v9(balance_t("4 GBP")); + value_t v10(mask_t("regex")); + value_t v11(new value_t::sequence_t()); + value_t v12(string("$1")); + value_t v13("2 CAD"); + value_t v14("comment",true); + value_t v15(string("comment"),true); + value_t v16; + + BOOST_CHECK_EQUAL(v1, value_t()); + BOOST_CHECK_EQUAL(v2, value_t(true)); + BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::from_time_t(time_var))); + BOOST_CHECK(!(v4 == value_t(date_t(parse_date("2014/08/15"))))); + + value_t v19(amount_t("2")); + value_t v20(balance_t("2")); + BOOST_CHECK_EQUAL(v5, v6); + BOOST_CHECK_EQUAL(v5, v19); + BOOST_CHECK_EQUAL(v5, v20); + BOOST_CHECK(v19 == v5); + BOOST_CHECK(v19 == v20); + BOOST_CHECK(v19 == value_t(amount_t("2"))); + BOOST_CHECK(v20 == v5); + BOOST_CHECK(v20 == v19); + BOOST_CHECK(v20 == value_t(balance_t(2L))); + BOOST_CHECK(v14 == v15); + BOOST_CHECK(v10 == value_t(mask_t("regex"))); + BOOST_CHECK(v11 == value_t(new value_t::sequence_t())); + + BOOST_CHECK_THROW(v8 == v10, 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_CHECK(v19.valid()); + BOOST_CHECK(v20.valid()); +} + BOOST_AUTO_TEST_SUITE_END() |