diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-19 13:33:47 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2011-02-04 03:43:33 -0500 |
commit | 2a2c3c1ceca27bc1e0ce6408459ddbf8dd980fae (patch) | |
tree | 8cf5fd66d4995b72e4636a7df40febee5e80817c /test/unit/t_times.cc | |
parent | c9730d781c33e5cbece892f78008e379cfabe2e2 (diff) | |
download | fork-ledger-2a2c3c1ceca27bc1e0ce6408459ddbf8dd980fae.tar.gz fork-ledger-2a2c3c1ceca27bc1e0ce6408459ddbf8dd980fae.tar.bz2 fork-ledger-2a2c3c1ceca27bc1e0ce6408459ddbf8dd980fae.zip |
Use Boost.Test instead of CppUnit
Diffstat (limited to 'test/unit/t_times.cc')
-rw-r--r-- | test/unit/t_times.cc | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/test/unit/t_times.cc b/test/unit/t_times.cc index aaf31263..c6251664 100644 --- a/test/unit/t_times.cc +++ b/test/unit/t_times.cc @@ -1,25 +1,26 @@ -#include <system.hh> +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE util +#include <boost/test/unit_test.hpp> -#include "t_times.h" +#include <system.hh> #include "utils.h" #include "times.h" using namespace ledger; -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(DateTimeTestCase, "util"); - -void DateTimeTestCase::setUp() -{ - times_initialize(); -} +struct times_fixture { + times_fixture() { + times_initialize(); + } + ~times_fixture() { + times_shutdown(); + } +}; -void DateTimeTestCase::tearDown() -{ - times_shutdown(); -} +BOOST_FIXTURE_TEST_SUITE(times, times_fixture) -void DateTimeTestCase::testConstructors() +BOOST_AUTO_TEST_CASE(testConstructors) { #ifndef NOT_FOR_PYTHON std::time_t now = std::time(NULL); @@ -71,51 +72,51 @@ void DateTimeTestCase::testConstructors() #endif // NOT_FOR_PYTHON #ifndef NOT_FOR_PYTHON - assertTrue(d0.is_not_a_date()); - assertFalse(d1.is_not_a_date()); - assertFalse(d4.is_not_a_date()); + BOOST_CHECK(d0.is_not_a_date()); + BOOST_CHECK(! d1.is_not_a_date()); + BOOST_CHECK(! d4.is_not_a_date()); #endif // NOT_FOR_PYTHON - assertTrue(CURRENT_DATE() > d1); - assertTrue(CURRENT_DATE() > d4); + BOOST_CHECK(CURRENT_DATE() > d1); + BOOST_CHECK(CURRENT_DATE() > d4); #ifndef NOT_FOR_PYTHON #if 0 - assertEqual(d3, d15); + BOOST_CHECK_EQUAL(d3, d15); #endif #endif // NOT_FOR_PYTHON - assertEqual(d4, d6); - assertEqual(d4, d8); - assertEqual(d5, d7); - assertEqual(d5, d9); + BOOST_CHECK_EQUAL(d4, d6); + BOOST_CHECK_EQUAL(d4, d8); + BOOST_CHECK_EQUAL(d5, d7); + BOOST_CHECK_EQUAL(d5, d9); #ifndef NOT_FOR_PYTHON #if 0 - assertEqual(d10, d11); - assertEqual(d12, d13); + BOOST_CHECK_EQUAL(d10, d11); + BOOST_CHECK_EQUAL(d12, d13); - assertThrow(parse_date("2007/02/29"), boost::gregorian::bad_day_of_month); - //assertThrow(parse_date("2007/13/01"), datetime_error); - //assertThrow(parse_date("2007/00/01"), datetime_error); - assertThrow(parse_date("2007/01/00"), boost::gregorian::bad_day_of_month); - //assertThrow(parse_date("2007/00/00"), boost::gregorian::bad_day_of_month); - //assertThrow(parse_date("2007/05/32"), boost::gregorian::bad_day_of_month); - - assertThrow(parse_date("2006x/12/25"), datetime_error); - assertThrow(parse_date("2006/12x/25"), datetime_error); - assertThrow(parse_date("2006/12/25x"), datetime_error); - - assertThrow(parse_date("feb/12/25"), datetime_error); - assertThrow(parse_date("2006/mon/25"), datetime_error); - assertThrow(parse_date("2006/12/web"), datetime_error); - - assertThrow(parse_date("12*25"), datetime_error); - - assertThrow(parse_date("tuf"), datetime_error); - assertThrow(parse_date("tufsday"), datetime_error); - assertThrow(parse_date("fec"), datetime_error); - assertThrow(parse_date("fecruary"), datetime_error); - assertThrow(parse_date("207x"), datetime_error); - assertThrow(parse_date("hello"), datetime_error); + BOOST_CHECK_THROW(parse_date("2007/02/29"), boost::gregorian::bad_day_of_month); + //BOOST_CHECK_THROW(parse_date("2007/13/01"), datetime_error); + //BOOST_CHECK_THROW(parse_date("2007/00/01"), datetime_error); + BOOST_CHECK_THROW(parse_date("2007/01/00"), boost::gregorian::bad_day_of_month); + //BOOST_CHECK_THROW(parse_date("2007/00/00"), boost::gregorian::bad_day_of_month); + //BOOST_CHECK_THROW(parse_date("2007/05/32"), boost::gregorian::bad_day_of_month); + + BOOST_CHECK_THROW(parse_date("2006x/12/25"), datetime_error); + BOOST_CHECK_THROW(parse_date("2006/12x/25"), datetime_error); + BOOST_CHECK_THROW(parse_date("2006/12/25x"), datetime_error); + + BOOST_CHECK_THROW(parse_date("feb/12/25"), datetime_error); + BOOST_CHECK_THROW(parse_date("2006/mon/25"), datetime_error); + BOOST_CHECK_THROW(parse_date("2006/12/web"), datetime_error); + + BOOST_CHECK_THROW(parse_date("12*25"), datetime_error); + + BOOST_CHECK_THROW(parse_date("tuf"), datetime_error); + BOOST_CHECK_THROW(parse_date("tufsday"), datetime_error); + BOOST_CHECK_THROW(parse_date("fec"), datetime_error); + BOOST_CHECK_THROW(parse_date("fecruary"), datetime_error); + BOOST_CHECK_THROW(parse_date("207x"), datetime_error); + BOOST_CHECK_THROW(parse_date("hello"), datetime_error); d1 = parse_date("2002-02-02"); d1 = parse_date("2002/02/02"); @@ -160,7 +161,9 @@ void DateTimeTestCase::testConstructors() d1 = parse_date("2002-02-02 12p"); d1 = parse_date("2002-02-02 12a"); - assertValid(d1); + BOOST_CHECK(d1.valid()); #endif // NOT_FOR_PYTHON #endif } + +BOOST_AUTO_TEST_SUITE_END() |