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 | |
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')
-rw-r--r-- | test/DataTests.cc | 3 | ||||
-rw-r--r-- | test/ExprTests.cc | 3 | ||||
-rw-r--r-- | test/MathTests.cc | 3 | ||||
-rw-r--r-- | test/ReportTests.cc | 3 | ||||
-rw-r--r-- | test/UnitTests.cc | 116 | ||||
-rw-r--r-- | test/UnitTests.h | 20 | ||||
-rw-r--r-- | test/UtilTests.cc | 3 | ||||
-rwxr-xr-x | test/convert.py | 56 | ||||
-rwxr-xr-x | test/prove.sh | 11 | ||||
-rwxr-xr-x | test/runtests.py | 180 | ||||
-rw-r--r-- | test/unit/t_amount.cc | 1442 | ||||
-rw-r--r-- | test/unit/t_amount.h | 105 | ||||
-rw-r--r-- | test/unit/t_balance.cc | 44 | ||||
-rw-r--r-- | test/unit/t_balance.h | 28 | ||||
-rw-r--r-- | test/unit/t_commodity.cc | 63 | ||||
-rw-r--r-- | test/unit/t_commodity.h | 28 | ||||
-rw-r--r-- | test/unit/t_expr.cc | 226 | ||||
-rw-r--r-- | test/unit/t_expr.h | 60 | ||||
-rw-r--r-- | test/unit/t_times.cc | 101 | ||||
-rw-r--r-- | test/unit/t_times.h | 28 | ||||
-rw-r--r-- | test/unit/t_utils.cc | 6 | ||||
-rw-r--r-- | test/unit/t_utils.h | 28 |
22 files changed, 988 insertions, 1569 deletions
diff --git a/test/DataTests.cc b/test/DataTests.cc deleted file mode 100644 index 8fa1db8a..00000000 --- a/test/DataTests.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("data"); diff --git a/test/ExprTests.cc b/test/ExprTests.cc deleted file mode 100644 index d3f0a734..00000000 --- a/test/ExprTests.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("expr"); diff --git a/test/MathTests.cc b/test/MathTests.cc deleted file mode 100644 index c1e8c839..00000000 --- a/test/MathTests.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("math"); diff --git a/test/ReportTests.cc b/test/ReportTests.cc deleted file mode 100644 index 2fabbe9a..00000000 --- a/test/ReportTests.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("report"); diff --git a/test/UnitTests.cc b/test/UnitTests.cc deleted file mode 100644 index af3f6311..00000000 --- a/test/UnitTests.cc +++ /dev/null @@ -1,116 +0,0 @@ -#include <system.hh> - -#include <cppunit/CompilerOutputter.h> -#include <cppunit/TestResult.h> -#include <cppunit/TestResultCollector.h> -#include <cppunit/TestRunner.h> -#include <cppunit/TextTestProgressListener.h> -#include <cppunit/BriefTestProgressListener.h> -#include <cppunit/XmlOutputter.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "UnitTests.h" - -#include "utils.h" - -// Create the CppUnit registry - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("Framework"); - -// Create a sample test, which acts both as a template, and a -// verification that the basic framework is functioning. - -class UnitTests : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE( UnitTests ); - CPPUNIT_TEST( testInitialization ); - CPPUNIT_TEST_SUITE_END(); - -public: - UnitTests() {} - virtual ~UnitTests() {} - - virtual void setUp() {} - virtual void tearDown() {} - - void testInitialization() { - assertEqual(std::string("Hello, world!"), - std::string("Hello, world!")); - } - -private: - UnitTests( const UnitTests © ); - void operator =( const UnitTests © ); -}; - -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(UnitTests, "framework"); - -// Create the various runners and commence running the tests! - -int main(int argc, char* argv[]) -{ - int index = 1; - - if (argc > index && std::string(argv[index]) == "--verify") { -#if defined(VERIFY_ON) - ledger::verify_enabled = true; -#endif - index++; - } - - // Retreive test path from command line first argument. Default to - // "" which resolves to the top level suite. - std::string testPath = ((argc > index) ? std::string(argv[index]) : - std::string("")); - - // Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // Add a listener that collects test results - CPPUNIT_NS::TestResultCollector result; - controller.addListener(&result); - - // Add a listener that print dots as test run. -#if 1 - CPPUNIT_NS::TextTestProgressListener progress; -#else - CPPUNIT_NS::BriefTestProgressListener progress; -#endif - controller.addListener(&progress); - - // Add the top suite to the test runner - CPPUNIT_NS::TestRunner runner; - runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); - try { -#if defined(VERIFY_ON) - IF_VERIFY() - ledger::initialize_memory_tracing(); -#endif - - runner.run(controller, testPath); - -#if defined(VERIFY_ON) - IF_VERIFY() - ledger::shutdown_memory_tracing(); -#endif - -#if 1 - // Print test in a compiler compatible format. - CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut()); - outputter.write(); -#else - // Uncomment this for XML output - std::ofstream file("tests.xml"); - CPPUNIT_NS::XmlOutputter xml(&result, file); - xml.setStyleSheet("report.xsl"); - xml.write(); - file.close(); -#endif - } - catch (std::invalid_argument &e) { // Test path not resolved - CPPUNIT_NS::stdCOut() << "\nERROR: " << e.what() << "\n"; - return 0; - } - - return result.wasSuccessful() ? 0 : 1; -} diff --git a/test/UnitTests.h b/test/UnitTests.h deleted file mode 100644 index a7bfcf9e..00000000 --- a/test/UnitTests.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _UNITTESTS_H -#define _UNITTESTS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/Exception.h> -#include <cppunit/Portability.h> - -#define assertDoublesEqual(x,y,z,w) CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(x,y,z,w) -#define assertEqual(x,y) CPPUNIT_ASSERT_EQUAL(x,y) -#define assertNotEqual(x,y) CPPUNIT_ASSERT((x) != (y)) -#define assertTrue(x) CPPUNIT_ASSERT(x) -#define assertFalse(x) CPPUNIT_ASSERT(! (x)) -#define assertValid(x) CPPUNIT_ASSERT((x).valid()) -#define assertEqualMessage(x,y,z) CPPUNIT_ASSERT_EQUAL_MESSAGE(x,y,z) -#define assertMessage(x,y) CPPUNIT_ASSERT_MESSAGE(x,y) -#define assertThrow(x,y) CPPUNIT_ASSERT_THROW(x,y) - -#define internalAmount(x) amount_t::exact(x) - -#endif /* _UNITTESTS_H */ diff --git a/test/UtilTests.cc b/test/UtilTests.cc deleted file mode 100644 index f584db89..00000000 --- a/test/UtilTests.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("util"); diff --git a/test/convert.py b/test/convert.py index 05a62b7e..ae44b39f 100755 --- a/test/convert.py +++ b/test/convert.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -# convert.py: This script converts a C++ Ledger unit test into an equivalent -# Python unit test. +# convert.py: This script converts a Boost.Test unit test into an +# equivalent Python unit test. # -# Copyright (c) 2003-2009, John Wiegley. All rights reserved. +# Copyright (c) 2003-2010, John Wiegley. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -61,12 +61,10 @@ from datetime import * internalAmount = Amount.exact class %sTestCase(unittest.TestCase): - testSession = None - - def assertValid(self, amt): - self.assertTrue(amt.valid())''' % os.path.basename(base)) + testSession = None''' % os.path.basename(base)) not_for_python = 0 +class_name = None for line in fd.readlines(): if re.match('^#ifndef NOT_FOR_PYTHON', line): @@ -83,6 +81,32 @@ for line in fd.readlines(): continue if not re.search('assert', line): + match = re.match('^};', line) + if match: + continue + match = re.match('BOOST_.*_TEST_SUITE', line) + if match: + continue + + match = re.match('^struct (.*?) {', line) + if match: + class_name = match.group(1) + continue + + if class_name: + match = re.search('(~)?%s\(\) {' % class_name, line) + if match: + if match.group(1): + fo.write(' def tearDown(self):\n') + else: + fo.write(' def setUp(self):\n') + continue + + match = re.match('BOOST_AUTO_TEST_CASE\((.+?)\)', line) + if match: + fo.write(' def %s(self):\n' % match.group(1)) + continue + match = re.match('void [^:]+::(test[^(]+|setUp|tearDown)\(\)', line) if match: fo.write(' def %s(self):\n' % match.group(1)) @@ -105,19 +129,15 @@ for line in fd.readlines(): if match: line = ' %s = %s\n' % (match.group(2), match.group(3)) - line = re.sub('CPPUNIT_ASSERT', 'self.assertTrue', line) - line = re.sub('assertValid', 'self.assertValid', line) - line = re.sub('assertTrue', 'self.assertTrue', line) - line = re.sub('assertFalse', 'self.assertFalse', line) - line = re.sub('assertNotEqual', 'self.assertNotEqual', line) - line = re.sub('assertEqual', 'self.assertEqual', line) - line = re.sub('assertThrow\(([^,]+), ([^,)]+?)\)', + line = re.sub('BOOST_CHECK_NE', 'self.assertNotEqual', line) + line = re.sub('BOOST_CHECK_EQUAL', 'self.assertEqual', line) + line = re.sub('BOOST_CHECK_THROW\(([^,]+), ([^,)]+?)\)', 'self.assertRaises(\\2, lambda: \\1)', line) - #line = re.sub('optional<([^>]+?)>', '\\1', line) - line = re.sub('amount_t::precision_t\(([^)]+?)\)', '\\1', line) + line = re.sub('BOOST_CHECK', 'self.assertTrue', line) - # Determine this list automatically by scanning the class_ lines in - # src/py_*.cc + # jww (2010-06-20): Determine this list automatically by scanning + # the class_ lines in src/py_*.cc + line = re.sub('amount_t::precision_t\(([^)]+?)\)', '\\1', line) line = re.sub('amount_t::', 'Amount.', line) line = re.sub('Amount\.PARSE_', 'AmountParse.', line) line = re.sub('commodity_t\(([^)]+?)\)', '\\1', line) diff --git a/test/prove.sh b/test/prove.sh deleted file mode 100755 index 5dadca71..00000000 --- a/test/prove.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [ -n "$1" ]; then - ledger --seed=$1 --actual --args-only generate > /tmp/cout -else - ledger --actual --args-only generate > /tmp/cout -fi - -ledger -f /tmp/cout --actual --args-only print > /tmp/print - -diff -w -U3 /tmp/cout /tmp/print diff --git a/test/runtests.py b/test/runtests.py deleted file mode 100755 index 9afbd25d..00000000 --- a/test/runtests.py +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env python - -import random -import string -import signal -import os -import sys - -true, false = 1, 0 - -options = [ - "--account=TempAccount", - "--actual", - "--add-budget", - "--amount-data", - "--amount=a", - "--ansi", - "--ansi-invert", - "--average", - #"--balance-format", - "--basis", - "--begin=2004/01", - "--budget", - "--by-payee", - #"--cache=/tmp/cache", - "--cleared", - "--collapse", - "--comm-as-payee", - #"--csv-register-format", - "--current", - "--date-format=%Y", - "--descend='$100'", - "--descend-if='t=={$100}'", - "--deviation", - "--display='a>10'", - "--dow", - "--download", - "--effective", - "--empty", - "--end=2005/01", - #"--equity-format", - #"--file=/tmp/file", - "--forecast='d<[2006]'", - "--format=%Y", - #"--full-help", - "--gain", - "--head=10", - #"--help", - #"--help-calc", - #"--help-comm", - #"--help-disp", - #"--init-file=/tmp/init", - #"--input-date-format", - "--limit='a>10'", - "--lots", - "--lot-prices", - "--lot-dates", - "--lot-tags", - "--market", - "--monthly", - "--no-cache", - #"--output=/tmp/output", - #"--pager", - #"--percentage", - "--performance", - "--period-sort=A\\(t\\)", - "--period=oct", - #"--plot-amount-format", - #"--plot-total-format", - "--price", - "--price-exp=1000", - #"--price-db=/tmp/foo", - #"--prices-format", - #"--print-format", - "--quantity", - "--real", - #"--reconcile", - #"--reconcile-date", - #"--register-format", - "--related", - "--sort=A\\(t\\)", - "--subtotal", - "--tail=5", - "--total-data", - "--total=O", - "--totals", - "--unbudgeted", - "--uncleared", - #"--version", - "--weekly", - "--wide", - "--yearly", -] - -commands = [ - "bal rent", - "bal ira", - "bal auto", - "reg rent", - "reg ira", - "reg expenses:food", - "print rent", - "print irc", - "xml rent", - "xml irc", - "equity rent", - "equity ira", - "prices AAPL", -] - -random.seed () - -loop = true -count = 0 -errors = 0 -if len(sys.argv) > 1: - errors = int(sys.argv[1]) -signals = 0 - -while loop: - try: - n = random.randint (0, len (options)) - opts = random.sample (options, n) - for cmd in commands: - if os.path.exists ("/tmp/out"): - os.unlink ("/tmp/out") - - cmd = "./ledger -f tools/standard.dat " + string.join(opts, " ") + " " + cmd + \ - " >> /tmp/out 2>&1" - - sys.stdout = open ("/tmp/out", "w") - print "::", cmd - sys.stdout.close () - - ret = os.system (cmd) - - sys.stdout = open ("/tmp/out", "a") - - # Convert an odd UNIX return type into the appropriate - # signal indication. - if ret and ret % 256 == 0 and ret / 256 > 127: - ret = 0x100 + (ret / 256 - 128) - - if ret and ret % 256 == 0: - print "ERROR: Return value", ret / 256 - sys.stdout.close () - os.system ("cat /tmp/out >> errors.out") - errors += 1 - elif ret: - if ret % 256 == signal.SIGINT: - loop = false - break - print "SIGNAL: Return value", ret % 256 - sys.stdout.close () - os.system ("cat /tmp/out >> signals.out") - signals += 1 - else: - sys.stdout.close () - os.system ("cat /tmp/out >> results.out") - - sys.stdout = sys.__stdout__ - count += 1 - if count < 10 or \ - (count < 100 and count % 10 == 0) or \ - (count < 1000 and count % 100 == 0) or \ - count % 1000 == 0: - if signals > 0 and errors > 0: - print "%d tests ... (%d signals, %d errors)" % \ - (count, signals, errors) - elif signals > 0: - print "%d tests ... (%d signals)" % \ - (count, signals) - elif errors > 0: - print "%d tests ... (%d errors)" % \ - (count, errors) - else: - print "%d tests ..." % count - - except KeyboardInterrupt: - loop = false diff --git a/test/unit/t_amount.cc b/test/unit/t_amount.cc index b1c7b837..cda0a017 100644 --- a/test/unit/t_amount.cc +++ b/test/unit/t_amount.cc @@ -1,34 +1,38 @@ -#include <system.hh> +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE math +#include <boost/test/unit_test.hpp> -#include "t_amount.h" +#include <system.hh> #include "amount.h" #include "commodity.h" +#define internalAmount(x) amount_t::exact(x) + using namespace ledger; -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(AmountTestCase, "math"); +struct amount_fixture { + amount_fixture() { + times_initialize(); + amount_t::initialize(); -void AmountTestCase::setUp() -{ - times_initialize(); - amount_t::initialize(); + // Cause the display precision for dollars to be initialized to 2. + amount_t x1("$1.00"); + BOOST_CHECK(x1); - // Cause the display precision for dollars to be initialized to 2. - amount_t x1("$1.00"); - assertTrue(x1); + amount_t::stream_fullstrings = true; // make reports from UnitTests accurate + } - amount_t::stream_fullstrings = true; // make reports from UnitTests accurate -} + ~amount_fixture() { + amount_t::stream_fullstrings = false; + amount_t::shutdown(); + times_shutdown(); + } +}; -void AmountTestCase::tearDown() -{ - amount_t::stream_fullstrings = false; - amount_t::shutdown(); - times_shutdown(); -} +BOOST_FIXTURE_TEST_SUITE(amount, amount_fixture) -void AmountTestCase::testParser() +BOOST_AUTO_TEST_CASE(testParser) { amount_t x0; amount_t x1; @@ -44,25 +48,25 @@ void AmountTestCase::testParser() amount_t x11(x8); amount_t x12("$100"); - assertEqual(amount_t::precision_t(2), x12.commodity().precision()); + BOOST_CHECK_EQUAL(amount_t::precision_t(2), x12.commodity().precision()); #ifndef NOT_FOR_PYTHON string buf("$100..."); std::istringstream input(buf); amount_t x13; x13.parse(input); - assertEqual(x12, x13); + BOOST_CHECK_EQUAL(x12, x13); #endif // NOT_FOR_PYTHON amount_t x14; - assertThrow(x14.parse("DM"), amount_error); + BOOST_CHECK_THROW(x14.parse("DM"), amount_error); amount_t x15("$1.000.000,00"); // parsing this switches us to European amount_t x16("$2000"); - assertEqual(string("$2.000,00"), x16.to_string()); + BOOST_CHECK_EQUAL(string("$2.000,00"), x16.to_string()); x16.parse("$2000,00"); - assertEqual(string("$2.000,00"), x16.to_string()); + BOOST_CHECK_EQUAL(string("$2.000,00"), x16.to_string()); // Since use of a decimal-comma is an additive quality, we must switch back // to decimal-period manually. @@ -71,66 +75,66 @@ void AmountTestCase::testParser() amount_t x17("$1,000,000.00"); // parsing this switches back to American amount_t x18("$2000"); - assertEqual(string("$2,000.00"), x18.to_string()); + BOOST_CHECK_EQUAL(string("$2,000.00"), x18.to_string()); x18.parse("$2,000"); - assertEqual(string("$2,000.00"), x18.to_string()); + BOOST_CHECK_EQUAL(string("$2,000.00"), x18.to_string()); - assertEqual(x15, x17); + BOOST_CHECK_EQUAL(x15, x17); amount_t x19("EUR 1000"); amount_t x20("EUR 1000"); - assertEqual(string("EUR 1000"), x19.to_string()); - assertEqual(string("EUR 1000"), x20.to_string()); + BOOST_CHECK_EQUAL(string("EUR 1000"), x19.to_string()); + BOOST_CHECK_EQUAL(string("EUR 1000"), x20.to_string()); x1.parse("$100.0000", PARSE_NO_MIGRATE); - assertEqual(amount_t::precision_t(2), x12.commodity().precision()); - assertEqual(x1.commodity(), x12.commodity()); - assertEqual(x1, x12); + BOOST_CHECK_EQUAL(amount_t::precision_t(2), x12.commodity().precision()); + BOOST_CHECK_EQUAL(x1.commodity(), x12.commodity()); + BOOST_CHECK_EQUAL(x1, x12); x0.parse("$100.0000"); - assertEqual(amount_t::precision_t(4), x12.commodity().precision()); - assertEqual(x0.commodity(), x12.commodity()); - assertEqual(x0, x12); + BOOST_CHECK_EQUAL(amount_t::precision_t(4), x12.commodity().precision()); + BOOST_CHECK_EQUAL(x0.commodity(), x12.commodity()); + BOOST_CHECK_EQUAL(x0, x12); x2.parse("$100.00", PARSE_NO_REDUCE); - assertEqual(x2, x12); + BOOST_CHECK_EQUAL(x2, x12); x3.parse("$100.00", PARSE_NO_MIGRATE | PARSE_NO_REDUCE); - assertEqual(x3, x12); + BOOST_CHECK_EQUAL(x3, x12); x4.parse("$100.00"); - assertEqual(x4, x12); + BOOST_CHECK_EQUAL(x4, x12); x5.parse("$100.00", PARSE_NO_MIGRATE); - assertEqual(x5, x12); + BOOST_CHECK_EQUAL(x5, x12); x6.parse("$100.00", PARSE_NO_REDUCE); - assertEqual(x6, x12); + BOOST_CHECK_EQUAL(x6, x12); x7.parse("$100.00", PARSE_NO_MIGRATE | PARSE_NO_REDUCE); - assertEqual(x7, x12); + BOOST_CHECK_EQUAL(x7, x12); x8.parse("$100.00"); - assertEqual(x8, x12); + BOOST_CHECK_EQUAL(x8, x12); x9.parse("$100.00", PARSE_NO_MIGRATE); - assertEqual(x9, x12); + BOOST_CHECK_EQUAL(x9, x12); x10.parse("$100.00", PARSE_NO_REDUCE); - assertEqual(x10, x12); + BOOST_CHECK_EQUAL(x10, x12); x11.parse("$100.00", PARSE_NO_MIGRATE | PARSE_NO_REDUCE); - assertEqual(x11, x12); - - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); - assertValid(x11); - assertValid(x12); + BOOST_CHECK_EQUAL(x11, x12); + + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); + BOOST_CHECK(x11.valid()); + BOOST_CHECK(x12.valid()); } -void AmountTestCase::testConstructors() +BOOST_AUTO_TEST_CASE(testConstructors) { amount_t x0; amount_t x1(123456L); @@ -144,31 +148,31 @@ void AmountTestCase::testConstructors() amount_t x10(x6); amount_t x11(x8); - assertEqual(amount_t(), x0); - assertNotEqual(amount_t("0"), x0); - assertNotEqual(amount_t("0.0"), x0); - assertEqual(x2, x1); - assertEqual(x5, x1); - assertEqual(x7, x1); - assertEqual(x6, x3); - assertEqual(x8, x3); - assertEqual(x10, x3); - assertEqual(x10, x9); - - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); - assertValid(x11); + BOOST_CHECK_EQUAL(amount_t(), x0); + BOOST_CHECK_NE(amount_t("0"), x0); + BOOST_CHECK_NE(amount_t("0.0"), x0); + BOOST_CHECK_EQUAL(x2, x1); + BOOST_CHECK_EQUAL(x5, x1); + BOOST_CHECK_EQUAL(x7, x1); + BOOST_CHECK_EQUAL(x6, x3); + BOOST_CHECK_EQUAL(x8, x3); + BOOST_CHECK_EQUAL(x10, x3); + BOOST_CHECK_EQUAL(x10, x9); + + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); + BOOST_CHECK(x11.valid()); } -void AmountTestCase::testCommodityConstructors() +BOOST_AUTO_TEST_CASE(testCommodityConstructors) { amount_t x1("$123.45"); amount_t x2("-$123.45"); @@ -181,43 +185,43 @@ void AmountTestCase::testCommodityConstructors() amount_t x9("123.45€"); amount_t x10("-123.45€"); - assertEqual(amount_t("$123.45"), x1); - assertEqual(amount_t("-$123.45"), x2); - assertEqual(amount_t("$-123.45"), x3); - assertEqual(amount_t("DM 123.45"), x4); - assertEqual(amount_t("-DM 123.45"), x5); - assertEqual(amount_t("DM -123.45"), x6); - assertEqual(amount_t("123.45 euro"), x7); - assertEqual(amount_t("-123.45 euro"), x8); - assertEqual(amount_t("123.45€"), x9); - assertEqual(amount_t("-123.45€"), x10); - - assertEqual(string("$123.45"), x1.to_string()); - assertEqual(string("$-123.45"), x2.to_string()); - assertEqual(string("$-123.45"), x3.to_string()); - assertEqual(string("DM 123.45"), x4.to_string()); - assertEqual(string("DM -123.45"), x5.to_string()); - assertEqual(string("DM -123.45"), x6.to_string()); - assertEqual(string("123.45 euro"), x7.to_string()); - assertEqual(string("-123.45 euro"), x8.to_string()); - assertEqual(string("123.45€"), x9.to_string()); - assertEqual(string("-123.45€"), x10.to_string()); - - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x1); + BOOST_CHECK_EQUAL(amount_t("-$123.45"), x2); + BOOST_CHECK_EQUAL(amount_t("$-123.45"), x3); + BOOST_CHECK_EQUAL(amount_t("DM 123.45"), x4); + BOOST_CHECK_EQUAL(amount_t("-DM 123.45"), x5); + BOOST_CHECK_EQUAL(amount_t("DM -123.45"), x6); + BOOST_CHECK_EQUAL(amount_t("123.45 euro"), x7); + BOOST_CHECK_EQUAL(amount_t("-123.45 euro"), x8); + BOOST_CHECK_EQUAL(amount_t("123.45€"), x9); + BOOST_CHECK_EQUAL(amount_t("-123.45€"), x10); + + BOOST_CHECK_EQUAL(string("$123.45"), x1.to_string()); + BOOST_CHECK_EQUAL(string("$-123.45"), x2.to_string()); + BOOST_CHECK_EQUAL(string("$-123.45"), x3.to_string()); + BOOST_CHECK_EQUAL(string("DM 123.45"), x4.to_string()); + BOOST_CHECK_EQUAL(string("DM -123.45"), x5.to_string()); + BOOST_CHECK_EQUAL(string("DM -123.45"), x6.to_string()); + BOOST_CHECK_EQUAL(string("123.45 euro"), x7.to_string()); + BOOST_CHECK_EQUAL(string("-123.45 euro"), x8.to_string()); + BOOST_CHECK_EQUAL(string("123.45€"), x9.to_string()); + BOOST_CHECK_EQUAL(string("-123.45€"), x10.to_string()); + + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } #ifndef NOT_FOR_PYTHON -void AmountTestCase::testAssignment() +BOOST_AUTO_TEST_CASE(testAssignment) { amount_t x0; amount_t x1; @@ -240,32 +244,32 @@ void AmountTestCase::testAssignment() x9 = x3; x10 = amount_t(x6); - assertEqual(x2, x1); - assertEqual(x5, x1); - assertEqual(x7, x1); - assertEqual(x6, x3); - assertEqual(x8, x3); - assertEqual(x10, x3); - assertEqual(x10, x9); + BOOST_CHECK_EQUAL(x2, x1); + BOOST_CHECK_EQUAL(x5, x1); + BOOST_CHECK_EQUAL(x7, x1); + BOOST_CHECK_EQUAL(x6, x3); + BOOST_CHECK_EQUAL(x8, x3); + BOOST_CHECK_EQUAL(x10, x3); + BOOST_CHECK_EQUAL(x10, x9); - assertFalse(x1.is_null()); + BOOST_CHECK(! x1.is_null()); x1 = x0; // sets x1 back to uninitialized state - assertTrue(x0.is_null()); - assertTrue(x1.is_null()); - - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK(x0.is_null()); + BOOST_CHECK(x1.is_null()); + + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } -void AmountTestCase::testCommodityAssignment() +BOOST_AUTO_TEST_CASE(testCommodityAssignment) { amount_t x1; amount_t x2; @@ -289,43 +293,43 @@ void AmountTestCase::testCommodityAssignment() x9 = "123.45€"; x10 = "-123.45€"; - assertEqual(amount_t("$123.45"), x1); - assertEqual(amount_t("-$123.45"), x2); - assertEqual(amount_t("$-123.45"), x3); - assertEqual(amount_t("DM 123.45"), x4); - assertEqual(amount_t("-DM 123.45"), x5); - assertEqual(amount_t("DM -123.45"), x6); - assertEqual(amount_t("123.45 euro"), x7); - assertEqual(amount_t("-123.45 euro"), x8); - assertEqual(amount_t("123.45€"), x9); - assertEqual(amount_t("-123.45€"), x10); - - assertEqual(string("$123.45"), x1.to_string()); - assertEqual(string("$-123.45"), x2.to_string()); - assertEqual(string("$-123.45"), x3.to_string()); - assertEqual(string("DM 123.45"), x4.to_string()); - assertEqual(string("DM -123.45"), x5.to_string()); - assertEqual(string("DM -123.45"), x6.to_string()); - assertEqual(string("123.45 euro"), x7.to_string()); - assertEqual(string("-123.45 euro"), x8.to_string()); - assertEqual(string("123.45€"), x9.to_string()); - assertEqual(string("-123.45€"), x10.to_string()); - - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x1); + BOOST_CHECK_EQUAL(amount_t("-$123.45"), x2); + BOOST_CHECK_EQUAL(amount_t("$-123.45"), x3); + BOOST_CHECK_EQUAL(amount_t("DM 123.45"), x4); + BOOST_CHECK_EQUAL(amount_t("-DM 123.45"), x5); + BOOST_CHECK_EQUAL(amount_t("DM -123.45"), x6); + BOOST_CHECK_EQUAL(amount_t("123.45 euro"), x7); + BOOST_CHECK_EQUAL(amount_t("-123.45 euro"), x8); + BOOST_CHECK_EQUAL(amount_t("123.45€"), x9); + BOOST_CHECK_EQUAL(amount_t("-123.45€"), x10); + + BOOST_CHECK_EQUAL(string("$123.45"), x1.to_string()); + BOOST_CHECK_EQUAL(string("$-123.45"), x2.to_string()); + BOOST_CHECK_EQUAL(string("$-123.45"), x3.to_string()); + BOOST_CHECK_EQUAL(string("DM 123.45"), x4.to_string()); + BOOST_CHECK_EQUAL(string("DM -123.45"), x5.to_string()); + BOOST_CHECK_EQUAL(string("DM -123.45"), x6.to_string()); + BOOST_CHECK_EQUAL(string("123.45 euro"), x7.to_string()); + BOOST_CHECK_EQUAL(string("-123.45 euro"), x8.to_string()); + BOOST_CHECK_EQUAL(string("123.45€"), x9.to_string()); + BOOST_CHECK_EQUAL(string("-123.45€"), x10.to_string()); + + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } #endif // NOT_FOR_PYTHON -void AmountTestCase::testEquality() +BOOST_AUTO_TEST_CASE(testEquality) { amount_t x1(123456L); amount_t x2(456789L); @@ -334,29 +338,29 @@ void AmountTestCase::testEquality() amount_t x5("123456.0"); amount_t x6("123456.0"); - assertTrue(x1 == 123456L); - assertTrue(x1 != x2); - assertTrue(x1 == (x2 - x3)); - assertTrue(x1 == x4); - assertTrue(x4 == x5); - assertTrue(x4 == x6); - - assertTrue(x1 == 123456L); - assertTrue(123456L == x1); - assertTrue(x1 == 123456UL); - assertTrue(123456UL == x1); - assertTrue(x1 == amount_t("123456.0")); - assertTrue(amount_t("123456.0") == x1); - - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); + BOOST_CHECK(x1 == 123456L); + BOOST_CHECK(x1 != x2); + BOOST_CHECK(x1 == (x2 - x3)); + BOOST_CHECK(x1 == x4); + BOOST_CHECK(x4 == x5); + BOOST_CHECK(x4 == x6); + + BOOST_CHECK(x1 == 123456L); + BOOST_CHECK(123456L == x1); + BOOST_CHECK(x1 == 123456UL); + BOOST_CHECK(123456UL == x1); + BOOST_CHECK(x1 == amount_t("123456.0")); + BOOST_CHECK(amount_t("123456.0") == x1); + + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); } -void AmountTestCase::testCommodityEquality() +BOOST_AUTO_TEST_CASE(testCommodityEquality) { amount_t x0; amount_t x1("$123.45"); @@ -370,38 +374,38 @@ void AmountTestCase::testCommodityEquality() amount_t x9("123.45€"); amount_t x10("-123.45€"); - assertTrue(x0.is_null()); - assertThrow(x0.is_zero(), amount_error); - assertThrow(x0.is_realzero(), amount_error); - assertThrow(x0.sign(), amount_error); - assertThrow(x0.compare(x1), amount_error); - assertThrow(x0.compare(x2), amount_error); - assertThrow(x0.compare(x0), amount_error); - - assertTrue(x1 != x2); - assertTrue(x1 != x4); - assertTrue(x1 != x7); - assertTrue(x1 != x9); - assertTrue(x2 == x3); - assertTrue(x4 != x5); - assertTrue(x5 == x6); - assertTrue(x7 == - x8); - assertTrue(x9 == - x10); - - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK(x0.is_null()); + BOOST_CHECK_THROW(x0.is_zero(), amount_error); + BOOST_CHECK_THROW(x0.is_realzero(), amount_error); + BOOST_CHECK_THROW(x0.sign(), amount_error); + BOOST_CHECK_THROW(x0.compare(x1), amount_error); + BOOST_CHECK_THROW(x0.compare(x2), amount_error); + BOOST_CHECK_THROW(x0.compare(x0), amount_error); + + BOOST_CHECK(x1 != x2); + BOOST_CHECK(x1 != x4); + BOOST_CHECK(x1 != x7); + BOOST_CHECK(x1 != x9); + BOOST_CHECK(x2 == x3); + BOOST_CHECK(x4 != x5); + BOOST_CHECK(x5 == x6); + BOOST_CHECK(x7 == - x8); + BOOST_CHECK(x9 == - x10); + + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } -void AmountTestCase::testComparisons() +BOOST_AUTO_TEST_CASE(testComparisons) { amount_t x0; amount_t x1(-123L); @@ -411,38 +415,38 @@ void AmountTestCase::testComparisons() amount_t x5("-123.45"); amount_t x6("123.45"); - assertThrow(x0 > x1, amount_error); - assertThrow(x0 < x2, amount_error); - assertThrow(x0 > x3, amount_error); - assertThrow(x0 < x4, amount_error); - assertThrow(x0 > x5, amount_error); - assertThrow(x0 < x6, amount_error); - - assertTrue(x1 > x3); - assertTrue(x3 <= x5); - assertTrue(x3 >= x5); - assertTrue(x3 < x1); - assertTrue(x3 < x4); - - assertTrue(x1 < 100L); - assertTrue(100L > x1); - assertTrue(x1 < 100UL); - assertTrue(100UL > x1); + BOOST_CHECK_THROW(x0 > x1, amount_error); + BOOST_CHECK_THROW(x0 < x2, amount_error); + BOOST_CHECK_THROW(x0 > x3, amount_error); + BOOST_CHECK_THROW(x0 < x4, amount_error); + BOOST_CHECK_THROW(x0 > x5, amount_error); + BOOST_CHECK_THROW(x0 < x6, amount_error); + + BOOST_CHECK(x1 > x3); + BOOST_CHECK(x3 <= x5); + BOOST_CHECK(x3 >= x5); + BOOST_CHECK(x3 < x1); + BOOST_CHECK(x3 < x4); + + BOOST_CHECK(x1 < 100L); + BOOST_CHECK(100L > x1); + BOOST_CHECK(x1 < 100UL); + BOOST_CHECK(100UL > x1); #ifndef NOT_FOR_PYTHON - assertTrue(x1 < 100.0); - assertTrue(100.0 > x1); + BOOST_CHECK(x1 < 100.0); + BOOST_CHECK(100.0 > x1); #endif // NOT_FOR_PYTHON - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); } -void AmountTestCase::testCommodityComparisons() +BOOST_AUTO_TEST_CASE(testCommodityComparisons) { amount_t x1("$-123"); amount_t x2("$123.00"); @@ -452,75 +456,75 @@ void AmountTestCase::testCommodityComparisons() amount_t x6("$123.45"); amount_t x7("DM 123.45"); - assertTrue(x1 > x3); - assertTrue(x3 <= x5); - assertTrue(x3 < x5); - assertTrue(x3 <= x5); - assertFalse(x3 == x5); - assertTrue(x3 < x1); - assertTrue(x3 < x4); - assertFalse(x6 == x7); - assertThrow(x6 < x7, amount_error); - - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); + BOOST_CHECK(x1 > x3); + BOOST_CHECK(x3 <= x5); + BOOST_CHECK(x3 < x5); + BOOST_CHECK(x3 <= x5); + BOOST_CHECK(! (x3 == x5)); + BOOST_CHECK(x3 < x1); + BOOST_CHECK(x3 < x4); + BOOST_CHECK(! (x6 == x7)); + BOOST_CHECK_THROW(x6 < x7, amount_error); + + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); } -void AmountTestCase::testIntegerAddition() +BOOST_AUTO_TEST_CASE(testIntegerAddition) { amount_t x0; amount_t x1(123L); amount_t y1(456L); - assertEqual(amount_t(579L), x1 + y1); - assertEqual(amount_t(579L), x1 + 456L); - assertEqual(amount_t(579L), 456L + x1); + BOOST_CHECK_EQUAL(amount_t(579L), x1 + y1); + BOOST_CHECK_EQUAL(amount_t(579L), x1 + 456L); + BOOST_CHECK_EQUAL(amount_t(579L), 456L + x1); x1 += amount_t(456L); - assertEqual(amount_t(579L), x1); + BOOST_CHECK_EQUAL(amount_t(579L), x1); x1 += 456L; - assertEqual(amount_t(1035L), x1); + BOOST_CHECK_EQUAL(amount_t(1035L), x1); amount_t x4("123456789123456789123456789"); - assertEqual(amount_t("246913578246913578246913578"), x4 + x4); + BOOST_CHECK_EQUAL(amount_t("246913578246913578246913578"), x4 + x4); - assertValid(x0); - assertValid(x1); - assertValid(y1); - assertValid(x4); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x4.valid()); } -void AmountTestCase::testFractionalAddition() +BOOST_AUTO_TEST_CASE(testFractionalAddition) { amount_t x1("123.123"); amount_t y1("456.456"); - assertEqual(amount_t("579.579"), x1 + y1); - assertEqual(amount_t("579.579"), x1 + amount_t("456.456")); - assertEqual(amount_t("579.579"), amount_t("456.456") + x1); + BOOST_CHECK_EQUAL(amount_t("579.579"), x1 + y1); + BOOST_CHECK_EQUAL(amount_t("579.579"), x1 + amount_t("456.456")); + BOOST_CHECK_EQUAL(amount_t("579.579"), amount_t("456.456") + x1); x1 += amount_t("456.456"); - assertEqual(amount_t("579.579"), x1); + BOOST_CHECK_EQUAL(amount_t("579.579"), x1); x1 += amount_t("456.456"); - assertEqual(amount_t("1036.035"), x1); + BOOST_CHECK_EQUAL(amount_t("1036.035"), x1); x1 += 456L; - assertEqual(amount_t("1492.035"), x1); + BOOST_CHECK_EQUAL(amount_t("1492.035"), x1); amount_t x2("123456789123456789.123456789123456789"); - assertEqual(amount_t("246913578246913578.246913578246913578"), x2 + x2); + BOOST_CHECK_EQUAL(amount_t("246913578246913578.246913578246913578"), x2 + x2); - assertValid(x1); - assertValid(y1); - assertValid(x2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x2.valid()); } -void AmountTestCase::testCommodityAddition() +BOOST_AUTO_TEST_CASE(testCommodityAddition) { amount_t x0; amount_t x1("$123.45"); @@ -530,109 +534,109 @@ void AmountTestCase::testCommodityAddition() amount_t x5("123.45€"); amount_t x6("123.45"); - assertEqual(amount_t("$246.90"), x1 + x1); - assertNotEqual(amount_t("$246.91"), x1 + x2); - assertEqual(internalAmount("$246.906789"), x1 + x2); + BOOST_CHECK_EQUAL(amount_t("$246.90"), x1 + x1); + BOOST_CHECK_NE(amount_t("$246.91"), x1 + x2); + BOOST_CHECK_EQUAL(internalAmount("$246.906789"), x1 + x2); // Converting to string drops internal precision - assertEqual(string("$246.90"), (x1 + x1).to_string()); - assertEqual(string("$246.91"), (x1 + x2).to_string()); - - assertThrow(x1 + x0, amount_error); - assertThrow(x0 + x1, amount_error); - assertThrow(x0 + x0, amount_error); - assertThrow(x1 + x3, amount_error); - assertThrow(x1 + x4, amount_error); - assertThrow(x1 + x5, amount_error); - assertEqual(string("$246.90"), (x1 + x6).to_string()); + BOOST_CHECK_EQUAL(string("$246.90"), (x1 + x1).to_string()); + BOOST_CHECK_EQUAL(string("$246.91"), (x1 + x2).to_string()); + + BOOST_CHECK_THROW(x1 + x0, amount_error); + BOOST_CHECK_THROW(x0 + x1, amount_error); + BOOST_CHECK_THROW(x0 + x0, amount_error); + BOOST_CHECK_THROW(x1 + x3, amount_error); + BOOST_CHECK_THROW(x1 + x4, amount_error); + BOOST_CHECK_THROW(x1 + x5, amount_error); + BOOST_CHECK_EQUAL(string("$246.90"), (x1 + x6).to_string()); #ifndef NOT_FOR_PYTHON - assertEqual(string("$246.90"), (x1 + 123.45).to_string()); + BOOST_CHECK_EQUAL(string("$246.90"), (x1 + 123.45).to_string()); #endif // NOT_FOR_PYTHON - assertEqual(string("$246.45"), (x1 + 123L).to_string()); + BOOST_CHECK_EQUAL(string("$246.45"), (x1 + 123L).to_string()); - assertEqual(amount_t("DM 246.90"), x3 + x3); - assertEqual(amount_t("246.90 euro"), x4 + x4); - assertEqual(amount_t("246.90€"), x5 + x5); + BOOST_CHECK_EQUAL(amount_t("DM 246.90"), x3 + x3); + BOOST_CHECK_EQUAL(amount_t("246.90 euro"), x4 + x4); + BOOST_CHECK_EQUAL(amount_t("246.90€"), x5 + x5); - assertEqual(string("DM 246.90"), (x3 + x3).to_string()); - assertEqual(string("246.90 euro"), (x4 + x4).to_string()); - assertEqual(string("246.90€"), (x5 + x5).to_string()); + BOOST_CHECK_EQUAL(string("DM 246.90"), (x3 + x3).to_string()); + BOOST_CHECK_EQUAL(string("246.90 euro"), (x4 + x4).to_string()); + BOOST_CHECK_EQUAL(string("246.90€"), (x5 + x5).to_string()); x1 += amount_t("$456.45"); - assertEqual(amount_t("$579.90"), x1); + BOOST_CHECK_EQUAL(amount_t("$579.90"), x1); x1 += amount_t("$456.45"); - assertEqual(amount_t("$1036.35"), x1); + BOOST_CHECK_EQUAL(amount_t("$1036.35"), x1); x1 += amount_t("$456"); - assertEqual(amount_t("$1492.35"), x1); + BOOST_CHECK_EQUAL(amount_t("$1492.35"), x1); amount_t x7(internalAmount("$123456789123456789.123456789123456789")); - assertEqual(internalAmount("$246913578246913578.246913578246913578"), x7 + x7); + BOOST_CHECK_EQUAL(internalAmount("$246913578246913578.246913578246913578"), x7 + x7); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); } -void AmountTestCase::testIntegerSubtraction() +BOOST_AUTO_TEST_CASE(testIntegerSubtraction) { amount_t x1(123L); amount_t y1(456L); - assertEqual(amount_t(333L), y1 - x1); - assertEqual(amount_t(-333L), x1 - y1); - assertEqual(amount_t(23L), x1 - 100L); - assertEqual(amount_t(-23L), 100L - x1); + BOOST_CHECK_EQUAL(amount_t(333L), y1 - x1); + BOOST_CHECK_EQUAL(amount_t(-333L), x1 - y1); + BOOST_CHECK_EQUAL(amount_t(23L), x1 - 100L); + BOOST_CHECK_EQUAL(amount_t(-23L), 100L - x1); x1 -= amount_t(456L); - assertEqual(amount_t(-333L), x1); + BOOST_CHECK_EQUAL(amount_t(-333L), x1); x1 -= 456L; - assertEqual(amount_t(-789L), x1); + BOOST_CHECK_EQUAL(amount_t(-789L), x1); amount_t x4("123456789123456789123456789"); amount_t y4("8238725986235986"); - assertEqual(amount_t("123456789115218063137220803"), x4 - y4); - assertEqual(amount_t("-123456789115218063137220803"), y4 - x4); + BOOST_CHECK_EQUAL(amount_t("123456789115218063137220803"), x4 - y4); + BOOST_CHECK_EQUAL(amount_t("-123456789115218063137220803"), y4 - x4); - assertValid(x1); - assertValid(y1); - assertValid(x4); - assertValid(y4); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(y4.valid()); } -void AmountTestCase::testFractionalSubtraction() +BOOST_AUTO_TEST_CASE(testFractionalSubtraction) { amount_t x1("123.123"); amount_t y1("456.456"); - assertEqual(amount_t("-333.333"), x1 - y1); - assertEqual(amount_t("333.333"), y1 - x1); + BOOST_CHECK_EQUAL(amount_t("-333.333"), x1 - y1); + BOOST_CHECK_EQUAL(amount_t("333.333"), y1 - x1); x1 -= amount_t("456.456"); - assertEqual(amount_t("-333.333"), x1); + BOOST_CHECK_EQUAL(amount_t("-333.333"), x1); x1 -= amount_t("456.456"); - assertEqual(amount_t("-789.789"), x1); + BOOST_CHECK_EQUAL(amount_t("-789.789"), x1); x1 -= 456L; - assertEqual(amount_t("-1245.789"), x1); + BOOST_CHECK_EQUAL(amount_t("-1245.789"), x1); amount_t x2("123456789123456789.123456789123456789"); amount_t y2("9872345982459.248974239578"); - assertEqual(amount_t("123446916777474329.874482549545456789"), x2 - y2); - assertEqual(amount_t("-123446916777474329.874482549545456789"), y2 - x2); + BOOST_CHECK_EQUAL(amount_t("123446916777474329.874482549545456789"), x2 - y2); + BOOST_CHECK_EQUAL(amount_t("-123446916777474329.874482549545456789"), y2 - x2); - assertValid(x1); - assertValid(y1); - assertValid(x2); - assertValid(y2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(y2.valid()); } -void AmountTestCase::testCommoditySubtraction() +BOOST_AUTO_TEST_CASE(testCommoditySubtraction) { amount_t x0; amount_t x1("$123.45"); @@ -642,152 +646,152 @@ void AmountTestCase::testCommoditySubtraction() amount_t x5("123.45€"); amount_t x6("123.45"); - assertNotEqual(amount_t(), x1 - x1); - assertEqual(amount_t("$0"), x1 - x1); - assertEqual(amount_t("$23.45"), x1 - amount_t("$100.00")); - assertEqual(amount_t("$-23.45"), amount_t("$100.00") - x1); - assertNotEqual(amount_t("$-0.01"), x1 - x2); - assertEqual(internalAmount("$-0.006789"), x1 - x2); + BOOST_CHECK_NE(amount_t(), x1 - x1); + BOOST_CHECK_EQUAL(amount_t("$0"), x1 - x1); + BOOST_CHECK_EQUAL(amount_t("$23.45"), x1 - amount_t("$100.00")); + BOOST_CHECK_EQUAL(amount_t("$-23.45"), amount_t("$100.00") - x1); + BOOST_CHECK_NE(amount_t("$-0.01"), x1 - x2); + BOOST_CHECK_EQUAL(internalAmount("$-0.006789"), x1 - x2); // Converting to string drops internal precision. If an amount is // zero, it drops the commodity as well. - assertEqual(string("$0.00"), (x1 - x1).to_string()); - assertEqual(string("$-0.01"), (x1 - x2).to_string()); - - assertThrow(x1 - x0, amount_error); - assertThrow(x0 - x1, amount_error); - assertThrow(x0 - x0, amount_error); - assertThrow(x1 - x3, amount_error); - assertThrow(x1 - x4, amount_error); - assertThrow(x1 - x5, amount_error); - assertEqual(string("$0.00"), (x1 - x6).to_string()); + BOOST_CHECK_EQUAL(string("$0.00"), (x1 - x1).to_string()); + BOOST_CHECK_EQUAL(string("$-0.01"), (x1 - x2).to_string()); + + BOOST_CHECK_THROW(x1 - x0, amount_error); + BOOST_CHECK_THROW(x0 - x1, amount_error); + BOOST_CHECK_THROW(x0 - x0, amount_error); + BOOST_CHECK_THROW(x1 - x3, amount_error); + BOOST_CHECK_THROW(x1 - x4, amount_error); + BOOST_CHECK_THROW(x1 - x5, amount_error); + BOOST_CHECK_EQUAL(string("$0.00"), (x1 - x6).to_string()); #ifndef NOT_FOR_PYTHON - assertEqual(string("$-0.00"), (x1 - 123.45).to_string()); + BOOST_CHECK_EQUAL(string("$-0.00"), (x1 - 123.45).to_string()); #endif // NOT_FOR_PYTHON - assertEqual(string("$0.45"), (x1 - 123L).to_string()); - - assertEqual(amount_t("DM 0.00"), x3 - x3); - assertEqual(amount_t("DM 23.45"), x3 - amount_t("DM 100.00")); - assertEqual(amount_t("DM -23.45"), amount_t("DM 100.00") - x3); - assertEqual(amount_t("0.00 euro"), x4 - x4); - assertEqual(amount_t("23.45 euro"), x4 - amount_t("100.00 euro")); - assertEqual(amount_t("-23.45 euro"), amount_t("100.00 euro") - x4); - assertEqual(amount_t("0.00€"), x5 - x5); - assertEqual(amount_t("23.45€"), x5 - amount_t("100.00€")); - assertEqual(amount_t("-23.45€"), amount_t("100.00€") - x5); - - assertEqual(string("DM 0.00"), (x3 - x3).to_string()); - assertEqual(string("DM 23.45"), (x3 - amount_t("DM 100.00")).to_string()); - assertEqual(string("DM -23.45"), (amount_t("DM 100.00") - x3).to_string()); - assertEqual(string("0.00 euro"), (x4 - x4).to_string()); - assertEqual(string("23.45 euro"), (x4 - amount_t("100.00 euro")).to_string()); - assertEqual(string("-23.45 euro"), (amount_t("100.00 euro") - x4).to_string()); - assertEqual(string("0.00€"), (x5 - x5).to_string()); - assertEqual(string("23.45€"), (x5 - amount_t("100.00€")).to_string()); - assertEqual(string("-23.45€"), (amount_t("100.00€") - x5).to_string()); + BOOST_CHECK_EQUAL(string("$0.45"), (x1 - 123L).to_string()); + + BOOST_CHECK_EQUAL(amount_t("DM 0.00"), x3 - x3); + BOOST_CHECK_EQUAL(amount_t("DM 23.45"), x3 - amount_t("DM 100.00")); + BOOST_CHECK_EQUAL(amount_t("DM -23.45"), amount_t("DM 100.00") - x3); + BOOST_CHECK_EQUAL(amount_t("0.00 euro"), x4 - x4); + BOOST_CHECK_EQUAL(amount_t("23.45 euro"), x4 - amount_t("100.00 euro")); + BOOST_CHECK_EQUAL(amount_t("-23.45 euro"), amount_t("100.00 euro") - x4); + BOOST_CHECK_EQUAL(amount_t("0.00€"), x5 - x5); + BOOST_CHECK_EQUAL(amount_t("23.45€"), x5 - amount_t("100.00€")); + BOOST_CHECK_EQUAL(amount_t("-23.45€"), amount_t("100.00€") - x5); + + BOOST_CHECK_EQUAL(string("DM 0.00"), (x3 - x3).to_string()); + BOOST_CHECK_EQUAL(string("DM 23.45"), (x3 - amount_t("DM 100.00")).to_string()); + BOOST_CHECK_EQUAL(string("DM -23.45"), (amount_t("DM 100.00") - x3).to_string()); + BOOST_CHECK_EQUAL(string("0.00 euro"), (x4 - x4).to_string()); + BOOST_CHECK_EQUAL(string("23.45 euro"), (x4 - amount_t("100.00 euro")).to_string()); + BOOST_CHECK_EQUAL(string("-23.45 euro"), (amount_t("100.00 euro") - x4).to_string()); + BOOST_CHECK_EQUAL(string("0.00€"), (x5 - x5).to_string()); + BOOST_CHECK_EQUAL(string("23.45€"), (x5 - amount_t("100.00€")).to_string()); + BOOST_CHECK_EQUAL(string("-23.45€"), (amount_t("100.00€") - x5).to_string()); x1 -= amount_t("$456.45"); - assertEqual(amount_t("$-333.00"), x1); + BOOST_CHECK_EQUAL(amount_t("$-333.00"), x1); x1 -= amount_t("$456.45"); - assertEqual(amount_t("$-789.45"), x1); + BOOST_CHECK_EQUAL(amount_t("$-789.45"), x1); x1 -= amount_t("$456"); - assertEqual(amount_t("$-1245.45"), x1); + BOOST_CHECK_EQUAL(amount_t("$-1245.45"), x1); amount_t x7(internalAmount("$123456789123456789.123456789123456789")); amount_t x8(internalAmount("$2354974984698.98459845984598")); - assertEqual(internalAmount("$123454434148472090.138858329277476789"), x7 - x8); - assertEqual(string("$123454434148472090.138858329277476789"), (x7 - x8).to_string()); - assertEqual(string("$123454434148472090.14"), + BOOST_CHECK_EQUAL(internalAmount("$123454434148472090.138858329277476789"), x7 - x8); + BOOST_CHECK_EQUAL(string("$123454434148472090.138858329277476789"), (x7 - x8).to_string()); + BOOST_CHECK_EQUAL(string("$123454434148472090.14"), (amount_t("$1.00") * (x7 - x8)).to_string()); - assertEqual(internalAmount("$-123454434148472090.138858329277476789"), x8 - x7); - assertEqual(string("$-123454434148472090.138858329277476789"), (x8 - x7).to_string()); - assertEqual(string("$-123454434148472090.14"), + BOOST_CHECK_EQUAL(internalAmount("$-123454434148472090.138858329277476789"), x8 - x7); + BOOST_CHECK_EQUAL(string("$-123454434148472090.138858329277476789"), (x8 - x7).to_string()); + BOOST_CHECK_EQUAL(string("$-123454434148472090.14"), (amount_t("$1.00") * (x8 - x7)).to_string()); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); } -void AmountTestCase::testIntegerMultiplication() +BOOST_AUTO_TEST_CASE(testIntegerMultiplication) { amount_t x1(123L); amount_t y1(456L); - assertEqual(amount_t(0L), x1 * 0L); - assertEqual(amount_t(0L), amount_t(0L) * x1); - assertEqual(amount_t(0L), 0L * x1); - assertEqual(x1, x1 * 1L); - assertEqual(x1, amount_t(1L) * x1); - assertEqual(x1, 1L * x1); - assertEqual(- x1, x1 * -1L); - assertEqual(- x1, amount_t(-1L) * x1); - assertEqual(- x1, -1L * x1); - assertEqual(amount_t(56088L), x1 * y1); - assertEqual(amount_t(56088L), y1 * x1); - assertEqual(amount_t(56088L), x1 * 456L); - assertEqual(amount_t(56088L), amount_t(456L) * x1); - assertEqual(amount_t(56088L), 456L * x1); + BOOST_CHECK_EQUAL(amount_t(0L), x1 * 0L); + BOOST_CHECK_EQUAL(amount_t(0L), amount_t(0L) * x1); + BOOST_CHECK_EQUAL(amount_t(0L), 0L * x1); + BOOST_CHECK_EQUAL(x1, x1 * 1L); + BOOST_CHECK_EQUAL(x1, amount_t(1L) * x1); + BOOST_CHECK_EQUAL(x1, 1L * x1); + BOOST_CHECK_EQUAL(- x1, x1 * -1L); + BOOST_CHECK_EQUAL(- x1, amount_t(-1L) * x1); + BOOST_CHECK_EQUAL(- x1, -1L * x1); + BOOST_CHECK_EQUAL(amount_t(56088L), x1 * y1); + BOOST_CHECK_EQUAL(amount_t(56088L), y1 * x1); + BOOST_CHECK_EQUAL(amount_t(56088L), x1 * 456L); + BOOST_CHECK_EQUAL(amount_t(56088L), amount_t(456L) * x1); + BOOST_CHECK_EQUAL(amount_t(56088L), 456L * x1); x1 *= amount_t(123L); - assertEqual(amount_t(15129L), x1); + BOOST_CHECK_EQUAL(amount_t(15129L), x1); x1 *= 123L; - assertEqual(amount_t(1860867L), x1); + BOOST_CHECK_EQUAL(amount_t(1860867L), x1); amount_t x4("123456789123456789123456789"); - assertEqual(amount_t("15241578780673678546105778281054720515622620750190521"), + BOOST_CHECK_EQUAL(amount_t("15241578780673678546105778281054720515622620750190521"), x4 * x4); - assertValid(x1); - assertValid(y1); - assertValid(x4); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x4.valid()); } -void AmountTestCase::testFractionalMultiplication() +BOOST_AUTO_TEST_CASE(testFractionalMultiplication) { amount_t x1("123.123"); amount_t y1("456.456"); - assertEqual(amount_t(0L), x1 * 0L); - assertEqual(amount_t(0L), amount_t(0L) * x1); - assertEqual(amount_t(0L), 0L * x1); - assertEqual(x1, x1 * 1L); - assertEqual(x1, amount_t(1L) * x1); - assertEqual(x1, 1L * x1); - assertEqual(- x1, x1 * -1L); - assertEqual(- x1, amount_t(-1L) * x1); - assertEqual(- x1, -1L * x1); - assertEqual(amount_t("56200.232088"), x1 * y1); - assertEqual(amount_t("56200.232088"), y1 * x1); - assertEqual(amount_t("56200.232088"), x1 * amount_t("456.456")); - assertEqual(amount_t("56200.232088"), amount_t("456.456") * x1); - assertEqual(amount_t("56200.232088"), amount_t("456.456") * x1); + BOOST_CHECK_EQUAL(amount_t(0L), x1 * 0L); + BOOST_CHECK_EQUAL(amount_t(0L), amount_t(0L) * x1); + BOOST_CHECK_EQUAL(amount_t(0L), 0L * x1); + BOOST_CHECK_EQUAL(x1, x1 * 1L); + BOOST_CHECK_EQUAL(x1, amount_t(1L) * x1); + BOOST_CHECK_EQUAL(x1, 1L * x1); + BOOST_CHECK_EQUAL(- x1, x1 * -1L); + BOOST_CHECK_EQUAL(- x1, amount_t(-1L) * x1); + BOOST_CHECK_EQUAL(- x1, -1L * x1); + BOOST_CHECK_EQUAL(amount_t("56200.232088"), x1 * y1); + BOOST_CHECK_EQUAL(amount_t("56200.232088"), y1 * x1); + BOOST_CHECK_EQUAL(amount_t("56200.232088"), x1 * amount_t("456.456")); + BOOST_CHECK_EQUAL(amount_t("56200.232088"), amount_t("456.456") * x1); + BOOST_CHECK_EQUAL(amount_t("56200.232088"), amount_t("456.456") * x1); x1 *= amount_t("123.123"); - assertEqual(amount_t("15159.273129"), x1); + BOOST_CHECK_EQUAL(amount_t("15159.273129"), x1); x1 *= amount_t("123.123"); - assertEqual(amount_t("1866455.185461867"), x1); + BOOST_CHECK_EQUAL(amount_t("1866455.185461867"), x1); x1 *= 123L; - assertEqual(amount_t("229573987.811809641"), x1); + BOOST_CHECK_EQUAL(amount_t("229573987.811809641"), x1); amount_t x2("123456789123456789.123456789123456789"); - assertEqual(amount_t("15241578780673678546105778311537878.046486820281054720515622620750190521"), + BOOST_CHECK_EQUAL(amount_t("15241578780673678546105778311537878.046486820281054720515622620750190521"), x2 * x2); - assertValid(x1); - assertValid(y1); - assertValid(x2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x2.valid()); } -void AmountTestCase::testCommodityMultiplication() +BOOST_AUTO_TEST_CASE(testCommodityMultiplication) { amount_t x0; amount_t x1("$123.12"); @@ -797,134 +801,134 @@ void AmountTestCase::testCommodityMultiplication() amount_t x4("123.45 euro"); amount_t x5("123.45€"); - assertEqual(amount_t("$0.00"), x1 * 0L); - assertEqual(amount_t("$0.00"), 0L * x1); - assertEqual(x1, x1 * 1L); - assertEqual(x1, 1L * x1); - assertEqual(- x1, x1 * -1L); - assertEqual(- x1, -1L * x1); - assertEqual(internalAmount("$56198.124"), x1 * y1); - assertEqual(string("$56198.12"), (x1 * y1).to_string()); - assertEqual(internalAmount("$56198.124"), y1 * x1); - assertEqual(string("$56198.12"), (y1 * x1).to_string()); + BOOST_CHECK_EQUAL(amount_t("$0.00"), x1 * 0L); + BOOST_CHECK_EQUAL(amount_t("$0.00"), 0L * x1); + BOOST_CHECK_EQUAL(x1, x1 * 1L); + BOOST_CHECK_EQUAL(x1, 1L * x1); + BOOST_CHECK_EQUAL(- x1, x1 * -1L); + BOOST_CHECK_EQUAL(- x1, -1L * x1); + BOOST_CHECK_EQUAL(internalAmount("$56198.124"), x1 * y1); + BOOST_CHECK_EQUAL(string("$56198.12"), (x1 * y1).to_string()); + BOOST_CHECK_EQUAL(internalAmount("$56198.124"), y1 * x1); + BOOST_CHECK_EQUAL(string("$56198.12"), (y1 * x1).to_string()); // Internal amounts retain their precision, even when being // converted to strings - assertEqual(internalAmount("$15199.99986168"), x1 * x2); - assertEqual(internalAmount("$15199.99986168"), x2 * x1); - assertEqual(string("$15200.00"), (x1 * x2).to_string()); - assertEqual(string("$15199.99986168"), (x2 * x1).to_string()); - - assertThrow(x1 * x0, amount_error); - assertThrow(x0 * x1, amount_error); - assertThrow(x0 * x0, amount_error); - //assertThrow(x1 * x3, amount_error); - //assertThrow(x1 * x4, amount_error); - //assertThrow(x1 * x5, amount_error); + BOOST_CHECK_EQUAL(internalAmount("$15199.99986168"), x1 * x2); + BOOST_CHECK_EQUAL(internalAmount("$15199.99986168"), x2 * x1); + BOOST_CHECK_EQUAL(string("$15200.00"), (x1 * x2).to_string()); + BOOST_CHECK_EQUAL(string("$15199.99986168"), (x2 * x1).to_string()); + + BOOST_CHECK_THROW(x1 * x0, amount_error); + BOOST_CHECK_THROW(x0 * x1, amount_error); + BOOST_CHECK_THROW(x0 * x0, amount_error); + //BOOST_CHECK_THROW(x1 * x3, amount_error); + //BOOST_CHECK_THROW(x1 * x4, amount_error); + //BOOST_CHECK_THROW(x1 * x5, amount_error); x1 *= amount_t("123.12"); - assertEqual(internalAmount("$15158.5344"), x1); - assertEqual(string("$15158.53"), x1.to_string()); + BOOST_CHECK_EQUAL(internalAmount("$15158.5344"), x1); + BOOST_CHECK_EQUAL(string("$15158.53"), x1.to_string()); x1 *= amount_t("123.12"); - assertEqual(internalAmount("$1866318.755328"), x1); - assertEqual(string("$1866318.76"), x1.to_string()); + BOOST_CHECK_EQUAL(internalAmount("$1866318.755328"), x1); + BOOST_CHECK_EQUAL(string("$1866318.76"), x1.to_string()); x1 *= 123L; - assertEqual(internalAmount("$229557206.905344"), x1); - assertEqual(string("$229557206.91"), x1.to_string()); + BOOST_CHECK_EQUAL(internalAmount("$229557206.905344"), x1); + BOOST_CHECK_EQUAL(string("$229557206.91"), x1.to_string()); amount_t x7(internalAmount("$123456789123456789.123456789123456789")); - assertEqual(internalAmount("$15241578780673678546105778311537878.046486820281054720515622620750190521"), + BOOST_CHECK_EQUAL(internalAmount("$15241578780673678546105778311537878.046486820281054720515622620750190521"), x7 * x7); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x7); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x7.valid()); } -void AmountTestCase::testIntegerDivision() +BOOST_AUTO_TEST_CASE(testIntegerDivision) { amount_t x1(123L); amount_t y1(456L); - assertThrow(x1 / 0L, amount_error); - assertEqual(amount_t(0L), amount_t(0L) / x1); - assertEqual(amount_t(0L), 0L / x1); - assertEqual(x1, x1 / 1L); - assertEqual(string("0.00813"), (amount_t(1L) / x1).to_string()); - assertEqual(string("0.00813"), (1L / x1).to_string()); - assertEqual(- x1, x1 / -1L); - assertEqual(string("-0.00813"), (amount_t(-1L) / x1).to_string()); - assertEqual(string("-0.00813"), (-1L / x1).to_string()); - assertEqual(string("0.269737"), (x1 / y1).to_string()); - assertEqual(string("3.707317"), (y1 / x1).to_string()); - assertEqual(string("0.269737"), (x1 / 456L).to_string()); - assertEqual(string("3.707317"), (amount_t(456L) / x1).to_string()); - assertEqual(string("3.707317"), (456L / x1).to_string()); + BOOST_CHECK_THROW(x1 / 0L, amount_error); + BOOST_CHECK_EQUAL(amount_t(0L), amount_t(0L) / x1); + BOOST_CHECK_EQUAL(amount_t(0L), 0L / x1); + BOOST_CHECK_EQUAL(x1, x1 / 1L); + BOOST_CHECK_EQUAL(string("0.00813"), (amount_t(1L) / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.00813"), (1L / x1).to_string()); + BOOST_CHECK_EQUAL(- x1, x1 / -1L); + BOOST_CHECK_EQUAL(string("-0.00813"), (amount_t(-1L) / x1).to_string()); + BOOST_CHECK_EQUAL(string("-0.00813"), (-1L / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.269737"), (x1 / y1).to_string()); + BOOST_CHECK_EQUAL(string("3.707317"), (y1 / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.269737"), (x1 / 456L).to_string()); + BOOST_CHECK_EQUAL(string("3.707317"), (amount_t(456L) / x1).to_string()); + BOOST_CHECK_EQUAL(string("3.707317"), (456L / x1).to_string()); x1 /= amount_t(456L); - assertEqual(string("0.269737"), x1.to_string()); + BOOST_CHECK_EQUAL(string("0.269737"), x1.to_string()); x1 /= 456L; - assertEqual(string("0.000591528163"), x1.to_string()); + BOOST_CHECK_EQUAL(string("0.000591528163"), x1.to_string()); amount_t x4("123456789123456789123456789"); amount_t y4("56"); - assertEqual(amount_t(1L), x4 / x4); - assertEqual(string("2204585520061728377204585.517857"), (x4 / y4).to_string()); + BOOST_CHECK_EQUAL(amount_t(1L), x4 / x4); + BOOST_CHECK_EQUAL(string("2204585520061728377204585.517857"), (x4 / y4).to_string()); - assertEqual(amount_t("0.000000000000000000000000000001"), + BOOST_CHECK_EQUAL(amount_t("0.000000000000000000000000000001"), amount_t("10") / amount_t("10000000000000000000000000000000")); - assertValid(x1); - assertValid(y1); - assertValid(x4); - assertValid(y4); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(y4.valid()); } -void AmountTestCase::testFractionalDivision() +BOOST_AUTO_TEST_CASE(testFractionalDivision) { amount_t x1("123.123"); amount_t y1("456.456"); - assertThrow(x1 / 0L, amount_error); - assertEqual(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); - assertEqual(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); - assertEqual(x1, x1 / amount_t("1.0")); - assertEqual(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); - assertEqual(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); - assertEqual(- x1, x1 / amount_t("-1.0")); - assertEqual(string("-0.0081219593"), (amount_t("-1.0") / x1).to_string()); - assertEqual(string("-0.0081219593"), (amount_t("-1.0") / x1).to_string()); - assertEqual(string("0.269736842105"), (x1 / y1).to_string()); - assertEqual(string("3.707317073171"), (y1 / x1).to_string()); - assertEqual(string("0.269736842105"), (x1 / amount_t("456.456")).to_string()); - assertEqual(string("3.707317073171"), (amount_t("456.456") / x1).to_string()); - assertEqual(string("3.707317073171"), (amount_t("456.456") / x1).to_string()); + BOOST_CHECK_THROW(x1 / 0L, amount_error); + BOOST_CHECK_EQUAL(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(x1, x1 / amount_t("1.0")); + BOOST_CHECK_EQUAL(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.0081219593"), (amount_t("1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(- x1, x1 / amount_t("-1.0")); + BOOST_CHECK_EQUAL(string("-0.0081219593"), (amount_t("-1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(string("-0.0081219593"), (amount_t("-1.0") / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.269736842105"), (x1 / y1).to_string()); + BOOST_CHECK_EQUAL(string("3.707317073171"), (y1 / x1).to_string()); + BOOST_CHECK_EQUAL(string("0.269736842105"), (x1 / amount_t("456.456")).to_string()); + BOOST_CHECK_EQUAL(string("3.707317073171"), (amount_t("456.456") / x1).to_string()); + BOOST_CHECK_EQUAL(string("3.707317073171"), (amount_t("456.456") / x1).to_string()); x1 /= amount_t("456.456"); - assertEqual(string("0.269736842105"), x1.to_string()); + BOOST_CHECK_EQUAL(string("0.269736842105"), x1.to_string()); x1 /= amount_t("456.456"); - assertEqual(string("0.000590937225286255757"), x1.to_string()); + BOOST_CHECK_EQUAL(string("0.000590937225286255757"), x1.to_string()); x1 /= 456L; - assertEqual(string("0.000001295914967733017011337"), x1.to_string()); + BOOST_CHECK_EQUAL(string("0.000001295914967733017011337"), x1.to_string()); amount_t x4("1234567891234567.89123456789"); amount_t y4("56.789"); - assertEqual(amount_t("1.0"), x4 / x4); - assertEqual(string("21739560323910.75544972737484371973"), (x4 / y4).to_string()); + BOOST_CHECK_EQUAL(amount_t("1.0"), x4 / x4); + BOOST_CHECK_EQUAL(string("21739560323910.75544972737484371973"), (x4 / y4).to_string()); - assertValid(x1); - assertValid(y1); - assertValid(x4); - assertValid(y4); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(y1.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(y4.valid()); } -void AmountTestCase::testCommodityDivision() +BOOST_AUTO_TEST_CASE(testCommodityDivision) { amount_t x0; amount_t x1("$123.12"); @@ -934,59 +938,59 @@ void AmountTestCase::testCommodityDivision() amount_t x4("123.45 euro"); amount_t x5("123.45€"); - assertThrow(x1 / 0L, amount_error); - assertEqual(amount_t("$0.00"), 0L / x1); - assertEqual(x1, x1 / 1L); - assertEqual(string("$0.00812216"), (1L / x1).to_fullstring()); - assertEqual(- x1, x1 / -1L); - assertEqual(string("$-0.00812216"), (-1L / x1).to_fullstring()); - assertEqual(string("$0.26973382"), (x1 / y1).to_fullstring()); - assertEqual(string("$0.27"), (x1 / y1).to_string()); - assertEqual(string("$3.70735867"), (y1 / x1).to_fullstring()); - assertEqual(string("$3.71"), (y1 / x1).to_string()); + BOOST_CHECK_THROW(x1 / 0L, amount_error); + BOOST_CHECK_EQUAL(amount_t("$0.00"), 0L / x1); + BOOST_CHECK_EQUAL(x1, x1 / 1L); + BOOST_CHECK_EQUAL(string("$0.00812216"), (1L / x1).to_fullstring()); + BOOST_CHECK_EQUAL(- x1, x1 / -1L); + BOOST_CHECK_EQUAL(string("$-0.00812216"), (-1L / x1).to_fullstring()); + BOOST_CHECK_EQUAL(string("$0.26973382"), (x1 / y1).to_fullstring()); + BOOST_CHECK_EQUAL(string("$0.27"), (x1 / y1).to_string()); + BOOST_CHECK_EQUAL(string("$3.70735867"), (y1 / x1).to_fullstring()); + BOOST_CHECK_EQUAL(string("$3.71"), (y1 / x1).to_string()); // Internal amounts retain their precision, even when being // converted to strings - assertEqual(string("$0.99727201"), (x1 / x2).to_fullstring()); - assertEqual(string("$1.00273545321637"), (x2 / x1).to_fullstring()); - assertEqual(string("$1.00"), (x1 / x2).to_string()); - assertEqual(string("$1.00273545321637"), (x2 / x1).to_string()); - - assertThrow(x1 / x0, amount_error); - assertThrow(x0 / x1, amount_error); - assertThrow(x0 / x0, amount_error); - //assertThrow(x1 / x3, amount_error); - //assertThrow(x1 / x4, amount_error); - //assertThrow(x1 / x5, amount_error); + BOOST_CHECK_EQUAL(string("$0.99727201"), (x1 / x2).to_fullstring()); + BOOST_CHECK_EQUAL(string("$1.00273545321637"), (x2 / x1).to_fullstring()); + BOOST_CHECK_EQUAL(string("$1.00"), (x1 / x2).to_string()); + BOOST_CHECK_EQUAL(string("$1.00273545321637"), (x2 / x1).to_string()); + + BOOST_CHECK_THROW(x1 / x0, amount_error); + BOOST_CHECK_THROW(x0 / x1, amount_error); + BOOST_CHECK_THROW(x0 / x0, amount_error); + //BOOST_CHECK_THROW(x1 / x3, amount_error); + //BOOST_CHECK_THROW(x1 / x4, amount_error); + //BOOST_CHECK_THROW(x1 / x5, amount_error); x1 /= amount_t("123.12"); - assertEqual(string("$1.00"), x1.to_string()); + BOOST_CHECK_EQUAL(string("$1.00"), x1.to_string()); x1 /= amount_t("123.12"); - assertEqual(string("$0.00812216"), x1.to_fullstring()); - assertEqual(string("$0.01"), x1.to_string()); + BOOST_CHECK_EQUAL(string("$0.00812216"), x1.to_fullstring()); + BOOST_CHECK_EQUAL(string("$0.01"), x1.to_string()); x1 /= 123L; - assertEqual(string("$0.00006603"), x1.to_fullstring()); - assertEqual(string("$0.00"), x1.to_string()); + BOOST_CHECK_EQUAL(string("$0.00006603"), x1.to_fullstring()); + BOOST_CHECK_EQUAL(string("$0.00"), x1.to_string()); amount_t x6(internalAmount("$237235987235987.98723987235978")); amount_t x7(internalAmount("$123456789123456789.123456789123456789")); - assertEqual(amount_t("$1"), x7 / x7); - assertEqual(string("$0.0019216115121765559608381226612019501"), + BOOST_CHECK_EQUAL(amount_t("$1"), x7 / x7); + BOOST_CHECK_EQUAL(string("$0.0019216115121765559608381226612019501"), (x6 / x7).to_fullstring()); - assertEqual(string("$520.39654928343335571379527154924040947272"), + BOOST_CHECK_EQUAL(string("$520.39654928343335571379527154924040947272"), (x7 / x6).to_fullstring()); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); } -void AmountTestCase::testNegation() +BOOST_AUTO_TEST_CASE(testNegation) { amount_t x0; amount_t x1(-123456L); @@ -997,29 +1001,29 @@ void AmountTestCase::testNegation() amount_t x8(string("-123.456")); amount_t x9(- x3); - assertThrow(x0.negated(), amount_error); - assertEqual(x5, x1); - assertEqual(x7, x1); - assertEqual(x6, x3); - assertEqual(x8, x3); - assertEqual(- x6, x9); - assertEqual(x3.negated(), x9); + BOOST_CHECK_THROW(x0.negated(), amount_error); + BOOST_CHECK_EQUAL(x5, x1); + BOOST_CHECK_EQUAL(x7, x1); + BOOST_CHECK_EQUAL(x6, x3); + BOOST_CHECK_EQUAL(x8, x3); + BOOST_CHECK_EQUAL(- x6, x9); + BOOST_CHECK_EQUAL(x3.negated(), x9); amount_t x10(x9.negated()); - assertEqual(x3, x10); + BOOST_CHECK_EQUAL(x3, x10); - assertValid(x1); - assertValid(x3); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } -void AmountTestCase::testCommodityNegation() +BOOST_AUTO_TEST_CASE(testCommodityNegation) { amount_t x1("$123.45"); amount_t x2("-$123.45"); @@ -1032,78 +1036,78 @@ void AmountTestCase::testCommodityNegation() amount_t x9("123.45€"); amount_t x10("-123.45€"); - assertEqual(amount_t("$-123.45"), - x1); - assertEqual(amount_t("$123.45"), - x2); - assertEqual(amount_t("$123.45"), - x3); - assertEqual(amount_t("DM -123.45"), - x4); - assertEqual(amount_t("DM 123.45"), - x5); - assertEqual(amount_t("DM 123.45"), - x6); - assertEqual(amount_t("-123.45 euro"), - x7); - assertEqual(amount_t("123.45 euro"), - x8); - assertEqual(amount_t("-123.45€"), - x9); - assertEqual(amount_t("123.45€"), - x10); - - assertEqual(amount_t("$-123.45"), x1.negated()); - assertEqual(amount_t("$123.45"), x2.negated()); - assertEqual(amount_t("$123.45"), x3.negated()); - - assertEqual(string("$-123.45"), (- x1).to_string()); - assertEqual(string("$123.45"), (- x2).to_string()); - assertEqual(string("$123.45"), (- x3).to_string()); - assertEqual(string("DM -123.45"), (- x4).to_string()); - assertEqual(string("DM 123.45"), (- x5).to_string()); - assertEqual(string("DM 123.45"), (- x6).to_string()); - assertEqual(string("-123.45 euro"), (- x7).to_string()); - assertEqual(string("123.45 euro"), (- x8).to_string()); - assertEqual(string("-123.45€"), (- x9).to_string()); - assertEqual(string("123.45€"), (- x10).to_string()); - - assertEqual(amount_t("$-123.45"), x1.negated()); - assertEqual(amount_t("$123.45"), x2.negated()); - assertEqual(amount_t("$123.45"), x3.negated()); - - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); - assertValid(x5); - assertValid(x6); - assertValid(x7); - assertValid(x8); - assertValid(x9); - assertValid(x10); + BOOST_CHECK_EQUAL(amount_t("$-123.45"), - x1); + BOOST_CHECK_EQUAL(amount_t("$123.45"), - x2); + BOOST_CHECK_EQUAL(amount_t("$123.45"), - x3); + BOOST_CHECK_EQUAL(amount_t("DM -123.45"), - x4); + BOOST_CHECK_EQUAL(amount_t("DM 123.45"), - x5); + BOOST_CHECK_EQUAL(amount_t("DM 123.45"), - x6); + BOOST_CHECK_EQUAL(amount_t("-123.45 euro"), - x7); + BOOST_CHECK_EQUAL(amount_t("123.45 euro"), - x8); + BOOST_CHECK_EQUAL(amount_t("-123.45€"), - x9); + BOOST_CHECK_EQUAL(amount_t("123.45€"), - x10); + + BOOST_CHECK_EQUAL(amount_t("$-123.45"), x1.negated()); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x2.negated()); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x3.negated()); + + BOOST_CHECK_EQUAL(string("$-123.45"), (- x1).to_string()); + BOOST_CHECK_EQUAL(string("$123.45"), (- x2).to_string()); + BOOST_CHECK_EQUAL(string("$123.45"), (- x3).to_string()); + BOOST_CHECK_EQUAL(string("DM -123.45"), (- x4).to_string()); + BOOST_CHECK_EQUAL(string("DM 123.45"), (- x5).to_string()); + BOOST_CHECK_EQUAL(string("DM 123.45"), (- x6).to_string()); + BOOST_CHECK_EQUAL(string("-123.45 euro"), (- x7).to_string()); + BOOST_CHECK_EQUAL(string("123.45 euro"), (- x8).to_string()); + BOOST_CHECK_EQUAL(string("-123.45€"), (- x9).to_string()); + BOOST_CHECK_EQUAL(string("123.45€"), (- x10).to_string()); + + BOOST_CHECK_EQUAL(amount_t("$-123.45"), x1.negated()); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x2.negated()); + BOOST_CHECK_EQUAL(amount_t("$123.45"), x3.negated()); + + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); + BOOST_CHECK(x5.valid()); + BOOST_CHECK(x6.valid()); + BOOST_CHECK(x7.valid()); + BOOST_CHECK(x8.valid()); + BOOST_CHECK(x9.valid()); + BOOST_CHECK(x10.valid()); } -void AmountTestCase::testAbs() +BOOST_AUTO_TEST_CASE(testAbs) { amount_t x0; amount_t x1(-1234L); amount_t x2(1234L); - assertThrow(x0.abs(), amount_error); - assertEqual(amount_t(1234L), x1.abs()); - assertEqual(amount_t(1234L), x2.abs()); + BOOST_CHECK_THROW(x0.abs(), amount_error); + BOOST_CHECK_EQUAL(amount_t(1234L), x1.abs()); + BOOST_CHECK_EQUAL(amount_t(1234L), x2.abs()); - assertValid(x0); - assertValid(x1); - assertValid(x2); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); } -void AmountTestCase::testCommodityAbs() +BOOST_AUTO_TEST_CASE(testCommodityAbs) { amount_t x1("$-1234.56"); amount_t x2("$1234.56"); - assertEqual(amount_t("$1234.56"), x1.abs()); - assertEqual(amount_t("$1234.56"), x2.abs()); + BOOST_CHECK_EQUAL(amount_t("$1234.56"), x1.abs()); + BOOST_CHECK_EQUAL(amount_t("$1234.56"), x2.abs()); - assertValid(x1); - assertValid(x2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); } #ifndef NOT_FOR_PYTHON #if 0 -void AmountTestCase::testReduction() +BOOST_AUTO_TEST_CASE(testReduction) { amount_t x0; amount_t x1("60s"); @@ -1119,17 +1123,17 @@ void AmountTestCase::testReduction() amount_t x11("1000h"); // 3600000s amount_t x12("10000h"); // 36000000s - assertThrow(x0.reduce(), amount_error); - assertThrow(x0.unreduce(), amount_error); - assertEqual(x2, x5.reduce()); - assertEqual(x3, x6.reduce()); - assertEqual(x10, x4.reduce()); - assertEqual(string("100.0h"), x4.unreduce().to_string()); + BOOST_CHECK_THROW(x0.reduce(), amount_error); + BOOST_CHECK_THROW(x0.unreduce(), amount_error); + BOOST_CHECK_EQUAL(x2, x5.reduce()); + BOOST_CHECK_EQUAL(x3, x6.reduce()); + BOOST_CHECK_EQUAL(x10, x4.reduce()); + BOOST_CHECK_EQUAL(string("100.0h"), x4.unreduce().to_string()); } #endif #endif // NOT_FOR_PYTHON -void AmountTestCase::testSign() +BOOST_AUTO_TEST_CASE(testSign) { amount_t x0; amount_t x1("0.0000000000000000000000000000000000001"); @@ -1137,141 +1141,141 @@ void AmountTestCase::testSign() amount_t x3("1"); amount_t x4("-1"); - assertThrow(x0.sign(), amount_error); - assertTrue(x1.sign() > 0); - assertTrue(x2.sign() < 0); - assertTrue(x3.sign() > 0); - assertTrue(x4.sign() < 0); - - assertValid(x0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); + BOOST_CHECK_THROW(x0.sign(), amount_error); + BOOST_CHECK(x1.sign() > 0); + BOOST_CHECK(x2.sign() < 0); + BOOST_CHECK(x3.sign() > 0); + BOOST_CHECK(x4.sign() < 0); + + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); } -void AmountTestCase::testCommoditySign() +BOOST_AUTO_TEST_CASE(testCommoditySign) { amount_t x1(internalAmount("$0.0000000000000000000000000000000000001")); amount_t x2(internalAmount("$-0.0000000000000000000000000000000000001")); amount_t x3("$1"); amount_t x4("$-1"); - assertTrue(x1.sign() != 0); - assertTrue(x2.sign() != 0); - assertTrue(x3.sign() > 0); - assertTrue(x4.sign() < 0); + BOOST_CHECK(x1.sign() != 0); + BOOST_CHECK(x2.sign() != 0); + BOOST_CHECK(x3.sign() > 0); + BOOST_CHECK(x4.sign() < 0); - assertValid(x1); - assertValid(x2); - assertValid(x3); - assertValid(x4); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); + BOOST_CHECK(x3.valid()); + BOOST_CHECK(x4.valid()); } -void AmountTestCase::testTruth() +BOOST_AUTO_TEST_CASE(testTruth) { amount_t x0; amount_t x1("1234"); amount_t x2("1234.56"); #ifndef NOT_FOR_PYTHON - assertThrow(x0.operator bool(), amount_error); + BOOST_CHECK_THROW(x0.operator bool(), amount_error); #endif // NOT_FOR_PYTHON - assertTrue(x1); - assertTrue(x2); + BOOST_CHECK(x1); + BOOST_CHECK(x2); - assertValid(x0); - assertValid(x1); - assertValid(x2); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); } -void AmountTestCase::testCommodityTruth() +BOOST_AUTO_TEST_CASE(testCommodityTruth) { amount_t x1("$1234"); amount_t x2("$1234.56"); if (x1) - assertTrue(true); + BOOST_CHECK(true); if (x2) - assertTrue(true); + BOOST_CHECK(true); - assertValid(x1); - assertValid(x2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); } -void AmountTestCase::testForZero() +BOOST_AUTO_TEST_CASE(testForZero) { amount_t x0; amount_t x1("0.000000000000000000001"); - assertTrue(x1); - assertThrow(x0.is_zero(), amount_error); - assertThrow(x0.is_realzero(), amount_error); - assertFalse(x1.is_zero()); - assertFalse(x1.is_realzero()); + BOOST_CHECK(x1); + BOOST_CHECK_THROW(x0.is_zero(), amount_error); + BOOST_CHECK_THROW(x0.is_realzero(), amount_error); + BOOST_CHECK(! x1.is_zero()); + BOOST_CHECK(! x1.is_realzero()); - assertValid(x0); - assertValid(x1); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); } -void AmountTestCase::testCommodityForZero() +BOOST_AUTO_TEST_CASE(testCommodityForZero) { amount_t x1(internalAmount("$0.000000000000000000001")); - assertTrue(x1); // an internal amount never betrays its precision - assertFalse(x1.is_zero()); - assertFalse(x1.is_realzero()); + BOOST_CHECK(x1); // an internal amount never betrays its precision + BOOST_CHECK(! x1.is_zero()); + BOOST_CHECK(! x1.is_realzero()); - assertValid(x1); + BOOST_CHECK(x1.valid()); } -void AmountTestCase::testIntegerConversion() +BOOST_AUTO_TEST_CASE(testIntegerConversion) { amount_t x0; amount_t x1(123456L); amount_t x2("12345682348723487324"); - assertThrow(x0.to_long(), amount_error); - assertThrow(x0.to_double(), amount_error); - assertFalse(x2.fits_in_long()); - assertEqual(123456L, x1.to_long()); - assertEqual(123456.0, x1.to_double()); - assertEqual(string("123456"), x1.to_string()); - assertEqual(string("123456"), x1.quantity_string()); + BOOST_CHECK_THROW(x0.to_long(), amount_error); + BOOST_CHECK_THROW(x0.to_double(), amount_error); + BOOST_CHECK(! x2.fits_in_long()); + BOOST_CHECK_EQUAL(123456L, x1.to_long()); + BOOST_CHECK_EQUAL(123456.0, x1.to_double()); + BOOST_CHECK_EQUAL(string("123456"), x1.to_string()); + BOOST_CHECK_EQUAL(string("123456"), x1.quantity_string()); - assertValid(x1); + BOOST_CHECK(x1.valid()); } -void AmountTestCase::testFractionalConversion() +BOOST_AUTO_TEST_CASE(testFractionalConversion) { amount_t x1("1234.56"); amount_t x2("1234.5683787634678348734"); - assertEqual(1235L, x1.to_long()); - assertEqual(1234.56, x1.to_double()); - assertEqual(string("1234.56"), x1.to_string()); - assertEqual(string("1234.56"), x1.quantity_string()); + BOOST_CHECK_EQUAL(1235L, x1.to_long()); + BOOST_CHECK_EQUAL(1234.56, x1.to_double()); + BOOST_CHECK_EQUAL(string("1234.56"), x1.to_string()); + BOOST_CHECK_EQUAL(string("1234.56"), x1.quantity_string()); - assertValid(x1); + BOOST_CHECK(x1.valid()); } -void AmountTestCase::testCommodityConversion() +BOOST_AUTO_TEST_CASE(testCommodityConversion) { amount_t x1("$1234.56"); - assertEqual(1235L, x1.to_long()); - assertEqual(1234.56, x1.to_double()); - assertEqual(string("$1234.56"), x1.to_string()); - assertEqual(string("1234.56"), x1.quantity_string()); + BOOST_CHECK_EQUAL(1235L, x1.to_long()); + BOOST_CHECK_EQUAL(1234.56, x1.to_double()); + BOOST_CHECK_EQUAL(string("$1234.56"), x1.to_string()); + BOOST_CHECK_EQUAL(string("1234.56"), x1.quantity_string()); - assertValid(x1); + BOOST_CHECK(x1.valid()); } #ifndef NOT_FOR_PYTHON -void AmountTestCase::testPrinting() +BOOST_AUTO_TEST_CASE(testPrinting) { amount_t x0; amount_t x1("982340823.380238098235098235098235098"); @@ -1279,22 +1283,22 @@ void AmountTestCase::testPrinting() { std::ostringstream bufstr; x0.print(bufstr); - assertEqual(std::string("<null>"), bufstr.str()); + BOOST_CHECK_EQUAL(std::string("<null>"), bufstr.str()); } { std::ostringstream bufstr; x1.print(bufstr); - assertEqual(std::string("982340823.380238098235098235098235098"), + BOOST_CHECK_EQUAL(std::string("982340823.380238098235098235098235098"), bufstr.str()); } - assertValid(x0); - assertValid(x1); + BOOST_CHECK(x0.valid()); + BOOST_CHECK(x1.valid()); } -void AmountTestCase::testCommodityPrinting() +BOOST_AUTO_TEST_CASE(testCommodityPrinting) { amount_t x1(internalAmount("$982340823.386238098235098235098235098")); amount_t x2("$982340823.38"); @@ -1303,7 +1307,7 @@ void AmountTestCase::testCommodityPrinting() std::ostringstream bufstr; x1.print(bufstr); - assertEqual(std::string("$982340823.386238098235098235098235098"), + BOOST_CHECK_EQUAL(std::string("$982340823.386238098235098235098235098"), bufstr.str()); } @@ -1311,7 +1315,7 @@ void AmountTestCase::testCommodityPrinting() std::ostringstream bufstr; (x1 * x2).print(bufstr); - assertEqual(std::string("$964993493285024293.18099172508158508135413499124"), + BOOST_CHECK_EQUAL(std::string("$964993493285024293.18099172508158508135413499124"), bufstr.str()); } @@ -1319,11 +1323,13 @@ void AmountTestCase::testCommodityPrinting() std::ostringstream bufstr; (x2 * x1).print(bufstr); - assertEqual(std::string("$964993493285024293.18"), bufstr.str()); + BOOST_CHECK_EQUAL(std::string("$964993493285024293.18"), bufstr.str()); } - assertValid(x1); - assertValid(x2); + BOOST_CHECK(x1.valid()); + BOOST_CHECK(x2.valid()); } #endif // NOT_FOR_PYTHON + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit/t_amount.h b/test/unit/t_amount.h deleted file mode 100644 index 3d63b2d7..00000000 --- a/test/unit/t_amount.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _T_AMOUNT_H -#define _T_AMOUNT_H - -#include "UnitTests.h" - -class AmountTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(AmountTestCase); - - CPPUNIT_TEST(testConstructors); - CPPUNIT_TEST(testCommodityConstructors); - CPPUNIT_TEST(testParser); - CPPUNIT_TEST(testAssignment); - CPPUNIT_TEST(testCommodityAssignment); - CPPUNIT_TEST(testEquality); - CPPUNIT_TEST(testCommodityEquality); - CPPUNIT_TEST(testComparisons); - CPPUNIT_TEST(testCommodityComparisons); - CPPUNIT_TEST(testIntegerAddition); - CPPUNIT_TEST(testFractionalAddition); - CPPUNIT_TEST(testCommodityAddition); - CPPUNIT_TEST(testIntegerSubtraction); - CPPUNIT_TEST(testFractionalSubtraction); - CPPUNIT_TEST(testCommoditySubtraction); - CPPUNIT_TEST(testIntegerMultiplication); - CPPUNIT_TEST(testFractionalMultiplication); - CPPUNIT_TEST(testCommodityMultiplication); - CPPUNIT_TEST(testIntegerDivision); - CPPUNIT_TEST(testFractionalDivision); - CPPUNIT_TEST(testCommodityDivision); - CPPUNIT_TEST(testNegation); - CPPUNIT_TEST(testCommodityNegation); - CPPUNIT_TEST(testAbs); - CPPUNIT_TEST(testCommodityAbs); -#if 0 - CPPUNIT_TEST(testReduction); -#endif - CPPUNIT_TEST(testSign); - CPPUNIT_TEST(testCommoditySign); - CPPUNIT_TEST(testTruth); - CPPUNIT_TEST(testCommodityTruth); - CPPUNIT_TEST(testForZero); - CPPUNIT_TEST(testCommodityForZero); - CPPUNIT_TEST(testIntegerConversion); - CPPUNIT_TEST(testFractionalConversion); - CPPUNIT_TEST(testCommodityConversion); - CPPUNIT_TEST(testPrinting); - CPPUNIT_TEST(testCommodityPrinting); - - CPPUNIT_TEST_SUITE_END(); - -public: - AmountTestCase() {} - virtual ~AmountTestCase() {} - - virtual void setUp(); - virtual void tearDown(); - - void testConstructors(); - void testCommodityConstructors(); - void testParser(); - void testAssignment(); - void testCommodityAssignment(); - void testEquality(); - void testCommodityEquality(); - void testComparisons(); - void testCommodityComparisons(); - void testIntegerAddition(); - void testFractionalAddition(); - void testCommodityAddition(); - void testIntegerSubtraction(); - void testFractionalSubtraction(); - void testCommoditySubtraction(); - void testIntegerMultiplication(); - void testFractionalMultiplication(); - void testCommodityMultiplication(); - void testIntegerDivision(); - void testFractionalDivision(); - void testCommodityDivision(); - void testNegation(); - void testCommodityNegation(); - void testAbs(); - void testCommodityAbs(); - void testFractionalRound(); - void testCommodityRound(); - void testCommodityDisplayRound(); - void testReduction(); - void testSign(); - void testCommoditySign(); - void testTruth(); - void testCommodityTruth(); - void testForZero(); - void testCommodityForZero(); - void testIntegerConversion(); - void testFractionalConversion(); - void testCommodityConversion(); - void testPrinting(); - void testCommodityPrinting(); - -private: - AmountTestCase(const AmountTestCase ©); - void operator=(const AmountTestCase ©); -}; - -#endif // _T_AMOUNT_H diff --git a/test/unit/t_balance.cc b/test/unit/t_balance.cc index c7d633b8..b74a54e7 100644 --- a/test/unit/t_balance.cc +++ b/test/unit/t_balance.cc @@ -1,29 +1,33 @@ -#include <system.hh> +#define BOOST_TEST_DYN_LINK +//#define BOOST_TEST_MODULE balance +#include <boost/test/unit_test.hpp> -#include "t_balance.h" +#include <system.hh> -#include "utils.h" -#include "amount.h" +#include "balance.h" using namespace ledger; -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BalanceTestCase, "math"); +struct balance_fixture { + balance_fixture() { + times_initialize(); + amount_t::initialize(); + + // Cause the display precision for dollars to be initialized to 2. + amount_t x1("$1.00"); + BOOST_CHECK(x1); -void BalanceTestCase::setUp() -{ - times_initialize(); - amount_t::initialize(); + amount_t::stream_fullstrings = true; // make reports from UnitTests accurate + } - // Cause the display precision for dollars to be initialized to 2. - amount_t x1("$1.00"); - assertTrue(x1); + ~balance_fixture() + { + amount_t::stream_fullstrings = false; + amount_t::shutdown(); + times_shutdown(); + } +}; - amount_t::stream_fullstrings = true; // make reports from UnitTests accurate -} +//BOOST_FIXTURE_TEST_SUITE(balance, balance_fixture) -void BalanceTestCase::tearDown() -{ - amount_t::stream_fullstrings = false; - amount_t::shutdown(); - times_shutdown(); -} +//BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit/t_balance.h b/test/unit/t_balance.h deleted file mode 100644 index 8b8ce1b7..00000000 --- a/test/unit/t_balance.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _T_BALANCE_H -#define _T_BALANCE_H - -#include "UnitTests.h" - -class BalanceTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(BalanceTestCase); - - //CPPUNIT_TEST(testConstructors); - - CPPUNIT_TEST_SUITE_END(); - -public: - BalanceTestCase() {} - virtual ~BalanceTestCase() {} - - virtual void setUp(); - virtual void tearDown(); - - //void testConstructors(); - -private: - BalanceTestCase(const BalanceTestCase ©); - void operator=(const BalanceTestCase ©); -}; - -#endif // _T_BALANCE_H diff --git a/test/unit/t_commodity.cc b/test/unit/t_commodity.cc index b8555202..7f797117 100644 --- a/test/unit/t_commodity.cc +++ b/test/unit/t_commodity.cc @@ -1,26 +1,30 @@ -#include <system.hh> +#define BOOST_TEST_DYN_LINK +//#define BOOST_TEST_MODULE commodity +#include <boost/test/unit_test.hpp> -#include "t_commodity.h" +#include <system.hh> #include "amount.h" #include "commodity.h" using namespace ledger; -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CommodityTestCase, "math"); +struct commodity_fixture { + commodity_fixture() { + times_initialize(); + amount_t::initialize(); + amount_t::stream_fullstrings = true; + } -void CommodityTestCase::setUp() { - times_initialize(); - amount_t::initialize(); - amount_t::stream_fullstrings = true; -} + ~commodity_fixture() { + amount_t::shutdown(); + times_shutdown(); + } +}; -void CommodityTestCase::tearDown() { - amount_t::shutdown(); - times_shutdown(); -} +BOOST_FIXTURE_TEST_SUITE(commodity, commodity_fixture) -void CommodityTestCase::testPriceHistory() +BOOST_AUTO_TEST_CASE(testPriceHistory) { #ifndef NOT_FOR_PYTHON datetime_t jan17_05; @@ -45,8 +49,8 @@ void CommodityTestCase::testPriceHistory() amount_t x0; amount_t x1("100.10 AAPL"); - assertThrow(x0.value(), amount_error); - assertFalse(x1.value()); + BOOST_CHECK_THROW(x0.value(), amount_error); + BOOST_CHECK(! x1.value()); // Commodities cannot be constructed by themselves, since a great deal // of their state depends on how they were seen to be used. @@ -74,33 +78,36 @@ void CommodityTestCase::testPriceHistory() #ifndef NOT_FOR_PYTHON optional<amount_t> amt = x1.value(feb28_07sbm); - assertTrue(amt); - assertEqual(amount_t("$1831.83"), *amt); + BOOST_CHECK(amt); + BOOST_CHECK_EQUAL(amount_t("$1831.83"), *amt); amt = x1.value(CURRENT_TIME()); - assertTrue(amt); - assertEqual(string("$2124.12"), amt->to_string()); + BOOST_CHECK(amt); + BOOST_CHECK_EQUAL(string("$2124.12"), amt->to_string()); #ifdef INTEGER_MATH - assertEqual(string("$2124.12"), amt->to_fullstring()); + BOOST_CHECK_EQUAL(string("$2124.12"), amt->to_fullstring()); #else - assertEqual(string("$2124.122"), amt->to_fullstring()); + BOOST_CHECK_EQUAL(string("$2124.122"), amt->to_fullstring()); #endif amt = x1.value(CURRENT_TIME(), euro); - assertTrue(amt); - assertEqual(string("EUR 1366.87"), amt->rounded().to_string()); + BOOST_CHECK(amt); + BOOST_CHECK_EQUAL(string("EUR 1366.87"), amt->rounded().to_string()); // Add a newer Euro pricing aapl.add_price(jan17_07, amount_t("EUR 23.00")); amt = x1.value(CURRENT_TIME(), euro); - assertTrue(amt); - assertEqual(string("EUR 2302.30"), amt->to_string()); + BOOST_CHECK(amt); + BOOST_CHECK_EQUAL(string("EUR 2302.30"), amt->to_string()); amt = x1.value(CURRENT_TIME(), cad); - assertTrue(amt); - assertEqual(string("CAD 3223.22"), amt->to_string()); + BOOST_CHECK(amt); + BOOST_CHECK_EQUAL(string("CAD 3223.22"), amt->to_string()); #endif // NOT_FOR_PYTHON - assertValid(x1); + BOOST_CHECK(x1.valid()); } + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit/t_commodity.h b/test/unit/t_commodity.h deleted file mode 100644 index 1dadb450..00000000 --- a/test/unit/t_commodity.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _T_COMMMODITY_H -#define _T_COMMMODITY_H - -#include "UnitTests.h" - -class CommodityTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(CommodityTestCase); - - CPPUNIT_TEST(testPriceHistory); - - CPPUNIT_TEST_SUITE_END(); - -public: - CommodityTestCase() {} - virtual ~CommodityTestCase() {} - - virtual void setUp(); - virtual void tearDown(); - - void testPriceHistory(); - -private: - CommodityTestCase(const CommodityTestCase ©); - void operator=(const CommodityTestCase ©); -}; - -#endif // _T_COMMMODITY_H diff --git a/test/unit/t_expr.cc b/test/unit/t_expr.cc index d9dc1f1f..f882f3a1 100644 --- a/test/unit/t_expr.cc +++ b/test/unit/t_expr.cc @@ -1,6 +1,8 @@ -#include <system.hh> +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE expr +#include <boost/test/unit_test.hpp> -#include "t_expr.h" +#include <system.hh> #include "expr.h" #include "predicate.h" @@ -9,19 +11,17 @@ using namespace ledger; -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ValueExprTestCase, "expr"); +struct expr_fixture { + expr_fixture() { + times_initialize(); + amount_t::initialize(); + } -void ValueExprTestCase::setUp() -{ - times_initialize(); - amount_t::initialize(); -} - -void ValueExprTestCase::tearDown() -{ - amount_t::shutdown(); - times_shutdown(); -} + ~expr_fixture() { + amount_t::shutdown(); + times_shutdown(); + } +}; // 1. foo and bar // 2. 'foo and bar' @@ -40,7 +40,9 @@ void ValueExprTestCase::tearDown() // 15. foo and bar|baz // 16. foo 'and bar|baz' -void ValueExprTestCase::testPredicateTokenizer1() +BOOST_FIXTURE_TEST_SUITE(expr, expr_fixture) + +BOOST_AUTO_TEST_CASE(testPredicateTokenizer1) { value_t args; args.push_back(string_value("foo")); @@ -50,14 +52,14 @@ void ValueExprTestCase::testPredicateTokenizer1() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer2() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer2) { value_t args; args.push_back(string_value("foo and bar")); @@ -65,14 +67,14 @@ void ValueExprTestCase::testPredicateTokenizer2() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end(), false); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer3() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer3) { value_t args; args.push_back(string_value("(foo")); @@ -82,16 +84,16 @@ void ValueExprTestCase::testPredicateTokenizer3() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer4() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer4) { value_t args; args.push_back(string_value("(")); @@ -103,16 +105,16 @@ void ValueExprTestCase::testPredicateTokenizer4() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer5() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer5) { value_t args; args.push_back(string_value("( foo and")); @@ -121,16 +123,16 @@ void ValueExprTestCase::testPredicateTokenizer5() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end(), false); - assertEqual(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::LPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::RPAREN, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer6() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer6) { value_t args; args.push_back(string_value("=foo")); @@ -140,15 +142,15 @@ void ValueExprTestCase::testPredicateTokenizer6() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TOK_EQ, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_EQ, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer7() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer7) { value_t args; args.push_back(string_value("=foo and bar")); @@ -156,13 +158,13 @@ void ValueExprTestCase::testPredicateTokenizer7() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TOK_EQ, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_EQ, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer8() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer8) { value_t args; args.push_back(string_value("expr 'foo and bar'")); @@ -170,13 +172,13 @@ void ValueExprTestCase::testPredicateTokenizer8() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end(), false); - assertEqual(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer9() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer9) { value_t args; args.push_back(string_value("expr")); @@ -185,13 +187,13 @@ void ValueExprTestCase::testPredicateTokenizer9() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer10() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer10) { value_t args; args.push_back(string_value("expr")); @@ -202,15 +204,15 @@ void ValueExprTestCase::testPredicateTokenizer10() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_EXPR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer11() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer11) { value_t args; args.push_back(string_value("foo")); @@ -222,16 +224,16 @@ void ValueExprTestCase::testPredicateTokenizer11() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer12() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer12) { value_t args; args.push_back(string_value("foo")); @@ -243,16 +245,16 @@ void ValueExprTestCase::testPredicateTokenizer12() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer13() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer13) { value_t args; args.push_back(string_value("foo")); @@ -263,16 +265,16 @@ void ValueExprTestCase::testPredicateTokenizer13() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer14() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer14) { value_t args; args.push_back(string_value("foo")); @@ -283,16 +285,16 @@ void ValueExprTestCase::testPredicateTokenizer14() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer15() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer15) { value_t args; args.push_back(string_value("foo")); @@ -302,16 +304,16 @@ void ValueExprTestCase::testPredicateTokenizer15() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end()); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } -void ValueExprTestCase::testPredicateTokenizer16() +BOOST_AUTO_TEST_CASE(testPredicateTokenizer16) { value_t args; args.push_back(string_value("foo")); @@ -320,11 +322,13 @@ void ValueExprTestCase::testPredicateTokenizer16() #ifndef NOT_FOR_PYTHON query_t::lexer_t tokens(args.begin(), args.end(), false); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); - assertEqual(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_AND, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TOK_OR, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::TERM, tokens.next_token().kind); + BOOST_CHECK_EQUAL(query_t::lexer_t::token_t::END_REACHED, tokens.next_token().kind); #endif } + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit/t_expr.h b/test/unit/t_expr.h deleted file mode 100644 index 2f22db3d..00000000 --- a/test/unit/t_expr.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _T_EXPR_H -#define _T_EXPR_H - -#include "UnitTests.h" - -class ValueExprTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(ValueExprTestCase); - - //CPPUNIT_TEST(testConstructors); - CPPUNIT_TEST(testPredicateTokenizer1); - CPPUNIT_TEST(testPredicateTokenizer2); - CPPUNIT_TEST(testPredicateTokenizer3); - CPPUNIT_TEST(testPredicateTokenizer4); - CPPUNIT_TEST(testPredicateTokenizer5); - CPPUNIT_TEST(testPredicateTokenizer6); - CPPUNIT_TEST(testPredicateTokenizer7); - CPPUNIT_TEST(testPredicateTokenizer8); - CPPUNIT_TEST(testPredicateTokenizer9); - CPPUNIT_TEST(testPredicateTokenizer10); - CPPUNIT_TEST(testPredicateTokenizer11); - CPPUNIT_TEST(testPredicateTokenizer12); - CPPUNIT_TEST(testPredicateTokenizer13); - CPPUNIT_TEST(testPredicateTokenizer14); - CPPUNIT_TEST(testPredicateTokenizer15); - CPPUNIT_TEST(testPredicateTokenizer16); - - CPPUNIT_TEST_SUITE_END(); - -public: - ValueExprTestCase() {} - virtual ~ValueExprTestCase() {} - - virtual void setUp(); - virtual void tearDown(); - - //void testConstructors(); - void testPredicateTokenizer1(); - void testPredicateTokenizer2(); - void testPredicateTokenizer3(); - void testPredicateTokenizer4(); - void testPredicateTokenizer5(); - void testPredicateTokenizer6(); - void testPredicateTokenizer7(); - void testPredicateTokenizer8(); - void testPredicateTokenizer9(); - void testPredicateTokenizer10(); - void testPredicateTokenizer11(); - void testPredicateTokenizer12(); - void testPredicateTokenizer13(); - void testPredicateTokenizer14(); - void testPredicateTokenizer15(); - void testPredicateTokenizer16(); - -private: - ValueExprTestCase(const ValueExprTestCase ©); - void operator=(const ValueExprTestCase ©); -}; - -#endif // _T_EXPR_H 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() diff --git a/test/unit/t_times.h b/test/unit/t_times.h deleted file mode 100644 index 5bbadf21..00000000 --- a/test/unit/t_times.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _T_TIMES_H -#define _T_TIMES_H - -#include "UnitTests.h" - -class DateTimeTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(DateTimeTestCase); - - CPPUNIT_TEST(testConstructors); - - CPPUNIT_TEST_SUITE_END(); - -public: - DateTimeTestCase() {} - virtual ~DateTimeTestCase() {} - - virtual void setUp(); - virtual void tearDown(); - - void testConstructors(); - -private: - DateTimeTestCase(const DateTimeTestCase ©); - void operator=(const DateTimeTestCase ©); -}; - -#endif /* _T_TIMES_H */ diff --git a/test/unit/t_utils.cc b/test/unit/t_utils.cc deleted file mode 100644 index 6c63359c..00000000 --- a/test/unit/t_utils.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include <system.hh> - -#include "t_utils.h" - -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(UtilitiesTestCase, "util"); - diff --git a/test/unit/t_utils.h b/test/unit/t_utils.h deleted file mode 100644 index 4520c580..00000000 --- a/test/unit/t_utils.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _T_UTILS_H -#define _T_UTILS_H - -#include "UnitTests.h" - -class UtilitiesTestCase : public CPPUNIT_NS::TestCase -{ - CPPUNIT_TEST_SUITE(UtilitiesTestCase); - - //CPPUNIT_TEST(testConstructors); - - CPPUNIT_TEST_SUITE_END(); - -public: - UtilitiesTestCase() {} - virtual ~UtilitiesTestCase() {} - - //virtual void setUp(); - //virtual void tearDown(); - - //void testConstructors(); - -private: - UtilitiesTestCase(const UtilitiesTestCase ©); - void operator=(const UtilitiesTestCase ©); -}; - -#endif /* _T_UTILS_H */ |