summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/UnitTests.cc115
-rw-r--r--test/UnitTests.h24
-rw-r--r--test/__init__.py0
-rw-r--r--test/numerics/t_amount.cc1558
-rw-r--r--test/numerics/t_amount.h110
-rw-r--r--test/numerics/t_balance.cc25
-rw-r--r--test/numerics/t_balance.h30
-rw-r--r--test/numerics/t_commodity.cc64
-rw-r--r--test/numerics/t_commodity.h36
-rwxr-xr-xtest/python/PyUnitTests.py5
-rw-r--r--test/python/UnitTests.py9
-rw-r--r--test/python/__init__.py0
-rw-r--r--test/python/numerics/__init__.py0
-rw-r--r--test/python/numerics/t_amount.py1470
-rw-r--r--test/utility/t_times.cc79
-rw-r--r--test/utility/t_times.h28
-rw-r--r--test/utility/t_utils.cc10
-rw-r--r--test/utility/t_utils.h28
-rw-r--r--tests/amounts.h169
-rw-r--r--tests/baseline/10011
-rw-r--r--tests/baseline/10024
-rw-r--r--tests/baseline/10034
-rw-r--r--tests/baseline/10044
-rw-r--r--tests/baseline/10054
-rw-r--r--tests/baseline/10064
-rw-r--r--tests/baseline/10074
-rw-r--r--tests/baseline/10084
-rw-r--r--tests/baseline/10094
-rw-r--r--tests/baseline/10104
-rw-r--r--tests/baseline/10114
-rw-r--r--tests/baseline/10124
-rw-r--r--tests/baseline/10134
-rw-r--r--tests/baseline/10144
-rw-r--r--tests/baseline/10154
-rw-r--r--tests/baseline/10164
-rw-r--r--tests/baseline/10174
-rw-r--r--tests/baseline/10184
-rw-r--r--tests/baseline/10194
-rw-r--r--tests/baseline/10204
-rw-r--r--tests/baseline/10214
-rw-r--r--tests/baseline/10224
-rw-r--r--tests/baseline/10234
-rw-r--r--tests/baseline/10244
-rw-r--r--tests/baseline/10254
-rw-r--r--tests/baseline/10264
-rw-r--r--tests/baseline/10274
-rw-r--r--tests/baseline/10284
-rw-r--r--tests/baseline/10294
-rw-r--r--tests/cases/1001.dat10
-rw-r--r--tests/cases/1002.dat25
-rw-r--r--tests/cases/1030.dat24
-rw-r--r--tests/cases/1032.dat834
-rwxr-xr-xtests/confirm.py58
-rw-r--r--tests/parser.h65
-rwxr-xr-xtests/regress95
-rwxr-xr-xtests/regtest27
-rwxr-xr-xtests/runtests.py184
-rw-r--r--tests/textual.h34
58 files changed, 3591 insertions, 1638 deletions
diff --git a/test/UnitTests.cc b/test/UnitTests.cc
new file mode 100644
index 00000000..7f5d1333
--- /dev/null
+++ b/test/UnitTests.cc
@@ -0,0 +1,115 @@
+#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 <stdexcept>
+#include <fstream>
+
+#include "UnitTests.h"
+
+
+// Create the CppUnit registry
+
+CPPUNIT_REGISTRY_ADD_TO_DEFAULT("Framework");
+
+CPPUNIT_REGISTRY_ADD_TO_DEFAULT("numerics");
+
+// 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 &copy );
+ void operator =( const UnitTests &copy );
+};
+
+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") {
+ ledger::verify_enabled = true;
+ 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_VERIFY()
+ initialize_memory_tracing();
+
+ runner.run(controller, testPath);
+
+ IF_VERIFY()
+ shutdown_memory_tracing();
+
+ // Print test in a compiler compatible format.
+ CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
+ outputter.write();
+
+#if 0
+ // 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() << "\n"
+ << "ERROR: " << e.what()
+ << "\n";
+ return 0;
+ }
+
+ return result.wasSuccessful() ? 0 : 1;
+}
diff --git a/test/UnitTests.h b/test/UnitTests.h
new file mode 100644
index 00000000..e7027cf4
--- /dev/null
+++ b/test/UnitTests.h
@@ -0,0 +1,24 @@
+#ifndef _UNITTESTS_H
+#define _UNITTESTS_H
+
+#include "ledger.h"
+
+using namespace ledger;
+
+#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/__init__.py b/test/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/__init__.py
diff --git a/test/numerics/t_amount.cc b/test/numerics/t_amount.cc
new file mode 100644
index 00000000..37e7ebae
--- /dev/null
+++ b/test/numerics/t_amount.cc
@@ -0,0 +1,1558 @@
+#include "t_amount.h"
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(AmountTestCase, "numerics");
+
+void AmountTestCase::setUp()
+{
+ ledger::set_session_context(&session);
+
+ // 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
+}
+
+void AmountTestCase::tearDown()
+{
+ amount_t::stream_fullstrings = false;
+
+ ledger::set_session_context();
+}
+
+void AmountTestCase::testParser()
+{
+ amount_t x0;
+ amount_t x1;
+ amount_t x2;
+ amount_t x3;
+ amount_t x4(123.456);
+ amount_t x5(x4);
+ amount_t x6(x4);
+ amount_t x7(x4);
+ amount_t x8("$123.45");
+ amount_t x9(x8);
+ amount_t x10(x8);
+ amount_t x11(x8);
+ amount_t x12("$100");
+
+ assertEqual(amount_t::precision_t(2), x12.commodity().precision());
+
+ string buf("$100...");
+ std::istringstream input(buf);
+ amount_t x13;
+ x13.parse(input);
+ assertEqual(x12, x13);
+
+ amount_t x14;
+ assertThrow(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());
+ x16.parse("$2000,00");
+ assertEqual(string("$2.000,00"), x16.to_string());
+
+ // Since European-ness is an additive quality, we must switch back
+ // to American-ness manually
+ x15.commodity().drop_flags(COMMODITY_STYLE_EUROPEAN);
+
+ 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());
+ x18.parse("$2,000");
+ assertEqual(string("$2,000.00"), x18.to_string());
+
+ assertEqual(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());
+
+ x1.parse("$100.0000", AMOUNT_PARSE_NO_MIGRATE);
+ assertEqual(amount_t::precision_t(2), x12.commodity().precision());
+ assertEqual(x1.commodity(), x12.commodity());
+ assertEqual(x1, x12);
+
+ x0.parse("$100.0000");
+ assertEqual(amount_t::precision_t(4), x12.commodity().precision());
+ assertEqual(x0.commodity(), x12.commodity());
+ assertEqual(x0, x12);
+
+ x2.parse("$100.00", AMOUNT_PARSE_NO_REDUCE);
+ assertEqual(x2, x12);
+ x3.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_PARSE_NO_REDUCE);
+ assertEqual(x3, x12);
+
+ x4.parse("$100.00");
+ assertEqual(x4, x12);
+ x5.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE);
+ assertEqual(x5, x12);
+ x6.parse("$100.00", AMOUNT_PARSE_NO_REDUCE);
+ assertEqual(x6, x12);
+ x7.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_PARSE_NO_REDUCE);
+ assertEqual(x7, x12);
+
+ x8.parse("$100.00");
+ assertEqual(x8, x12);
+ x9.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE);
+ assertEqual(x9, x12);
+ x10.parse("$100.00", AMOUNT_PARSE_NO_REDUCE);
+ assertEqual(x10, x12);
+ x11.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_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);
+}
+
+void AmountTestCase::testConstructors()
+{
+ amount_t x0;
+ amount_t x1(123456L);
+ amount_t x2(123456UL);
+ amount_t x3(123.456);
+ amount_t x5("123456");
+ amount_t x6("123.456");
+ amount_t x7(string("123456"));
+ amount_t x8(string("123.456"));
+ amount_t x9(x3);
+ amount_t x10(x6);
+ amount_t x11(x8);
+
+ assertThrow(amount_t(0L) == x0, amount_error);
+ assertThrow(amount_t() == x0, amount_error);
+ assertThrow(amount_t("0") == x0, amount_error);
+ assertThrow(amount_t("0.0") == x0, amount_error);
+ 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);
+}
+
+void AmountTestCase::testCommodityConstructors()
+{
+ amount_t x1("$123.45");
+ amount_t x2("-$123.45");
+ amount_t x3("$-123.45");
+ amount_t x4("DM 123.45");
+ amount_t x5("-DM 123.45");
+ amount_t x6("DM -123.45");
+ amount_t x7("123.45 euro");
+ amount_t x8("-123.45 euro");
+ 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);
+}
+
+void AmountTestCase::testAssignment()
+{
+ amount_t x0;
+ amount_t x1;
+ amount_t x2;
+ amount_t x3;
+ amount_t x5;
+ amount_t x6;
+ amount_t x7;
+ amount_t x8;
+ amount_t x9;
+ amount_t x10;
+
+ x1 = 123456L;
+ x2 = 123456UL;
+ x3 = 123.456;
+ x5 = "123456";
+ x6 = "123.456";
+ x7 = string("123456");
+ x8 = string("123.456");
+ 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);
+
+ assertFalse(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);
+}
+
+void AmountTestCase::testCommodityAssignment()
+{
+ amount_t x1;
+ amount_t x2;
+ amount_t x3;
+ amount_t x4;
+ amount_t x5;
+ amount_t x6;
+ amount_t x7;
+ amount_t x8;
+ amount_t x9;
+ amount_t x10;
+
+ x1 = "$123.45";
+ x2 = "-$123.45";
+ x3 = "$-123.45";
+ x4 = "DM 123.45";
+ x5 = "-DM 123.45";
+ x6 = "DM -123.45";
+ x7 = "123.45 euro";
+ x8 = "-123.45 euro";
+ 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);
+}
+
+void AmountTestCase::testEquality()
+{
+ amount_t x1(123456L);
+ amount_t x2(456789L);
+ amount_t x3(333333L);
+ amount_t x4(123456.0);
+ amount_t x5("123456.0");
+ amount_t x6(123456.0F);
+
+ 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 == 123456.0);
+ assertTrue(123456.0 == x1);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+}
+
+void AmountTestCase::testCommodityEquality()
+{
+ amount_t x0;
+ amount_t x1;
+ amount_t x2;
+ amount_t x3;
+ amount_t x4;
+ amount_t x5;
+ amount_t x6;
+ amount_t x7;
+ amount_t x8;
+ amount_t x9;
+ amount_t x10;
+
+ x1 = "$123.45";
+ x2 = "-$123.45";
+ x3 = "$-123.45";
+ x4 = "DM 123.45";
+ x5 = "-DM 123.45";
+ x6 = "DM -123.45";
+ x7 = "123.45 euro";
+ x8 = "-123.45 euro";
+ x9 = "123.45€";
+ x10 = "-123.45€";
+
+ assertTrue(x0.is_null());
+ assertThrow(x0.is_zero(), amount_error);
+ assertThrow(x0.is_realzero(), amount_error);
+ assertThrow(assert(x0.sign() == 0), amount_error);
+ assertThrow(assert(x0.compare(x1) < 0), amount_error);
+ assertThrow(assert(x0.compare(x2) > 0), amount_error);
+ assertThrow(assert(x0.compare(x0) == 0), 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);
+}
+
+void AmountTestCase::testComparisons()
+{
+ amount_t x0;
+ amount_t x1(-123L);
+ amount_t x2(123L);
+ amount_t x3(-123.45);
+ amount_t x4(123.45);
+ 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);
+ assertTrue(x1 < 100.0);
+ assertTrue(100.0 > x1);
+
+ assertValid(x0);
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+}
+
+void AmountTestCase::testCommodityComparisons()
+{
+ amount_t x1("$-123");
+ amount_t x2("$123.00");
+ amount_t x3(internalAmount("$-123.4544"));
+ amount_t x4(internalAmount("$123.4544"));
+ amount_t x5("$-123.45");
+ 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);
+}
+
+void AmountTestCase::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);
+
+ x1 += amount_t(456L);
+ assertEqual(amount_t(579L), x1);
+ x1 += 456L;
+ assertEqual(amount_t(1035L), x1);
+
+ amount_t x4("123456789123456789123456789");
+
+ assertEqual(amount_t("246913578246913578246913578"), x4 + x4);
+
+ assertValid(x0);
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x4);
+}
+
+void AmountTestCase::testFractionalAddition()
+{
+ amount_t x1(123.123);
+ amount_t y1(456.456);
+
+ assertEqual(amount_t(579.579), x1 + y1);
+ assertEqual(amount_t(579.579), x1 + 456.456);
+ assertEqual(amount_t(579.579), 456.456 + x1);
+
+ x1 += amount_t(456.456);
+ assertEqual(amount_t(579.579), x1);
+ x1 += 456.456;
+ assertEqual(amount_t(1036.035), x1);
+ x1 += 456L;
+ assertEqual(amount_t(1492.035), x1);
+
+ amount_t x2("123456789123456789.123456789123456789");
+
+ assertEqual(amount_t("246913578246913578.246913578246913578"), x2 + x2);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x2);
+}
+
+void AmountTestCase::testCommodityAddition()
+{
+ amount_t x0;
+ amount_t x1("$123.45");
+ amount_t x2(internalAmount("$123.456789"));
+ amount_t x3("DM 123.45");
+ amount_t x4("123.45 euro");
+ 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);
+
+ // 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);
+ assertThrow(x1 + x6, amount_error);
+ assertThrow(x1 + 123.45, amount_error);
+ assertThrow(x1 + 123L, amount_error);
+
+ assertEqual(amount_t("DM 246.90"), x3 + x3);
+ assertEqual(amount_t("246.90 euro"), x4 + x4);
+ assertEqual(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());
+
+ x1 += amount_t("$456.45");
+ assertEqual(amount_t("$579.90"), x1);
+ x1 += amount_t("$456.45");
+ assertEqual(amount_t("$1036.35"), x1);
+ x1 += amount_t("$456");
+ assertEqual(amount_t("$1492.35"), x1);
+
+ amount_t x7(internalAmount("$123456789123456789.123456789123456789"));
+
+ assertEqual(internalAmount("$246913578246913578.246913578246913578"), x7 + x7);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+ assertValid(x7);
+}
+
+void AmountTestCase::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);
+
+ x1 -= amount_t(456L);
+ assertEqual(amount_t(-333L), x1);
+ x1 -= 456L;
+ assertEqual(amount_t(-789L), x1);
+
+ amount_t x4("123456789123456789123456789");
+ amount_t y4("8238725986235986");
+
+ assertEqual(amount_t("123456789115218063137220803"), x4 - y4);
+ assertEqual(amount_t("-123456789115218063137220803"), y4 - x4);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x4);
+ assertValid(y4);
+}
+
+void AmountTestCase::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);
+
+ x1 -= amount_t(456.456);
+ assertEqual(amount_t(-333.333), x1);
+ x1 -= 456.456;
+ assertEqual(amount_t(-789.789), x1);
+ x1 -= 456L;
+ assertEqual(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);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x2);
+ assertValid(y2);
+}
+
+void AmountTestCase::testCommoditySubtraction()
+{
+ amount_t x0;
+ amount_t x1("$123.45");
+ amount_t x2(internalAmount("$123.456789"));
+ amount_t x3("DM 123.45");
+ amount_t x4("123.45 euro");
+ 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);
+
+ // 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);
+ assertThrow(x1 - x6, amount_error);
+ assertThrow(x1 - 123.45, amount_error);
+ assertThrow(x1 - 123L, amount_error);
+
+ 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());
+
+ x1 -= amount_t("$456.45");
+ assertEqual(amount_t("$-333.00"), x1);
+ x1 -= amount_t("$456.45");
+ assertEqual(amount_t("$-789.45"), x1);
+ x1 -= amount_t("$456");
+ assertEqual(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"),
+ (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"),
+ (amount_t("$1.00") * (x8 - x7)).to_string());
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+ assertValid(x7);
+ assertValid(x8);
+}
+
+void AmountTestCase::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);
+
+ x1 *= amount_t(123L);
+ assertEqual(amount_t(15129L), x1);
+ x1 *= 123L;
+ assertEqual(amount_t(1860867L), x1);
+
+ amount_t x4("123456789123456789123456789");
+
+ assertEqual(amount_t("15241578780673678546105778281054720515622620750190521"),
+ x4 * x4);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x4);
+}
+
+void AmountTestCase::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 * 456.456);
+ assertEqual(amount_t("56200.232088"), amount_t(456.456) * x1);
+ assertEqual(amount_t("56200.232088"), 456.456 * x1);
+
+ x1 *= amount_t(123.123);
+ assertEqual(amount_t("15159.273129"), x1);
+ x1 *= 123.123;
+ assertEqual(amount_t("1866455.185461867"), x1);
+ x1 *= 123L;
+ assertEqual(amount_t("229573987.811809641"), x1);
+
+ amount_t x2("123456789123456789.123456789123456789");
+
+ assertEqual(amount_t("15241578780673678546105778311537878.046486820281054720515622620750190521"),
+ x2 * x2);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x2);
+}
+
+void AmountTestCase::testCommodityMultiplication()
+{
+ amount_t x0;
+ amount_t x1("$123.12");
+ amount_t y1("$456.45");
+ amount_t x2(internalAmount("$123.456789"));
+ amount_t x3("DM 123.45");
+ 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());
+
+ // 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);
+
+ x1 *= amount_t("123.12");
+ assertEqual(internalAmount("$15158.5344"), x1);
+ assertEqual(string("$15158.53"), x1.to_string());
+ x1 *= 123.12;
+ assertEqual(internalAmount("$1866318.755328"), x1);
+ assertEqual(string("$1866318.76"), x1.to_string());
+ x1 *= 123L;
+ assertEqual(internalAmount("$229557206.905344"), x1);
+ assertEqual(string("$229557206.91"), x1.to_string());
+
+ amount_t x7(internalAmount("$123456789123456789.123456789123456789"));
+
+ assertEqual(internalAmount("$15241578780673678546105778311537878.046486820281054720515622620750190521"),
+ x7 * x7);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x7);
+}
+
+void AmountTestCase::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(amount_t("0.008130"), amount_t(1L) / x1);
+ assertEqual(amount_t("0.008130"), 1L / x1);
+ assertEqual(- x1, x1 / -1L);
+ assertEqual(- amount_t("0.008130"), amount_t(-1L) / x1);
+ assertEqual(- amount_t("0.008130"), -1L / x1);
+ assertEqual(amount_t("0.269737"), x1 / y1);
+ assertEqual(amount_t("3.707317"), y1 / x1);
+ assertEqual(amount_t("0.269737"), x1 / 456L);
+ assertEqual(amount_t("3.707317"), amount_t(456L) / x1);
+ assertEqual(amount_t("3.707317"), 456L / x1);
+
+ x1 /= amount_t(456L);
+ assertEqual(amount_t("0.269737"), x1);
+ x1 /= 456L;
+ assertEqual(amount_t("0.00059152850877193"), x1);
+
+ amount_t x4("123456789123456789123456789");
+ amount_t y4("56");
+
+ assertEqual(amount_t(1L), x4 / x4);
+ assertEqual(amount_t("2204585520061728377204585.517857"), x4 / y4);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x4);
+ assertValid(y4);
+}
+
+void AmountTestCase::testFractionalDivision()
+{
+ amount_t x1(123.123);
+ amount_t y1(456.456);
+
+ assertThrow(x1 / 0L, amount_error);
+ assertEqual(amount_t("0.008121959"), amount_t(1.0) / x1);
+ assertEqual(amount_t("0.008121959"), 1.0 / x1);
+ assertEqual(x1, x1 / 1.0);
+ assertEqual(amount_t("0.008121959"), amount_t(1.0) / x1);
+ assertEqual(amount_t("0.008121959"), 1.0 / x1);
+ assertEqual(- x1, x1 / -1.0);
+ assertEqual(- amount_t("0.008121959"), amount_t(-1.0) / x1);
+ assertEqual(- amount_t("0.008121959"), -1.0 / x1);
+ assertEqual(amount_t("0.269736842105263"), x1 / y1);
+ assertEqual(amount_t("3.707317073170732"), y1 / x1);
+ assertEqual(amount_t("0.269736842105263"), x1 / 456.456);
+ assertEqual(amount_t("3.707317073170732"), amount_t(456.456) / x1);
+ assertEqual(amount_t("3.707317073170732"), 456.456 / x1);
+
+ x1 /= amount_t(456.456);
+ assertEqual(amount_t("0.269736842105263"), x1);
+ x1 /= 456.456;
+ assertEqual(amount_t("0.000590937225286255411255411255411255411"), x1);
+ x1 /= 456L;
+ assertEqual(amount_t("0.000001295914967733016252753094858358016252192982456140350877192982456140350877192982"), x1);
+
+ amount_t x4("1234567891234567.89123456789");
+ amount_t y4("56.789");
+
+ assertEqual(amount_t(1.0), x4 / x4);
+ assertEqual(amount_t("21739560323910.7554497273748437197344556164046"), x4 / y4);
+
+ assertValid(x1);
+ assertValid(y1);
+ assertValid(x4);
+ assertValid(y4);
+}
+
+void AmountTestCase::testCommodityDivision()
+{
+ amount_t x0;
+ amount_t x1("$123.12");
+ amount_t y1("$456.45");
+ amount_t x2(internalAmount("$123.456789"));
+ amount_t x3("DM 123.45");
+ 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(internalAmount("$0.00812216"), 1L / x1);
+ assertEqual(- x1, x1 / -1L);
+ assertEqual(internalAmount("$-0.00812216"), -1L / x1);
+ assertEqual(internalAmount("$0.26973382"), x1 / y1);
+ assertEqual(string("$0.27"), (x1 / y1).to_string());
+ assertEqual(internalAmount("$3.70735867"), y1 / x1);
+ assertEqual(string("$3.71"), (y1 / x1).to_string());
+
+ // Internal amounts retain their precision, even when being
+ // converted to strings
+ assertEqual(internalAmount("$0.99727201"), x1 / x2);
+ assertEqual(internalAmount("$1.00273545321637426901"), x2 / x1);
+ assertEqual(string("$1.00"), (x1 / x2).to_string());
+ assertEqual(string("$1.00273545321637426901"), (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);
+
+ x1 /= amount_t("123.12");
+ assertEqual(internalAmount("$1.00"), x1);
+ assertEqual(string("$1.00"), x1.to_string());
+ x1 /= 123.12;
+ assertEqual(internalAmount("$0.00812216"), x1);
+ assertEqual(string("$0.01"), x1.to_string());
+ x1 /= 123L;
+ assertEqual(internalAmount("$0.00006603"), x1);
+ assertEqual(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(internalAmount("$0.0019216115121765559608381226612019501046413574469262"),
+ x6 / x7);
+ assertEqual(internalAmount("$520.39654928343335571379527154924040947271699678158689736256"),
+ x7 / x6);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+ assertValid(x7);
+}
+
+void AmountTestCase::testNegation()
+{
+ amount_t x0;
+ amount_t x1(-123456L);
+ amount_t x3(-123.456);
+ amount_t x5("-123456");
+ amount_t x6("-123.456");
+ amount_t x7(string("-123456"));
+ amount_t x8(string("-123.456"));
+ amount_t x9(- x3);
+
+ assertThrow(x0.negate(), amount_error);
+ assertEqual(x5, x1);
+ assertEqual(x7, x1);
+ assertEqual(x6, x3);
+ assertEqual(x8, x3);
+ assertEqual(- x6, x9);
+ assertEqual(x3.negate(), x9);
+
+ amount_t x10(x9.negate());
+
+ assertEqual(x3, x10);
+
+ assertValid(x1);
+ assertValid(x3);
+ assertValid(x5);
+ assertValid(x6);
+ assertValid(x7);
+ assertValid(x8);
+ assertValid(x9);
+ assertValid(x10);
+}
+
+void AmountTestCase::testCommodityNegation()
+{
+ amount_t x1("$123.45");
+ amount_t x2("-$123.45");
+ amount_t x3("$-123.45");
+ amount_t x4("DM 123.45");
+ amount_t x5("-DM 123.45");
+ amount_t x6("DM -123.45");
+ amount_t x7("123.45 euro");
+ amount_t x8("-123.45 euro");
+ 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.negate());
+ assertEqual(amount_t("$123.45"), x2.negate());
+ assertEqual(amount_t("$123.45"), x3.negate());
+
+ 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.negate());
+ assertEqual(amount_t("$123.45"), x2.negate());
+ assertEqual(amount_t("$123.45"), x3.negate());
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+ assertValid(x6);
+ assertValid(x7);
+ assertValid(x8);
+ assertValid(x9);
+ assertValid(x10);
+}
+
+void AmountTestCase::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());
+
+ assertValid(x0);
+ assertValid(x1);
+ assertValid(x2);
+}
+
+void AmountTestCase::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());
+
+ assertValid(x1);
+ assertValid(x2);
+}
+
+void AmountTestCase::testFractionalRound()
+{
+ amount_t x0;
+ amount_t x1("1234.567890");
+
+ assertThrow(x0.precision(), amount_error);
+ assertThrow(x0.round(), amount_error);
+ assertThrow(x0.round(2), amount_error);
+ assertThrow(x0.unround(), amount_error);
+ assertEqual(amount_t::precision_t(6), x1.precision());
+
+ amount_t x1b(x1.unround());
+
+ assertEqual(x1b.precision(), x1b.unround().precision());
+
+ amount_t y7(x1.round(7));
+ amount_t y6(x1.round(6));
+ amount_t y5(x1.round(5));
+ amount_t y4(x1.round(4));
+ amount_t y3(x1.round(3));
+ amount_t y2(x1.round(2));
+ amount_t y1(x1.round(1));
+ amount_t y0(x1.round(0));
+
+ assertEqual(amount_t::precision_t(6), y7.precision());
+ assertEqual(amount_t::precision_t(6), y6.precision());
+ assertEqual(amount_t::precision_t(5), y5.precision());
+ assertEqual(amount_t::precision_t(4), y4.precision());
+ assertEqual(amount_t::precision_t(3), y3.precision());
+ assertEqual(amount_t::precision_t(2), y2.precision());
+ assertEqual(amount_t::precision_t(1), y1.precision());
+ assertEqual(amount_t::precision_t(0), y0.precision());
+
+ assertEqual(amount_t("1234.56789"), y7);
+ assertEqual(amount_t("1234.56789"), y6);
+ assertEqual(amount_t("1234.56789"), y5);
+ assertEqual(amount_t("1234.5679"), y4);
+ assertEqual(amount_t("1234.568"), y3);
+ assertEqual(amount_t("1234.57"), y2);
+ assertEqual(amount_t("1234.6"), y1);
+ assertEqual(amount_t("1235"), y0);
+
+ amount_t x2("9876.543210");
+
+ assertEqual(amount_t("9876.543210"), x2.round(6));
+ assertEqual(amount_t("9876.54321"), x2.round(5));
+ assertEqual(amount_t("9876.5432"), x2.round(4));
+ assertEqual(amount_t("9876.543"), x2.round(3));
+ assertEqual(amount_t("9876.54"), x2.round(2));
+ assertEqual(amount_t("9876.5"), x2.round(1));
+ assertEqual(amount_t("9877"), x2.round(0));
+
+ amount_t x3("-1234.567890");
+
+ assertEqual(amount_t("-1234.56789"), x3.round(6));
+ assertEqual(amount_t("-1234.56789"), x3.round(5));
+ assertEqual(amount_t("-1234.5679"), x3.round(4));
+ assertEqual(amount_t("-1234.568"), x3.round(3));
+ assertEqual(amount_t("-1234.57"), x3.round(2));
+ assertEqual(amount_t("-1234.6"), x3.round(1));
+ assertEqual(amount_t("-1235"), x3.round(0));
+
+ amount_t x4("-9876.543210");
+
+ assertEqual(amount_t("-9876.543210"), x4.round(6));
+ assertEqual(amount_t("-9876.54321"), x4.round(5));
+ assertEqual(amount_t("-9876.5432"), x4.round(4));
+ assertEqual(amount_t("-9876.543"), x4.round(3));
+ assertEqual(amount_t("-9876.54"), x4.round(2));
+ assertEqual(amount_t("-9876.5"), x4.round(1));
+ assertEqual(amount_t("-9877"), x4.round(0));
+
+ amount_t x5("0.0000000000000000000000000000000000001");
+
+ assertEqual(amount_t("0.0000000000000000000000000000000000001"),
+ x5.round(37));
+ assertEqual(amount_t(0L), x5.round(36));
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+}
+
+void AmountTestCase::testCommodityRound()
+{
+ amount_t x1(internalAmount("$1234.567890"));
+
+ assertEqual(internalAmount("$1234.56789"), x1.round(6));
+ assertEqual(internalAmount("$1234.56789"), x1.round(5));
+ assertEqual(internalAmount("$1234.5679"), x1.round(4));
+ assertEqual(internalAmount("$1234.568"), x1.round(3));
+ assertEqual(amount_t("$1234.57"), x1.round(2));
+ assertEqual(amount_t("$1234.6"), x1.round(1));
+ assertEqual(amount_t("$1235"), x1.round(0));
+
+ amount_t x2(internalAmount("$9876.543210"));
+
+ assertEqual(internalAmount("$9876.543210"), x2.round(6));
+ assertEqual(internalAmount("$9876.54321"), x2.round(5));
+ assertEqual(internalAmount("$9876.5432"), x2.round(4));
+ assertEqual(internalAmount("$9876.543"), x2.round(3));
+ assertEqual(amount_t("$9876.54"), x2.round(2));
+ assertEqual(amount_t("$9876.5"), x2.round(1));
+ assertEqual(amount_t("$9877"), x2.round(0));
+
+ amount_t x3(internalAmount("$-1234.567890"));
+
+ assertEqual(internalAmount("$-1234.56789"), x3.round(6));
+ assertEqual(internalAmount("$-1234.56789"), x3.round(5));
+ assertEqual(internalAmount("$-1234.5679"), x3.round(4));
+ assertEqual(internalAmount("$-1234.568"), x3.round(3));
+ assertEqual(amount_t("$-1234.57"), x3.round(2));
+ assertEqual(amount_t("$-1234.6"), x3.round(1));
+ assertEqual(amount_t("$-1235"), x3.round(0));
+
+ amount_t x4(internalAmount("$-9876.543210"));
+
+ assertEqual(internalAmount("$-9876.543210"), x4.round(6));
+ assertEqual(internalAmount("$-9876.54321"), x4.round(5));
+ assertEqual(internalAmount("$-9876.5432"), x4.round(4));
+ assertEqual(internalAmount("$-9876.543"), x4.round(3));
+ assertEqual(amount_t("$-9876.54"), x4.round(2));
+ assertEqual(amount_t("$-9876.5"), x4.round(1));
+ assertEqual(amount_t("$-9877"), x4.round(0));
+
+ amount_t x5("$123.45");
+
+ x5 *= 100.12;
+
+ assertEqual(internalAmount("$12359.814"), x5);
+ assertEqual(string("$12359.81"), x5.to_string());
+ assertEqual(string("$12359.814"), x5.to_fullstring());
+ assertEqual(string("$12359.814"), x5.unround().to_string());
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x5);
+}
+
+void AmountTestCase::testCommodityDisplayRound()
+{
+ amount_t x1("$0.85");
+ amount_t x2("$0.1");
+
+ x1 *= 0.19;
+
+ assertNotEqual(amount_t("$0.16"), x1);
+ assertEqual(internalAmount("$0.1615"), x1);
+ assertEqual(string("$0.16"), x1.to_string());
+
+ assertEqual(amount_t("$0.10"), x2);
+ assertNotEqual(internalAmount("$0.101"), x2);
+ assertEqual(string("$0.10"), x2.to_string());
+
+ x1 *= 7L;
+
+ assertNotEqual(amount_t("$1.13"), x1);
+ assertEqual(internalAmount("$1.1305"), x1);
+ assertEqual(string("$1.13"), x1.to_string());
+}
+
+void AmountTestCase::testReduction()
+{
+ amount_t x0;
+ amount_t x1("60s");
+ amount_t x2("600s");
+ amount_t x3("6000s");
+ amount_t x4("360000s");
+ amount_t x5("10m"); // 600s
+ amount_t x6("100m"); // 6000s
+ amount_t x7("1000m"); // 60000s
+ amount_t x8("10000m"); // 600000s
+ amount_t x9("10h"); // 36000s
+ amount_t x10("100h"); // 360000s
+ amount_t x11("1000h"); // 3600000s
+ amount_t x12("10000h"); // 36000000s
+
+ assertThrow(x0.reduce(), amount_error);
+ assertThrow(x0.unreduce(), amount_error);
+ assertEqual(x2, x5);
+ assertEqual(x3, x6);
+ assertEqual(x4, x10);
+ assertEqual(string("100.0h"), x4.unreduce().to_string());
+}
+
+void AmountTestCase::testSign()
+{
+ amount_t x0;
+ amount_t x1("0.0000000000000000000000000000000000001");
+ amount_t x2("-0.0000000000000000000000000000000000001");
+ 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);
+}
+
+void AmountTestCase::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);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+}
+
+void AmountTestCase::testTruth()
+{
+ amount_t x0;
+ amount_t x1("1234");
+ amount_t x2("1234.56");
+
+ assertThrow(assert(x0 ? 1 : 0), amount_error);
+
+ assertTrue(x1);
+ assertTrue(x2);
+
+ assertValid(x0);
+ assertValid(x1);
+ assertValid(x2);
+}
+
+void AmountTestCase::testCommodityTruth()
+{
+ amount_t x1("$1234");
+ amount_t x2("$1234.56");
+
+ if (x1)
+ assertTrue(true);
+ else
+ assertTrue(false);
+
+ if (x2)
+ assertTrue(true);
+ else
+ assertTrue(false);
+
+ assertValid(x1);
+ assertValid(x2);
+}
+
+void AmountTestCase::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());
+
+ assertValid(x0);
+ assertValid(x1);
+}
+
+void AmountTestCase::testCommodityForZero()
+{
+ amount_t x1(internalAmount("$0.000000000000000000001"));
+
+ assertFalse(x1);
+ assertTrue(x1.is_zero());
+ assertFalse(x1.is_realzero());
+
+ assertValid(x1);
+}
+
+void AmountTestCase::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());
+
+ assertValid(x1);
+}
+
+void AmountTestCase::testFractionalConversion()
+{
+ amount_t x1(1234.56);
+ amount_t x2("1234.5683787634678348734");
+
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertThrow(x2.to_double(), amount_error); // loses precision
+ assertFalse(x2.fits_in_double());
+ assertEqual(1234L, x1.to_long(true));
+ assertEqual(1234.56, x1.to_double());
+ assertEqual(string("1234.56"), x1.to_string());
+ assertEqual(string("1234.56"), x1.quantity_string());
+
+ assertValid(x1);
+}
+
+void AmountTestCase::testCommodityConversion()
+{
+ amount_t x1("$1234.56");
+
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertEqual(1234L, x1.to_long(true));
+ assertEqual(1234.56, x1.to_double());
+ assertEqual(string("$1234.56"), x1.to_string());
+ assertEqual(string("1234.56"), x1.quantity_string());
+
+ assertValid(x1);
+}
+
+void AmountTestCase::testPrinting()
+{
+ amount_t x0;
+ amount_t x1("982340823.380238098235098235098235098");
+
+ {
+ std::ostringstream bufstr;
+ assertThrow(bufstr << x0, amount_error);
+ }
+
+ {
+ std::ostringstream bufstr;
+ bufstr << x1;
+
+ assertEqual(std::string("982340823.380238098235098235098235098"),
+ bufstr.str());
+ }
+
+ assertValid(x0);
+ assertValid(x1);
+}
+
+void AmountTestCase::testCommodityPrinting()
+{
+ amount_t x1(internalAmount("$982340823.386238098235098235098235098"));
+ amount_t x2("$982340823.38");
+
+ {
+ std::ostringstream bufstr;
+ bufstr << x1;
+
+ assertEqual(std::string("$982340823.386238098235098235098235098"),
+ bufstr.str());
+ }
+
+ {
+ std::ostringstream bufstr;
+ bufstr << (x1 * x2).to_string();
+
+ assertEqual(std::string("$964993493285024293.18099172508158508135413499124"),
+ bufstr.str());
+ }
+
+ {
+ std::ostringstream bufstr;
+ bufstr << (x2 * x1).to_string();
+
+ assertEqual(std::string("$964993493285024293.18"), bufstr.str());
+ }
+
+ assertValid(x1);
+ assertValid(x2);
+}
+
+void AmountTestCase::testSerialization()
+{
+ amount_t x0;
+ amount_t x1("$8,192.34");
+ amount_t x2("8192.34");
+ amount_t x3("8192.34");
+ amount_t x4("-8192.34");
+ amount_t x5(x4);
+
+ // Force x3's pointer to actually be set to null_commodity
+ x3.set_commodity(*x3.current_pool->null_commodity);
+
+ std::string buf;
+ {
+ std::ostringstream storage;
+ assertThrow(x0.write(storage), amount_error);
+ x1.write(storage);
+ x2.write(storage);
+ x3.write(storage);
+ x4.write(storage);
+ x5.write(storage);
+ buf = storage.str();
+ }
+
+ amount_t x1b;
+ amount_t x2b;
+ amount_t x3b;
+ amount_t x4b;
+ amount_t x5b;
+ {
+ std::istringstream storage(buf);
+ x1b.read(storage);
+ x2b.read(storage);
+ x3b.read(storage);
+ x4b.read(storage);
+ x5b.read(storage);
+ }
+
+ assertEqual(x1, x1b);
+ assertEqual(x2, x2b);
+ assertEqual(x3, x3b);
+ assertEqual(x4, x4b);
+
+ const char * ptr = buf.c_str();
+
+ amount_t x1c;
+ amount_t x2c;
+ amount_t x3c;
+ amount_t x4c;
+ amount_t x5c;
+ {
+ x1c.read(ptr);
+ x2c.read(ptr);
+ x3c.read(ptr);
+ x4c.read(ptr);
+ x5c.read(ptr);
+ }
+
+ assertEqual(x1, x1b);
+ assertEqual(x2, x2b);
+ assertEqual(x3, x3b);
+ assertEqual(x4, x4b);
+
+ assertValid(x1);
+ assertValid(x2);
+ assertValid(x3);
+ assertValid(x4);
+ assertValid(x1b);
+ assertValid(x2b);
+ assertValid(x3b);
+ assertValid(x4b);
+ assertValid(x1c);
+ assertValid(x2c);
+ assertValid(x3c);
+ assertValid(x4c);
+}
diff --git a/test/numerics/t_amount.h b/test/numerics/t_amount.h
new file mode 100644
index 00000000..2d5a327a
--- /dev/null
+++ b/test/numerics/t_amount.h
@@ -0,0 +1,110 @@
+#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);
+ CPPUNIT_TEST(testFractionalRound);
+ CPPUNIT_TEST(testCommodityRound);
+ CPPUNIT_TEST(testCommodityDisplayRound);
+ CPPUNIT_TEST(testReduction);
+ 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(testSerialization);
+
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ ledger::session_t session;
+
+ 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();
+ void testSerialization();
+
+private:
+ AmountTestCase(const AmountTestCase &copy);
+ void operator=(const AmountTestCase &copy);
+};
+
+#endif // _T_AMOUNT_H
diff --git a/test/numerics/t_balance.cc b/test/numerics/t_balance.cc
new file mode 100644
index 00000000..ca759836
--- /dev/null
+++ b/test/numerics/t_balance.cc
@@ -0,0 +1,25 @@
+#include "t_balance.h"
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BalanceTestCase, "numerics");
+
+void BalanceTestCase::setUp()
+{
+ ledger::set_session_context(&session);
+
+ // 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
+}
+
+void BalanceTestCase::tearDown()
+{
+ amount_t::stream_fullstrings = false;
+
+ ledger::set_session_context();
+}
+
+void BalanceTestCase::testConstructors()
+{
+}
diff --git a/test/numerics/t_balance.h b/test/numerics/t_balance.h
new file mode 100644
index 00000000..7c27f7e8
--- /dev/null
+++ b/test/numerics/t_balance.h
@@ -0,0 +1,30 @@
+#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:
+ ledger::session_t session;
+
+ BalanceTestCase() {}
+ virtual ~BalanceTestCase() {}
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ void testConstructors();
+
+private:
+ BalanceTestCase(const BalanceTestCase &copy);
+ void operator=(const BalanceTestCase &copy);
+};
+
+#endif // _T_BALANCE_H
diff --git a/test/numerics/t_commodity.cc b/test/numerics/t_commodity.cc
new file mode 100644
index 00000000..f9892287
--- /dev/null
+++ b/test/numerics/t_commodity.cc
@@ -0,0 +1,64 @@
+#include "t_commodity.h"
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CommodityTestCase, "numerics");
+
+void CommodityTestCase::setUp() {
+ ledger::set_session_context(&session);
+}
+void CommodityTestCase::tearDown() {
+ ledger::set_session_context();
+}
+
+void CommodityTestCase::testPriceHistory()
+{
+ ptime jan17_07 = parse_datetime("2007/01/17 00:00:00");
+ ptime feb27_07 = parse_datetime("2007/02/27 18:00:00");
+ ptime feb28_07 = parse_datetime("2007/02/28 06:00:00");
+ ptime feb28_07sbm = parse_datetime("2007/02/28 11:59:59");
+ ptime mar01_07 = parse_datetime("2007/03/01 00:00:00");
+ ptime apr15_07 = parse_datetime("2007/04/15 13:00:00");
+
+ // jww (2007-04-17): tbd
+ amount_t x0;
+ amount_t x1("100.10 AAPL");
+
+ assertThrow(x0.value(), amount_error);
+ assertFalse(x1.value());
+
+ // Commodities cannot be constructed by themselves, since a great
+ // deal of their state depends on how they were seen to be used.
+ commodity_t& aapl(x1.commodity());
+
+ aapl.add_price(jan17_07, amount_t("$10.20"));
+ aapl.add_price(feb27_07, amount_t("$13.40"));
+ aapl.add_price(feb28_07, amount_t("$18.33"));
+ aapl.add_price(feb28_07sbm, amount_t("$18.30"));
+ aapl.add_price(mar01_07, amount_t("$19.50"));
+ aapl.add_price(apr15_07, amount_t("$21.22"));
+
+ optional<amount_t> amt1 = x1.value(feb28_07sbm);
+ assertTrue(amt1);
+ assertEqual(amount_t("$1831.83"), *amt1);
+
+ optional<amount_t> amt2 = x1.value(now);
+ assertTrue(amt2);
+ assertEqual(amount_t("$2124.12"), *amt2);
+
+ assertValid(x1);
+}
+
+void CommodityTestCase::testLots()
+{
+ // jww (2007-04-17): tbd
+}
+
+void CommodityTestCase::testScalingBase()
+{
+ // jww (2007-04-17): tbd
+}
+
+void CommodityTestCase::testReduction()
+{
+ // jww (2007-04-17): tbd
+}
+
diff --git a/test/numerics/t_commodity.h b/test/numerics/t_commodity.h
new file mode 100644
index 00000000..ed739751
--- /dev/null
+++ b/test/numerics/t_commodity.h
@@ -0,0 +1,36 @@
+#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(testLots);
+ CPPUNIT_TEST(testScalingBase);
+ CPPUNIT_TEST(testReduction);
+
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ ledger::session_t session;
+
+ CommodityTestCase() {}
+ virtual ~CommodityTestCase() {}
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ void testPriceHistory();
+ void testLots();
+ void testScalingBase();
+ void testReduction();
+
+private:
+ CommodityTestCase(const CommodityTestCase &copy);
+ void operator=(const CommodityTestCase &copy);
+};
+
+#endif // _T_COMMMODITY_H
diff --git a/test/python/PyUnitTests.py b/test/python/PyUnitTests.py
new file mode 100755
index 00000000..3c19093f
--- /dev/null
+++ b/test/python/PyUnitTests.py
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+PYTHONPATH="%builddir%":"%srcdir%":$PYTHONPATH \
+DYLD_LIBRARY_PATH="%builddir%/.libs":"%builddir%/gdtoa/.libs":$DYLD_LIBRARY_PATH \
+ python "%srcdir%"/tests/python/UnitTests.py
diff --git a/test/python/UnitTests.py b/test/python/UnitTests.py
new file mode 100644
index 00000000..843e9fc1
--- /dev/null
+++ b/test/python/UnitTests.py
@@ -0,0 +1,9 @@
+from unittest import TextTestRunner, TestSuite
+
+import tests.python.numerics.t_amount as t_amount
+
+suites = [
+ t_amount.suite(),
+]
+
+TextTestRunner().run(TestSuite(suites))
diff --git a/test/python/__init__.py b/test/python/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/python/__init__.py
diff --git a/test/python/numerics/__init__.py b/test/python/numerics/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/python/numerics/__init__.py
diff --git a/test/python/numerics/t_amount.py b/test/python/numerics/t_amount.py
new file mode 100644
index 00000000..f7eeee8f
--- /dev/null
+++ b/test/python/numerics/t_amount.py
@@ -0,0 +1,1470 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+import exceptions
+import operator
+
+from ledger import *
+from StringIO import *
+
+internalAmount = amount.exact
+
+class t_amountTestCase(unittest.TestCase):
+ testSession = None
+
+ def assertValid(self, amt):
+ self.assertTrue(amt.valid())
+
+ def setUp(self):
+ #self.testSession = session()
+ #set_session_context(self.testSession)
+
+ # Cause the display precision for dollars to be initialized to 2.
+ x1 = amount("$1.00")
+ self.assertTrue(x1)
+
+ #amount.stream_fullstrings = True # make reports from UnitTests accurate
+
+ def tearDown(self):
+ pass
+ #amount.stream_fullstrings = False
+
+ #set_session_context()
+ #self.testSession = None
+
+ def testParser(self):
+ x0 = amount()
+ x1 = amount()
+ x2 = amount()
+ x3 = amount()
+ x4 = amount(123.456)
+ x5 = amount(x4)
+ x6 = amount(x4)
+ x7 = amount(x4)
+ x8 = amount("$123.45")
+ x9 = amount(x8)
+ x10 = amount(x8)
+ x11 = amount(x8)
+ x12 = amount("$100")
+
+ self.assertEqual(2, x12.commodity.precision)
+
+ #buf = "$100..."
+ #input = StringIO(buf)
+ #x13 = amount()
+ #x13.parse(input)
+ #self.assertEqual(x12, x13)
+
+ x14 = amount()
+ self.assertRaises(exceptions.ArithmeticError, lambda: x14.parse("DM"))
+
+ x15 = amount("$1.000.000,00")
+
+ x16 = amount("$2000")
+ self.assertEqual("$2.000,00", x16.to_string())
+ x16.parse("$2000,00")
+ self.assertEqual("$2.000,00", x16.to_string())
+
+ # Since European-ness is an additive quality, we must switch back
+ # to American-ness manually
+ x15.commodity.drop_flags(COMMODITY_STYLE_EUROPEAN)
+
+ x17 = amount("$1,000,000.00")
+
+ x18 = amount("$2000")
+ self.assertEqual("$2,000.00", x18.to_string())
+ x18.parse("$2,000")
+ self.assertEqual("$2,000.00", x18.to_string())
+
+ self.assertEqual(x15, x17)
+
+ x19 = amount("EUR 1000")
+ x20 = amount("EUR 1000")
+
+ self.assertEqual("EUR 1000", x19.to_string())
+ self.assertEqual("EUR 1000", x20.to_string())
+
+ x1.parse("$100.0000", AMOUNT_PARSE_NO_MIGRATE)
+ self.assertEqual(2, x12.commodity.precision)
+ self.assertEqual(x1.commodity, x12.commodity)
+ self.assertEqual(x1, x12)
+
+ x0.parse("$100.0000")
+ self.assertEqual(4, x12.commodity.precision)
+ self.assertEqual(x0.commodity, x12.commodity)
+ self.assertEqual(x0, x12)
+
+ x2.parse("$100.00", AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x2, x12)
+ x3.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x3, x12)
+
+ x4.parse("$100.00")
+ self.assertEqual(x4, x12)
+ x5.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE)
+ self.assertEqual(x5, x12)
+ x6.parse("$100.00", AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x6, x12)
+ x7.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x7, x12)
+
+ x8.parse("$100.00")
+ self.assertEqual(x8, x12)
+ x9.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE)
+ self.assertEqual(x9, x12)
+ x10.parse("$100.00", AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x10, x12)
+ x11.parse("$100.00", AMOUNT_PARSE_NO_MIGRATE | AMOUNT_PARSE_NO_REDUCE)
+ self.assertEqual(x11, x12)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+ self.assertValid(x11)
+ self.assertValid(x12)
+
+ def testConstructors(self):
+ x0 = amount()
+ x1 = amount(123456)
+ x2 = amount(123456L)
+ x3 = amount(123.456)
+ x5 = amount("123456")
+ x6 = amount("123.456")
+ x7 = amount("123456")
+ x8 = amount("123.456")
+ x9 = amount(x3)
+ x10 = amount(x6)
+ x11 = amount(x8)
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: amount(0) == x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: amount() == x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: amount("0") == x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: amount("0.0") == x0)
+ self.assertEqual(x2, x1)
+ self.assertEqual(x5, x1)
+ self.assertEqual(x7, x1)
+ self.assertEqual(x6, x3)
+ self.assertEqual(x8, x3)
+ self.assertEqual(x10, x3)
+ self.assertEqual(x10, x9)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+ self.assertValid(x11)
+
+ def testCommodityConstructors(self):
+ x1 = amount("$123.45")
+ x2 = amount("-$123.45")
+ x3 = amount("$-123.45")
+ x4 = amount("DM 123.45")
+ x5 = amount("-DM 123.45")
+ x6 = amount("DM -123.45")
+ x7 = amount("123.45 euro")
+ x8 = amount("-123.45 euro")
+ x9 = amount("123.45€")
+ x10 = amount("-123.45€")
+
+ self.assertEqual(amount("$123.45"), x1)
+ self.assertEqual(amount("-$123.45"), x2)
+ self.assertEqual(amount("$-123.45"), x3)
+ self.assertEqual(amount("DM 123.45"), x4)
+ self.assertEqual(amount("-DM 123.45"), x5)
+ self.assertEqual(amount("DM -123.45"), x6)
+ self.assertEqual(amount("123.45 euro"), x7)
+ self.assertEqual(amount("-123.45 euro"), x8)
+ self.assertEqual(amount("123.45€"), x9)
+ self.assertEqual(amount("-123.45€"), x10)
+
+ self.assertEqual("$123.45", x1.to_string())
+ self.assertEqual("$-123.45", x2.to_string())
+ self.assertEqual("$-123.45", x3.to_string())
+ self.assertEqual("DM 123.45", x4.to_string())
+ self.assertEqual("DM -123.45", x5.to_string())
+ self.assertEqual("DM -123.45", x6.to_string())
+ self.assertEqual("123.45 euro", x7.to_string())
+ self.assertEqual("-123.45 euro", x8.to_string())
+ self.assertEqual("123.45€", x9.to_string())
+ self.assertEqual("-123.45€", x10.to_string())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testAssignment(self):
+ x0 = amount()
+ x1 = amount(123456)
+ x2 = amount(123456L)
+ x3 = amount(123.456)
+ x5 = amount("123456")
+ x6 = amount("123.456")
+ x7 = "123456"
+ x8 = "123.456"
+ x9 = amount(x3)
+ x10 = amount(x6)
+
+ self.assertEqual(x2, x1)
+ self.assertEqual(x5, x1)
+ self.assertEqual(x7, x1)
+ self.assertEqual(x6, x3)
+ self.assertEqual(x8, x3)
+ self.assertEqual(x10, x3)
+ self.assertEqual(x10, x9)
+
+ x1 = amount(123456)
+ x2 = amount(123456L)
+ x3 = amount(123.456)
+ x5 = amount("123456")
+ x6 = amount("123.456")
+ x7 = amount("123456")
+ x8 = amount("123.456")
+ x9 = x3
+ x10 = amount(x6)
+
+ self.assertEqual(x2, x1)
+ self.assertEqual(x5, x1)
+ self.assertEqual(x7, x1)
+ self.assertEqual(x6, x3)
+ self.assertEqual(x8, x3)
+ self.assertEqual(x10, x3)
+ self.assertEqual(x10, x9)
+
+ self.assertFalse(x1.is_null())
+ x1 = x0 # sets x1 back to uninitialized state
+ self.assertTrue(x0.is_null())
+ self.assertTrue(x1.is_null())
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testCommodityAssignment(self):
+ x1 = amount("$123.45")
+ x2 = amount("-$123.45")
+ x3 = amount("$-123.45")
+ x4 = amount("DM 123.45")
+ x5 = amount("-DM 123.45")
+ x6 = amount("DM -123.45")
+ x7 = amount("123.45 euro")
+ x8 = amount("-123.45 euro")
+ x9 = amount("123.45€")
+ x10 = amount("-123.45€")
+
+ self.assertEqual(amount("$123.45"), x1)
+ self.assertEqual(amount("-$123.45"), x2)
+ self.assertEqual(amount("$-123.45"), x3)
+ self.assertEqual(amount("DM 123.45"), x4)
+ self.assertEqual(amount("-DM 123.45"), x5)
+ self.assertEqual(amount("DM -123.45"), x6)
+ self.assertEqual(amount("123.45 euro"), x7)
+ self.assertEqual(amount("-123.45 euro"), x8)
+ self.assertEqual(amount("123.45€"), x9)
+ self.assertEqual(amount("-123.45€"), x10)
+
+ self.assertEqual("$123.45", x1.to_string())
+ self.assertEqual("$-123.45", x2.to_string())
+ self.assertEqual("$-123.45", x3.to_string())
+ self.assertEqual("DM 123.45", x4.to_string())
+ self.assertEqual("DM -123.45", x5.to_string())
+ self.assertEqual("DM -123.45", x6.to_string())
+ self.assertEqual("123.45 euro", x7.to_string())
+ self.assertEqual("-123.45 euro", x8.to_string())
+ self.assertEqual("123.45€", x9.to_string())
+ self.assertEqual("-123.45€", x10.to_string())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testEquality(self):
+ x1 = amount(123456)
+ x2 = amount(456789)
+ x3 = amount(333333)
+ x4 = amount(123456.0)
+ x5 = amount("123456.0")
+ x6 = amount(123456.0)
+
+ self.assertTrue(x1 == 123456)
+ self.assertTrue(x1 != x2)
+ self.assertTrue(x1 == (x2 - x3))
+ self.assertTrue(x1 == x4)
+ self.assertTrue(x4 == x5)
+ self.assertTrue(x4 == x6)
+
+ self.assertTrue(x1 == 123456)
+ self.assertTrue(123456 == x1)
+ self.assertTrue(x1 == 123456L)
+ self.assertTrue(123456L == x1)
+ self.assertTrue(x1 == 123456.0)
+ self.assertTrue(123456.0 == x1)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+
+ def testCommodityEquality(self):
+ x0 = amount()
+ x1 = amount("$123.45")
+ x2 = amount("-$123.45")
+ x3 = amount("$-123.45")
+ x4 = amount("DM 123.45")
+ x5 = amount("-DM 123.45")
+ x6 = amount("DM -123.45")
+ x7 = amount("123.45 euro")
+ x8 = amount("-123.45 euro")
+ x9 = amount("123.45€")
+ x10 = amount("-123.45€")
+
+ self.assertTrue(x0.is_null())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.is_zero())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.is_realzero())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.sign() == 0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.compare(x1) < 0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.compare(x2) > 0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.compare(x0) == 0)
+
+ self.assertTrue(x1 != x2)
+ self.assertTrue(x1 != x4)
+ self.assertTrue(x1 != x7)
+ self.assertTrue(x1 != x9)
+ self.assertTrue(x2 == x3)
+ self.assertTrue(x4 != x5)
+ self.assertTrue(x5 == x6)
+ self.assertTrue(x7 == - x8)
+ self.assertTrue(x9 == - x10)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testComparisons(self):
+ x0 = amount()
+ x1 = amount(-123)
+ x2 = amount(123)
+ x3 = amount(-123.45)
+ x4 = amount(123.45)
+ x5 = amount("-123.45")
+ x6 = amount("123.45")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 > x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 < x2)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 > x3)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 < x4)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 > x5)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 < x6)
+
+ self.assertTrue(x1 > x3)
+ self.assertTrue(x3 <= x5)
+ self.assertTrue(x3 >= x5)
+ self.assertTrue(x3 < x1)
+ self.assertTrue(x3 < x4)
+
+ self.assertTrue(x1 < 100)
+ self.assertTrue(100 > x1)
+ self.assertTrue(x1 < 100L)
+ self.assertTrue(100L > x1)
+ self.assertTrue(x1 < 100.0)
+ self.assertTrue(100.0 > x1)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+
+ def testCommodityComparisons(self):
+ x1 = amount("$-123")
+ x2 = amount("$123.00")
+ x3 = amount(internalAmount("$-123.4544"))
+ x4 = amount(internalAmount("$123.4544"))
+ x5 = amount("$-123.45")
+ x6 = amount("$123.45")
+ x7 = amount("DM 123.45")
+
+ self.assertTrue(x1 > x3)
+ self.assertTrue(x3 <= x5)
+ self.assertTrue(x3 < x5)
+ self.assertTrue(x3 <= x5)
+ self.assertFalse(x3 == x5)
+ self.assertTrue(x3 < x1)
+ self.assertTrue(x3 < x4)
+ self.assertFalse(x6 == x7)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x6 < x7)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+
+ def testIntegerAddition(self):
+ x0 = amount()
+ x1 = amount(123)
+ y1 = amount(456)
+
+ self.assertEqual(amount(579), x1 + y1)
+ self.assertEqual(amount(579), x1 + 456)
+ self.assertEqual(amount(579), 456 + x1)
+
+ x1 += amount(456)
+ self.assertEqual(amount(579), x1)
+ x1 += 456
+ self.assertEqual(amount(1035), x1)
+
+ x4 = amount("123456789123456789123456789")
+
+ self.assertEqual(amount("246913578246913578246913578"), x4 + x4)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x4)
+
+ def testFractionalAddition(self):
+ x1 = amount(123.123)
+ y1 = amount(456.456)
+
+ self.assertEqual(amount(579.579), x1 + y1)
+ self.assertEqual(amount(579.579), x1 + 456.456)
+ self.assertEqual(amount(579.579), 456.456 + x1)
+
+ x1 += amount(456.456)
+ self.assertEqual(amount(579.579), x1)
+ x1 += 456.456
+ self.assertEqual(amount(1036.035), x1)
+ x1 += 456
+ self.assertEqual(amount(1492.035), x1)
+
+ x2 = amount("123456789123456789.123456789123456789")
+
+ self.assertEqual(amount("246913578246913578.246913578246913578"), x2 + x2)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x2)
+
+ def testCommodityAddition(self):
+ x0 = amount()
+ x1 = amount("$123.45")
+ x2 = amount(internalAmount("$123.456789"))
+ x3 = amount("DM 123.45")
+ x4 = amount("123.45 euro")
+ x5 = amount("123.45€")
+ x6 = amount("123.45")
+
+ self.assertEqual(amount("$246.90"), x1 + x1)
+ self.assertNotEqual(amount("$246.91"), x1 + x2)
+ self.assertEqual(internalAmount("$246.906789"), x1 + x2)
+
+ # Converting to string drops internal precision
+ self.assertEqual("$246.90", (x1 + x1).to_string())
+ self.assertEqual("$246.91", (x1 + x2).to_string())
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 + x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 + x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + x3)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + x4)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + x5)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + x6)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + 123.45)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 + 123)
+
+ self.assertEqual(amount("DM 246.90"), x3 + x3)
+ self.assertEqual(amount("246.90 euro"), x4 + x4)
+ self.assertEqual(amount("246.90€"), x5 + x5)
+
+ self.assertEqual("DM 246.90", (x3 + x3).to_string())
+ self.assertEqual("246.90 euro", (x4 + x4).to_string())
+ self.assertEqual("246.90€", (x5 + x5).to_string())
+
+ x1 += amount("$456.45")
+ self.assertEqual(amount("$579.90"), x1)
+ x1 += amount("$456.45")
+ self.assertEqual(amount("$1036.35"), x1)
+ x1 += amount("$456")
+ self.assertEqual(amount("$1492.35"), x1)
+
+ x7 = amount(internalAmount("$123456789123456789.123456789123456789"))
+
+ self.assertEqual(internalAmount("$246913578246913578.246913578246913578"), x7 + x7)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+
+ def testIntegerSubtraction(self):
+ x1 = amount(123)
+ y1 = amount(456)
+
+ self.assertEqual(amount(333), y1 - x1)
+ self.assertEqual(amount(-333), x1 - y1)
+ self.assertEqual(amount(23), x1 - 100)
+ self.assertEqual(amount(-23), 100 - x1)
+
+ x1 -= amount(456)
+ self.assertEqual(amount(-333), x1)
+ x1 -= 456
+ self.assertEqual(amount(-789), x1)
+
+ x4 = amount("123456789123456789123456789")
+ y4 = amount("8238725986235986")
+
+ self.assertEqual(amount("123456789115218063137220803"), x4 - y4)
+ self.assertEqual(amount("-123456789115218063137220803"), y4 - x4)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x4)
+ self.assertValid(y4)
+
+ def testFractionalSubtraction(self):
+ x1 = amount(123.123)
+ y1 = amount(456.456)
+
+ self.assertEqual(amount(-333.333), x1 - y1)
+ self.assertEqual(amount(333.333), y1 - x1)
+
+ x1 -= amount(456.456)
+ self.assertEqual(amount(-333.333), x1)
+ x1 -= 456.456
+ self.assertEqual(amount(-789.789), x1)
+ x1 -= 456
+ self.assertEqual(amount(-1245.789), x1)
+
+ x2 = amount("123456789123456789.123456789123456789")
+ y2 = amount("9872345982459.248974239578")
+
+ self.assertEqual(amount("123446916777474329.874482549545456789"), x2 - y2)
+ self.assertEqual(amount("-123446916777474329.874482549545456789"), y2 - x2)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x2)
+ self.assertValid(y2)
+
+ def testCommoditySubtraction(self):
+ x0 = amount()
+ x1 = amount("$123.45")
+ x2 = amount(internalAmount("$123.456789"))
+ x3 = amount("DM 123.45")
+ x4 = amount("123.45 euro")
+ x5 = amount("123.45€")
+ x6 = amount("123.45")
+
+ self.assertNotEqual(amount(), x1 - x1)
+ self.assertEqual(amount("$0"), x1 - x1)
+ self.assertEqual(amount("$23.45"), x1 - amount("$100.00"))
+ self.assertEqual(amount("$-23.45"), amount("$100.00") - x1)
+ self.assertNotEqual(amount("$-0.01"), x1 - x2)
+ self.assertEqual(internalAmount("$-0.006789"), x1 - x2)
+
+ # Converting to string drops internal precision. If an amount is
+ # zero, it drops the commodity as well.
+ self.assertEqual("$0.00", (x1 - x1).to_string())
+ self.assertEqual("$-0.01", (x1 - x2).to_string())
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 - x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 - x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - x3)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - x4)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - x5)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - x6)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - 123.45)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 - 123)
+
+ self.assertEqual(amount("DM 0.00"), x3 - x3)
+ self.assertEqual(amount("DM 23.45"), x3 - amount("DM 100.00"))
+ self.assertEqual(amount("DM -23.45"), amount("DM 100.00") - x3)
+ self.assertEqual(amount("0.00 euro"), x4 - x4)
+ self.assertEqual(amount("23.45 euro"), x4 - amount("100.00 euro"))
+ self.assertEqual(amount("-23.45 euro"), amount("100.00 euro") - x4)
+ self.assertEqual(amount("0.00€"), x5 - x5)
+ self.assertEqual(amount("23.45€"), x5 - amount("100.00€"))
+ self.assertEqual(amount("-23.45€"), amount("100.00€") - x5)
+
+ self.assertEqual("DM 0.00", (x3 - x3).to_string())
+ self.assertEqual("DM 23.45", (x3 - amount("DM 100.00")).to_string())
+ self.assertEqual("DM -23.45", (amount("DM 100.00") - x3).to_string())
+ self.assertEqual("0.00 euro", (x4 - x4).to_string())
+ self.assertEqual("23.45 euro", (x4 - amount("100.00 euro")).to_string())
+ self.assertEqual("-23.45 euro", (amount("100.00 euro") - x4).to_string())
+ self.assertEqual("0.00€", (x5 - x5).to_string())
+ self.assertEqual("23.45€", (x5 - amount("100.00€")).to_string())
+ self.assertEqual("-23.45€", (amount("100.00€") - x5).to_string())
+
+ x1 -= amount("$456.45")
+ self.assertEqual(amount("$-333.00"), x1)
+ x1 -= amount("$456.45")
+ self.assertEqual(amount("$-789.45"), x1)
+ x1 -= amount("$456")
+ self.assertEqual(amount("$-1245.45"), x1)
+
+ x7 = amount(internalAmount("$123456789123456789.123456789123456789"))
+ x8 = amount(internalAmount("$2354974984698.98459845984598"))
+
+ self.assertEqual(internalAmount("$123454434148472090.138858329277476789"), x7 - x8)
+ self.assertEqual("$123454434148472090.138858329277476789", (x7 - x8).to_string())
+ self.assertEqual("$123454434148472090.14",
+ (amount("$1.00") * (x7 - x8)).to_string())
+ self.assertEqual(internalAmount("$-123454434148472090.138858329277476789"), x8 - x7)
+ self.assertEqual("$-123454434148472090.138858329277476789", (x8 - x7).to_string())
+ self.assertEqual("$-123454434148472090.14",
+ (amount("$1.00") * (x8 - x7)).to_string())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+
+ def testIntegerMultiplication(self):
+ x1 = amount(123)
+ y1 = amount(456)
+
+ self.assertEqual(amount(0), x1 * 0)
+ self.assertEqual(amount(0), amount(0) * x1)
+ self.assertEqual(amount(0), 0 * x1)
+ self.assertEqual(x1, x1 * 1)
+ self.assertEqual(x1, amount(1) * x1)
+ self.assertEqual(x1, 1 * x1)
+ self.assertEqual(- x1, x1 * -1)
+ self.assertEqual(- x1, amount(-1) * x1)
+ self.assertEqual(- x1, -1 * x1)
+ self.assertEqual(amount(56088), x1 * y1)
+ self.assertEqual(amount(56088), y1 * x1)
+ self.assertEqual(amount(56088), x1 * 456)
+ self.assertEqual(amount(56088), amount(456) * x1)
+ self.assertEqual(amount(56088), 456 * x1)
+
+ x1 *= amount(123)
+ self.assertEqual(amount(15129), x1)
+ x1 *= 123
+ self.assertEqual(amount(1860867), x1)
+
+ x4 = amount("123456789123456789123456789")
+
+ self.assertEqual(amount("15241578780673678546105778281054720515622620750190521"),
+ x4 * x4)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x4)
+
+ def testFractionalMultiplication(self):
+ x1 = amount(123.123)
+ y1 = amount(456.456)
+
+ self.assertEqual(amount(0), x1 * 0)
+ self.assertEqual(amount(0), amount(0) * x1)
+ self.assertEqual(amount(0), 0 * x1)
+ self.assertEqual(x1, x1 * 1)
+ self.assertEqual(x1, amount(1) * x1)
+ self.assertEqual(x1, 1 * x1)
+ self.assertEqual(- x1, x1 * -1)
+ self.assertEqual(- x1, amount(-1) * x1)
+ self.assertEqual(- x1, -1 * x1)
+ self.assertEqual(amount("56200.232088"), x1 * y1)
+ self.assertEqual(amount("56200.232088"), y1 * x1)
+ self.assertEqual(amount("56200.232088"), x1 * 456.456)
+ self.assertEqual(amount("56200.232088"), amount(456.456) * x1)
+ self.assertEqual(amount("56200.232088"), 456.456 * x1)
+
+ x1 *= amount(123.123)
+ self.assertEqual(amount("15159.273129"), x1)
+ x1 *= 123.123
+ self.assertEqual(amount("1866455.185461867"), x1)
+ x1 *= 123
+ self.assertEqual(amount("229573987.811809641"), x1)
+
+ x2 = amount("123456789123456789.123456789123456789")
+
+ self.assertEqual(amount("15241578780673678546105778311537878.046486820281054720515622620750190521"),
+ x2 * x2)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x2)
+
+ def testCommodityMultiplication(self):
+ x0 = amount()
+ x1 = amount("$123.12")
+ y1 = amount("$456.45")
+ x2 = amount(internalAmount("$123.456789"))
+ x3 = amount("DM 123.45")
+ x4 = amount("123.45 euro")
+ x5 = amount("123.45€")
+
+ self.assertEqual(amount("$0.00"), x1 * 0)
+ self.assertEqual(amount("$0.00"), 0 * x1)
+ self.assertEqual(x1, x1 * 1)
+ self.assertEqual(x1, 1 * x1)
+ self.assertEqual(- x1, x1 * -1)
+ self.assertEqual(- x1, -1 * x1)
+ self.assertEqual(internalAmount("$56198.124"), x1 * y1)
+ self.assertEqual("$56198.12", (x1 * y1).to_string())
+ self.assertEqual(internalAmount("$56198.124"), y1 * x1)
+ self.assertEqual("$56198.12", (y1 * x1).to_string())
+
+ # Internal amounts retain their precision, even when being
+ # converted to strings
+ self.assertEqual(internalAmount("$15199.99986168"), x1 * x2)
+ self.assertEqual(internalAmount("$15199.99986168"), x2 * x1)
+ self.assertEqual("$15200.00", (x1 * x2).to_string())
+ self.assertEqual("$15199.99986168", (x2 * x1).to_string())
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 * x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 * x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 * x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 * x3)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 * x4)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 * x5)
+
+ x1 *= amount("123.12")
+ self.assertEqual(internalAmount("$15158.5344"), x1)
+ self.assertEqual("$15158.53", x1.to_string())
+ x1 *= 123.12
+ self.assertEqual(internalAmount("$1866318.755328"), x1)
+ self.assertEqual("$1866318.76", x1.to_string())
+ x1 *= 123
+ self.assertEqual(internalAmount("$229557206.905344"), x1)
+ self.assertEqual("$229557206.91", x1.to_string())
+
+ x7 = amount(internalAmount("$123456789123456789.123456789123456789"))
+
+ self.assertEqual(internalAmount("$15241578780673678546105778311537878.046486820281054720515622620750190521"),
+ x7 * x7)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x7)
+
+ def testIntegerDivision(self):
+ x1 = amount(123)
+ y1 = amount(456)
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / 0)
+ self.assertEqual(amount(0), amount(0) / x1)
+ self.assertEqual(amount(0), 0 / x1)
+ self.assertEqual(x1, x1 / 1)
+ self.assertEqual(amount("0.008130"), amount(1) / x1)
+ self.assertEqual(amount("0.008130"), 1 / x1)
+ self.assertEqual(- x1, x1 / -1)
+ self.assertEqual(- amount("0.008130"), amount(-1) / x1)
+ self.assertEqual(- amount("0.008130"), -1 / x1)
+ self.assertEqual(amount("0.269737"), x1 / y1)
+ self.assertEqual(amount("3.707317"), y1 / x1)
+ self.assertEqual(amount("0.269737"), x1 / 456)
+ self.assertEqual(amount("3.707317"), amount(456) / x1)
+ self.assertEqual(amount("3.707317"), 456 / x1)
+
+ x1 /= amount(456)
+ self.assertEqual(amount("0.269737"), x1)
+ x1 /= 456
+ self.assertEqual(amount("0.00059152850877193"), x1)
+
+ x4 = amount("123456789123456789123456789")
+ y4 = amount("56")
+
+ self.assertEqual(amount(1), x4 / x4)
+ self.assertEqual(amount("2204585520061728377204585.517857"), x4 / y4)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x4)
+ self.assertValid(y4)
+
+ def testFractionalDivision(self):
+ x1 = amount(123.123)
+ y1 = amount(456.456)
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / 0)
+ self.assertEqual(amount("0.008121959"), amount(1.0) / x1)
+ self.assertEqual(amount("0.008121959"), 1.0 / x1)
+ self.assertEqual(x1, x1 / 1.0)
+ self.assertEqual(amount("0.008121959"), amount(1.0) / x1)
+ self.assertEqual(amount("0.008121959"), 1.0 / x1)
+ self.assertEqual(- x1, x1 / -1.0)
+ self.assertEqual(- amount("0.008121959"), amount(-1.0) / x1)
+ self.assertEqual(- amount("0.008121959"), -1.0 / x1)
+ self.assertEqual(amount("0.269736842105263"), x1 / y1)
+ self.assertEqual(amount("3.707317073170732"), y1 / x1)
+ self.assertEqual(amount("0.269736842105263"), x1 / 456.456)
+ self.assertEqual(amount("3.707317073170732"), amount(456.456) / x1)
+ self.assertEqual(amount("3.707317073170732"), 456.456 / x1)
+
+ x1 /= amount(456.456)
+ self.assertEqual(amount("0.269736842105263"), x1)
+ x1 /= 456.456
+ self.assertEqual(amount("0.000590937225286255411255411255411255411"), x1)
+ x1 /= 456
+ self.assertEqual(amount("0.000001295914967733016252753094858358016252192982456140350877192982456140350877192982"), x1)
+
+ x4 = amount("1234567891234567.89123456789")
+ y4 = amount("56.789")
+
+ self.assertEqual(amount(1.0), x4 / x4)
+ self.assertEqual(amount("21739560323910.7554497273748437197344556164046"), x4 / y4)
+
+ self.assertValid(x1)
+ self.assertValid(y1)
+ self.assertValid(x4)
+ self.assertValid(y4)
+
+ def testCommodityDivision(self):
+ x0 = amount()
+ x1 = amount("$123.12")
+ y1 = amount("$456.45")
+ x2 = amount(internalAmount("$123.456789"))
+ x3 = amount("DM 123.45")
+ x4 = amount("123.45 euro")
+ x5 = amount("123.45€")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / 0)
+ self.assertEqual(amount("$0.00"), 0 / x1)
+ self.assertEqual(x1, x1 / 1)
+ self.assertEqual(internalAmount("$0.00812216"), 1 / x1)
+ self.assertEqual(- x1, x1 / -1)
+ self.assertEqual(internalAmount("$-0.00812216"), -1 / x1)
+ self.assertEqual(internalAmount("$0.26973382"), x1 / y1)
+ self.assertEqual("$0.27", (x1 / y1).to_string())
+ self.assertEqual(internalAmount("$3.70735867"), y1 / x1)
+ self.assertEqual("$3.71", (y1 / x1).to_string())
+
+ # Internal amounts retain their precision, even when being
+ # converted to strings
+ self.assertEqual(internalAmount("$0.99727201"), x1 / x2)
+ self.assertEqual(internalAmount("$1.00273545321637426901"), x2 / x1)
+ self.assertEqual("$1.00", (x1 / x2).to_string())
+ self.assertEqual("$1.00273545321637426901", (x2 / x1).to_string())
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 / x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0 / x0)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / x3)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / x4)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1 / x5)
+
+ x1 /= amount("123.12")
+ self.assertEqual(internalAmount("$1.00"), x1)
+ self.assertEqual("$1.00", x1.to_string())
+ x1 /= 123.12
+ self.assertEqual(internalAmount("$0.00812216"), x1)
+ self.assertEqual("$0.01", x1.to_string())
+ x1 /= 123
+ self.assertEqual(internalAmount("$0.00006603"), x1)
+ self.assertEqual("$0.00", x1.to_string())
+
+ x6 = amount(internalAmount("$237235987235987.98723987235978"))
+ x7 = amount(internalAmount("$123456789123456789.123456789123456789"))
+
+ self.assertEqual(amount("$1"), x7 / x7)
+ self.assertEqual(internalAmount("$0.0019216115121765559608381226612019501046413574469262"),
+ x6 / x7)
+ self.assertEqual(internalAmount("$520.39654928343335571379527154924040947271699678158689736256"),
+ x7 / x6)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+
+ def testNegation(self):
+ x0 = amount()
+ x1 = amount(-123456)
+ x3 = amount(-123.456)
+ x5 = amount("-123456")
+ x6 = amount("-123.456")
+ x7 = amount("-123456")
+ x8 = amount("-123.456")
+ x9 = amount(- x3)
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.negate())
+ self.assertEqual(x5, x1)
+ self.assertEqual(x7, x1)
+ self.assertEqual(x6, x3)
+ self.assertEqual(x8, x3)
+ self.assertEqual(- x6, x9)
+ self.assertEqual(x3.negate(), x9)
+
+ x10 = amount(x9.negate())
+
+ self.assertEqual(x3, x10)
+
+ self.assertValid(x1)
+ self.assertValid(x3)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testCommodityNegation(self):
+ x1 = amount("$123.45")
+ x2 = amount("-$123.45")
+ x3 = amount("$-123.45")
+ x4 = amount("DM 123.45")
+ x5 = amount("-DM 123.45")
+ x6 = amount("DM -123.45")
+ x7 = amount("123.45 euro")
+ x8 = amount("-123.45 euro")
+ x9 = amount("123.45€")
+ x10 = amount("-123.45€")
+
+ self.assertEqual(amount("$-123.45"), - x1)
+ self.assertEqual(amount("$123.45"), - x2)
+ self.assertEqual(amount("$123.45"), - x3)
+ self.assertEqual(amount("DM -123.45"), - x4)
+ self.assertEqual(amount("DM 123.45"), - x5)
+ self.assertEqual(amount("DM 123.45"), - x6)
+ self.assertEqual(amount("-123.45 euro"), - x7)
+ self.assertEqual(amount("123.45 euro"), - x8)
+ self.assertEqual(amount("-123.45€"), - x9)
+ self.assertEqual(amount("123.45€"), - x10)
+
+ self.assertEqual(amount("$-123.45"), x1.negate())
+ self.assertEqual(amount("$123.45"), x2.negate())
+ self.assertEqual(amount("$123.45"), x3.negate())
+
+ self.assertEqual("$-123.45", (- x1).to_string())
+ self.assertEqual("$123.45", (- x2).to_string())
+ self.assertEqual("$123.45", (- x3).to_string())
+ self.assertEqual("DM -123.45", (- x4).to_string())
+ self.assertEqual("DM 123.45", (- x5).to_string())
+ self.assertEqual("DM 123.45", (- x6).to_string())
+ self.assertEqual("-123.45 euro", (- x7).to_string())
+ self.assertEqual("123.45 euro", (- x8).to_string())
+ self.assertEqual("-123.45€", (- x9).to_string())
+ self.assertEqual("123.45€", (- x10).to_string())
+
+ self.assertEqual(amount("$-123.45"), x1.negate())
+ self.assertEqual(amount("$123.45"), x2.negate())
+ self.assertEqual(amount("$123.45"), x3.negate())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+ self.assertValid(x6)
+ self.assertValid(x7)
+ self.assertValid(x8)
+ self.assertValid(x9)
+ self.assertValid(x10)
+
+ def testAbs(self):
+ x0 = amount()
+ x1 = amount(-1234)
+ x2 = amount(1234)
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.abs())
+ self.assertEqual(amount(1234), x1.abs())
+ self.assertEqual(amount(1234), x2.abs())
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+
+ def testCommodityAbs(self):
+ x1 = amount("$-1234.56")
+ x2 = amount("$1234.56")
+
+ self.assertEqual(amount("$1234.56"), x1.abs())
+ self.assertEqual(amount("$1234.56"), x2.abs())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+
+ def testFractionalRound(self):
+ x0 = amount()
+ x1 = amount("1234.567890")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.precision)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.round())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.round(2))
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.unround())
+ self.assertEqual(6, x1.precision)
+
+ x1b = amount(x1.unround())
+
+ self.assertEqual(x1b.precision, x1b.unround().precision)
+
+ y7 = amount(x1.round(7))
+ y6 = amount(x1.round(6))
+ y5 = amount(x1.round(5))
+ y4 = amount(x1.round(4))
+ y3 = amount(x1.round(3))
+ y2 = amount(x1.round(2))
+ y1 = amount(x1.round(1))
+ y0 = amount(x1.round(0))
+
+ self.assertEqual(6, y7.precision)
+ self.assertEqual(6, y6.precision)
+ self.assertEqual(5, y5.precision)
+ self.assertEqual(4, y4.precision)
+ self.assertEqual(3, y3.precision)
+ self.assertEqual(2, y2.precision)
+ self.assertEqual(1, y1.precision)
+ self.assertEqual(0, y0.precision)
+
+ self.assertEqual(amount("1234.56789"), y7)
+ self.assertEqual(amount("1234.56789"), y6)
+ self.assertEqual(amount("1234.56789"), y5)
+ self.assertEqual(amount("1234.5679"), y4)
+ self.assertEqual(amount("1234.568"), y3)
+ self.assertEqual(amount("1234.57"), y2)
+ self.assertEqual(amount("1234.6"), y1)
+ self.assertEqual(amount("1235"), y0)
+
+ x2 = amount("9876.543210")
+
+ self.assertEqual(amount("9876.543210"), x2.round(6))
+ self.assertEqual(amount("9876.54321"), x2.round(5))
+ self.assertEqual(amount("9876.5432"), x2.round(4))
+ self.assertEqual(amount("9876.543"), x2.round(3))
+ self.assertEqual(amount("9876.54"), x2.round(2))
+ self.assertEqual(amount("9876.5"), x2.round(1))
+ self.assertEqual(amount("9877"), x2.round(0))
+
+ x3 = amount("-1234.567890")
+
+ self.assertEqual(amount("-1234.56789"), x3.round(6))
+ self.assertEqual(amount("-1234.56789"), x3.round(5))
+ self.assertEqual(amount("-1234.5679"), x3.round(4))
+ self.assertEqual(amount("-1234.568"), x3.round(3))
+ self.assertEqual(amount("-1234.57"), x3.round(2))
+ self.assertEqual(amount("-1234.6"), x3.round(1))
+ self.assertEqual(amount("-1235"), x3.round(0))
+
+ x4 = amount("-9876.543210")
+
+ self.assertEqual(amount("-9876.543210"), x4.round(6))
+ self.assertEqual(amount("-9876.54321"), x4.round(5))
+ self.assertEqual(amount("-9876.5432"), x4.round(4))
+ self.assertEqual(amount("-9876.543"), x4.round(3))
+ self.assertEqual(amount("-9876.54"), x4.round(2))
+ self.assertEqual(amount("-9876.5"), x4.round(1))
+ self.assertEqual(amount("-9877"), x4.round(0))
+
+ x5 = amount("0.0000000000000000000000000000000000001")
+
+ self.assertEqual(amount("0.0000000000000000000000000000000000001"),
+ x5.round(37))
+ self.assertEqual(amount(0), x5.round(36))
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+
+ def testCommodityRound(self):
+ x1 = amount(internalAmount("$1234.567890"))
+
+ self.assertEqual(internalAmount("$1234.56789"), x1.round(6))
+ self.assertEqual(internalAmount("$1234.56789"), x1.round(5))
+ self.assertEqual(internalAmount("$1234.5679"), x1.round(4))
+ self.assertEqual(internalAmount("$1234.568"), x1.round(3))
+ self.assertEqual(amount("$1234.57"), x1.round(2))
+ self.assertEqual(amount("$1234.6"), x1.round(1))
+ self.assertEqual(amount("$1235"), x1.round(0))
+
+ x2 = amount(internalAmount("$9876.543210"))
+
+ self.assertEqual(internalAmount("$9876.543210"), x2.round(6))
+ self.assertEqual(internalAmount("$9876.54321"), x2.round(5))
+ self.assertEqual(internalAmount("$9876.5432"), x2.round(4))
+ self.assertEqual(internalAmount("$9876.543"), x2.round(3))
+ self.assertEqual(amount("$9876.54"), x2.round(2))
+ self.assertEqual(amount("$9876.5"), x2.round(1))
+ self.assertEqual(amount("$9877"), x2.round(0))
+
+ x3 = amount(internalAmount("$-1234.567890"))
+
+ self.assertEqual(internalAmount("$-1234.56789"), x3.round(6))
+ self.assertEqual(internalAmount("$-1234.56789"), x3.round(5))
+ self.assertEqual(internalAmount("$-1234.5679"), x3.round(4))
+ self.assertEqual(internalAmount("$-1234.568"), x3.round(3))
+ self.assertEqual(amount("$-1234.57"), x3.round(2))
+ self.assertEqual(amount("$-1234.6"), x3.round(1))
+ self.assertEqual(amount("$-1235"), x3.round(0))
+
+ x4 = amount(internalAmount("$-9876.543210"))
+
+ self.assertEqual(internalAmount("$-9876.543210"), x4.round(6))
+ self.assertEqual(internalAmount("$-9876.54321"), x4.round(5))
+ self.assertEqual(internalAmount("$-9876.5432"), x4.round(4))
+ self.assertEqual(internalAmount("$-9876.543"), x4.round(3))
+ self.assertEqual(amount("$-9876.54"), x4.round(2))
+ self.assertEqual(amount("$-9876.5"), x4.round(1))
+ self.assertEqual(amount("$-9877"), x4.round(0))
+
+ x5 = amount("$123.45")
+
+ x5 *= 100.12
+
+ self.assertEqual(internalAmount("$12359.814"), x5)
+ self.assertEqual("$12359.81", x5.to_string())
+ self.assertEqual("$12359.814", x5.to_fullstring())
+ self.assertEqual("$12359.814", x5.unround().to_string())
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+ self.assertValid(x5)
+
+ def testCommodityDisplayRound(self):
+ x1 = amount("$0.85")
+ x2 = amount("$0.1")
+
+ x1 *= 0.19
+
+ self.assertNotEqual(amount("$0.16"), x1)
+ self.assertEqual(internalAmount("$0.1615"), x1)
+ self.assertEqual("$0.16", x1.to_string())
+
+ self.assertEqual(amount("$0.10"), x2)
+ self.assertNotEqual(internalAmount("$0.101"), x2)
+ self.assertEqual("$0.10", x2.to_string())
+
+ x1 *= 7
+
+ self.assertNotEqual(amount("$1.13"), x1)
+ self.assertEqual(internalAmount("$1.1305"), x1)
+ self.assertEqual("$1.13", x1.to_string())
+
+ def testReduction(self):
+ x0 = amount()
+ x1 = amount("60s")
+ x2 = amount("600s")
+ x3 = amount("6000s")
+ x4 = amount("360000s")
+ x5 = amount("10m")
+ x6 = amount("100m")
+ x7 = amount("1000m")
+ x8 = amount("10000m")
+ x9 = amount("10h")
+ x10 = amount("100h")
+ x11 = amount("1000h")
+ x12 = amount("10000h")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.reduce())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.unreduce())
+ self.assertEqual(x2, x5)
+ self.assertEqual(x3, x6)
+ self.assertEqual(x4, x10)
+ self.assertEqual("100.0h", x4.unreduce().to_string())
+
+ def testSign(self):
+ x0 = amount()
+ x1 = amount("0.0000000000000000000000000000000000001")
+ x2 = amount("-0.0000000000000000000000000000000000001")
+ x3 = amount("1")
+ x4 = amount("-1")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.sign())
+ self.assertTrue(x1.sign() > 0)
+ self.assertTrue(x2.sign() < 0)
+ self.assertTrue(x3.sign() > 0)
+ self.assertTrue(x4.sign() < 0)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+
+ def testCommoditySign(self):
+ x1 = amount(internalAmount("$0.0000000000000000000000000000000000001"))
+ x2 = amount(internalAmount("$-0.0000000000000000000000000000000000001"))
+ x3 = amount("$1")
+ x4 = amount("$-1")
+
+ self.assertTrue(x1.sign() != 0)
+ self.assertTrue(x2.sign() != 0)
+ self.assertTrue(x3.sign() > 0)
+ self.assertTrue(x4.sign() < 0)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+ self.assertValid(x3)
+ self.assertValid(x4)
+
+ def testTruth(self):
+ x0 = amount()
+ x1 = amount("1234")
+ x2 = amount("1234.56")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: 1 if x0 else 0)
+
+ self.assertTrue(x1)
+ self.assertTrue(x2)
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+ self.assertValid(x2)
+
+ def testCommodityTruth(self):
+ x1 = amount("$1234")
+ x2 = amount("$1234.56")
+
+ if x1:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+
+ if x2:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+
+ self.assertValid(x1)
+ self.assertValid(x2)
+
+ def testForZero(self):
+ x0 = amount()
+ x1 = amount("0.000000000000000000001")
+
+ self.assertTrue(x1)
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.is_zero())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.is_realzero())
+ self.assertFalse(x1.is_zero())
+ self.assertFalse(x1.is_realzero())
+
+ self.assertValid(x0)
+ self.assertValid(x1)
+
+ def testCommodityForZero(self):
+ x1 = amount(internalAmount("$0.000000000000000000001"))
+
+ self.assertFalse(x1)
+ self.assertTrue(x1.is_zero())
+ self.assertFalse(x1.is_realzero())
+
+ self.assertValid(x1)
+
+ def testIntegerConversion(self):
+ x0 = amount()
+ x1 = amount(123456)
+ x2 = amount("12345682348723487324")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.to_long())
+ self.assertRaises(exceptions.ArithmeticError, lambda: x0.to_double())
+ self.assertFalse(x2.fits_in_long())
+ self.assertEqual(123456, x1.to_long())
+ self.assertEqual(123456.0, x1.to_double())
+ self.assertEqual("123456", x1.to_string())
+ self.assertEqual("123456", x1.quantity_string)
+
+ self.assertValid(x1)
+
+ def testFractionalConversion(self):
+ x1 = amount(1234.56)
+ x2 = amount("1234.5683787634678348734")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1.to_long()) # loses precision
+ self.assertRaises(exceptions.ArithmeticError, lambda: x2.to_double()) # loses precision
+ self.assertFalse(x2.fits_in_double())
+ self.assertEqual(1234, x1.to_long(True))
+ self.assertEqual(1234.56, x1.to_double())
+ self.assertEqual("1234.56", x1.to_string())
+ self.assertEqual("1234.56", x1.quantity_string)
+
+ self.assertValid(x1)
+
+ def testCommodityConversion(self):
+ x1 = amount("$1234.56")
+
+ self.assertRaises(exceptions.ArithmeticError, lambda: x1.to_long()) # loses precision
+ self.assertEqual(1234, x1.to_long(True))
+ self.assertEqual(1234.56, x1.to_double())
+ self.assertEqual("$1234.56", x1.to_string())
+ self.assertEqual("1234.56", x1.quantity_string)
+
+ self.assertValid(x1)
+
+ def testPrinting(self):
+ pass
+ #x0 = amount()
+ #x1 = amount("982340823.380238098235098235098235098")
+ #
+ #bufstr = StringIO()
+ #self.assertRaises(exceptions.ArithmeticError, lambda: bufstr.write(x0))
+ #
+ #bufstr = StringIO()
+ #bufstr.write(x1)
+ #
+ #self.assertEqual("982340823.380238098235098235098235098",
+ # bufstr.getvalue())
+ #
+ #self.assertValid(x0)
+ #self.assertValid(x1)
+
+ def testCommodityPrinting(self):
+ pass
+ #x1 = amount(internalAmount("$982340823.386238098235098235098235098"))
+ #x2 = amount("$982340823.38")
+ #
+ #bufstr = StringIO()
+ #bufstr.write(x1)
+ #
+ #self.assertEqual("$982340823.386238098235098235098235098",
+ # bufstr.getvalue())
+ #
+ #bufstr = StringIO()
+ #bufstr.write((x1 * x2).to_string())
+ #
+ #self.assertEqual("$964993493285024293.18099172508158508135413499124",
+ # bufstr.getvalue())
+ #
+ #bufstr = StringIO()
+ #bufstr.write((x2 * x1).to_string())
+ #
+ #self.assertEqual("$964993493285024293.18", bufstr.getvalue())
+ #
+ #self.assertValid(x1)
+ #self.assertValid(x2)
+
+ def testSerialization(self):
+ pass
+ #x0 = amount()
+ #x1 = amount("$8,192.34")
+ #x2 = amount("8192.34")
+ #x3 = amount("8192.34")
+ #x4 = amount("-8192.34")
+ #x5 = amount(x4)
+ #
+ ## Force x3's pointer to actually be set to null_commodity
+ ##x3.set_commodity(*x3.current_pool.null_commodity)
+ #
+ #buf = ""
+ #storage = StringIO()
+ #self.assertRaises(exceptions.ArithmeticError, lambda: x0.write(storage))
+ #x1.write(storage)
+ #x2.write(storage)
+ #x3.write(storage)
+ #x4.write(storage)
+ #x5.write(storage)
+ #buf = storage.getvalue()
+ #
+ #x1b = amount()
+ #x2b = amount()
+ #x3b = amount()
+ #x4b = amount()
+ #x5b = amount()
+ #
+ #storage = StringIO(buf)
+ #x1b.read(storage)
+ #x2b.read(storage)
+ #x3b.read(storage)
+ #x4b.read(storage)
+ #x5b.read(storage)
+ #
+ #self.assertEqual(x1, x1b)
+ #self.assertEqual(x2, x2b)
+ #self.assertEqual(x3, x3b)
+ #self.assertEqual(x4, x4b)
+ #
+ #ptr = buf.c_str()
+ #
+ #x1c = amount()
+ #x2c = amount()
+ #x3c = amount()
+ #x4c = amount()
+ #x5c = amount()
+ #
+ #x1c.read(ptr)
+ #x2c.read(ptr)
+ #x3c.read(ptr)
+ #x4c.read(ptr)
+ #x5c.read(ptr)
+ #
+ #self.assertEqual(x1, x1b)
+ #self.assertEqual(x2, x2b)
+ #self.assertEqual(x3, x3b)
+ #self.assertEqual(x4, x4b)
+ #
+ #self.assertValid(x1)
+ #self.assertValid(x2)
+ #self.assertValid(x3)
+ #self.assertValid(x4)
+ #self.assertValid(x1b)
+ #self.assertValid(x2b)
+ #self.assertValid(x3b)
+ #self.assertValid(x4b)
+ #self.assertValid(x1c)
+ #self.assertValid(x2c)
+ #self.assertValid(x3c)
+ #self.assertValid(x4c)
+
+
+def suite():
+ return unittest.TestLoader().loadTestsFromTestCase(t_amountTestCase)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/utility/t_times.cc b/test/utility/t_times.cc
new file mode 100644
index 00000000..c2d6fe64
--- /dev/null
+++ b/test/utility/t_times.cc
@@ -0,0 +1,79 @@
+#include "t_times.h"
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(DateTimeTestCase, "utility");
+
+void DateTimeTestCase::setUp() {}
+void DateTimeTestCase::tearDown() {}
+
+void DateTimeTestCase::testConstructors()
+{
+ std::time_t time_t_now = std::time(NULL);
+ struct tm * moment = std::localtime(&time_t_now);
+
+ std::time_t localMoment = std::mktime(moment);
+
+ ptime d0;
+ ptime d1(parse_datetime("1990/01/01"));
+ ptime d3(boost::posix_time::from_time_t(localMoment));
+ ptime d4(parse_datetime("2006/12/25"));
+ //ptime d5(parse_datetime("12/25"));
+ ptime d6(parse_datetime("2006.12.25"));
+ //ptime d7(parse_datetime("12.25"));
+ ptime d8(parse_datetime("2006-12-25"));
+ //ptime d9(parse_datetime("12-25"));
+#if 0
+ ptime d10(parse_datetime("tue"));
+ ptime d11(parse_datetime("tuesday"));
+ ptime d12(parse_datetime("feb"));
+ ptime d13(parse_datetime("february"));
+ ptime d14(parse_datetime("2006"));
+#endif
+ ptime d15(d3);
+
+ assertTrue(d0.is_not_a_date_time());
+ assertFalse(d1.is_not_a_date_time());
+ assertFalse(d4.is_not_a_date_time());
+
+ assertTrue(now > d1);
+ //assertTrue(now <= d3);
+ assertTrue(now > d4);
+
+ assertEqual(d3, d15);
+ assertEqual(d4, d6);
+ assertEqual(d4, d8);
+ //assertEqual(d5, d7);
+ //assertEqual(d5, d9);
+#if 0
+ assertEqual(d10, d11);
+ assertEqual(d12, d13);
+#endif
+
+#if 0
+ assertThrow(parse_datetime("2007/02/29"), datetime_error *);
+ assertThrow(parse_datetime("2007/13/01"), datetime_error *);
+ assertThrow(parse_datetime("2007/00/01"), datetime_error *);
+ assertThrow(parse_datetime("2007/01/00"), datetime_error *);
+ assertThrow(parse_datetime("2007/00/00"), datetime_error *);
+ assertThrow(parse_datetime("2007/05/32"), datetime_error *);
+
+ assertThrow(parse_datetime("2006x/12/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/12x/25"), datetime_error *);
+ //assertThrow(parse_datetime("2006/12/25x"), datetime_error *);
+
+ assertThrow(parse_datetime("feb/12/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/mon/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/12/web"), datetime_error *);
+
+ assertThrow(parse_datetime("12*25"), datetime_error *);
+
+ assertThrow(parse_datetime("tuf"), datetime_error *);
+ assertThrow(parse_datetime("tufsday"), datetime_error *);
+ assertThrow(parse_datetime("fec"), datetime_error *);
+ assertThrow(parse_datetime("fecruary"), datetime_error *);
+ assertThrow(parse_datetime("207x"), datetime_error *);
+ assertThrow(parse_datetime("hello"), datetime_error *);
+
+ interval_t i1;
+ interval_t i2;
+#endif
+}
diff --git a/test/utility/t_times.h b/test/utility/t_times.h
new file mode 100644
index 00000000..5bbadf21
--- /dev/null
+++ b/test/utility/t_times.h
@@ -0,0 +1,28 @@
+#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 &copy);
+ void operator=(const DateTimeTestCase &copy);
+};
+
+#endif /* _T_TIMES_H */
diff --git a/test/utility/t_utils.cc b/test/utility/t_utils.cc
new file mode 100644
index 00000000..eda84a3a
--- /dev/null
+++ b/test/utility/t_utils.cc
@@ -0,0 +1,10 @@
+#include "t_utils.h"
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(UtilitiesTestCase, "utility");
+
+void UtilitiesTestCase::setUp() {}
+void UtilitiesTestCase::tearDown() {}
+
+void UtilitiesTestCase::testConstructors()
+{
+}
diff --git a/test/utility/t_utils.h b/test/utility/t_utils.h
new file mode 100644
index 00000000..97154bae
--- /dev/null
+++ b/test/utility/t_utils.h
@@ -0,0 +1,28 @@
+#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 &copy);
+ void operator=(const UtilitiesTestCase &copy);
+};
+
+#endif /* _T_UTILS_H */
diff --git a/tests/amounts.h b/tests/amounts.h
deleted file mode 100644
index a72e57d2..00000000
--- a/tests/amounts.h
+++ /dev/null
@@ -1,169 +0,0 @@
-#ifndef __TESTAMOUNT_H
-#define __TESTAMOUNT_H
-
-#include <cxxtest/TestSuite.h>
-
-#include <amount.h>
-
-using namespace ledger;
-
-class TestAmount : public CxxTest::TestSuite
-{
-public:
- void testCreateAmountWithoutCommodityFromInteger()
- {
- amount_t a((long int)42);
- TS_ASSERT_EQUALS("", a.commodity().symbol());
- TS_ASSERT_EQUALS("", a.commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a.quantity_string());
- }
-
- void testCreateAmountWithoutCommodity()
- {
- amount_t a("42");
- TS_ASSERT_EQUALS("", a.commodity().symbol());
- TS_ASSERT_EQUALS("", a.commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a.quantity_string());
- }
-
- void testCreateAmountWithPrefixCommodity()
- {
- amount_t *a;
- a = new amount_t("$ 42");
- TS_ASSERT_EQUALS("$", a->commodity().symbol());
- TS_ASSERT_EQUALS("$", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCreateAmountWithPostfixCommodity()
- {
- amount_t *a;
- a = new amount_t("42 GLD");
- TS_ASSERT_EQUALS("GLD", a->commodity().symbol());
- TS_ASSERT_EQUALS("GLD", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCreateAmountWithPrefixCommodityContainingSpace()
- {
- amount_t *a;
- a = new amount_t("\"one dollar\" 42");
- TS_ASSERT_EQUALS("\"one dollar\"", a->commodity().symbol());
- TS_ASSERT_EQUALS("one dollar", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCreateAmountWithPostfixCommodityContainingSpace()
- {
- amount_t *a;
- a = new amount_t("42 \"swedish crowns\"");
- TS_ASSERT_EQUALS("\"swedish crowns\"", a->commodity().symbol());
- TS_ASSERT_EQUALS("swedish crowns", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCreateAmountWithDirectPrefixCommodity()
- {
- amount_t *a;
- a = new amount_t("$42");
- TS_ASSERT_EQUALS("$", a->commodity().symbol());
- TS_ASSERT_EQUALS("$", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCreateAmountWithDirectPostfixCommodity()
- {
- amount_t *a;
- a = new amount_t("42GLD");
- TS_ASSERT_EQUALS("GLD", a->commodity().symbol());
- TS_ASSERT_EQUALS("GLD", a->commodity().base_symbol());
- TS_ASSERT_EQUALS("42", a->quantity_string());
- }
-
- void testCannotCreateAmountWithoutQuantity()
- {
- TS_ASSERT_THROWS(new amount_t("$"), amount_error*);
- }
-
- void testCreateBiiigIntegerAmount()
- {
- amount_t a("12345678901234567890123456789012345678901234567890");
- TS_ASSERT_EQUALS("12345678901234567890123456789012345678901234567890",
- a.quantity_string());
- }
-
- void testCreateBiiigDecimalAmount()
- {
- amount_t a("12345678.901234567890123456789012345678901234567890");
- TS_ASSERT_EQUALS("12345678.901234567890123456789012345678901234567890",
- a.quantity_string());
- }
-
- void testCreateCommodityAnnotatedWithEntry()
- {
- amount_t a("10 AAPL (entry 6)");
- TS_ASSERT_EQUALS("10", a.quantity_string());
- commodity_t c = a.commodity();
- TS_ASSERT_EQUALS("AAPL", c.symbol());
- TS_ASSERT_EQUALS("AAPL", c.base_symbol());
- TS_ASSERT(c.annotated);
- //TODO: check entry annotation
- }
-
- void testCreateCommodityAnnotatedWithEntry2()
- {
- amount_t *a = new amount_t("10 AAPL (entry 6)");
- TS_ASSERT_EQUALS("10", a->quantity_string());
- commodity_t c = a->commodity();
- TS_ASSERT_EQUALS("AAPL", c.symbol());
- TS_ASSERT_EQUALS("AAPL", c.base_symbol());
- TS_ASSERT(c.annotated);
- //TODO: check entry annotation
- }
-
- void testAddTwoAmountsWithoutCommodity()
- {
- amount_t a("6");
- amount_t b("9");
- TS_ASSERT_EQUALS(* new amount_t((long int)15), a+b);
- }
-
- void testAddTwoAmountsWithSameCommodity()
- {
- amount_t a("$ 6");
- amount_t b("$ 9");
- TS_ASSERT_EQUALS(* new amount_t("$ 15"), a+b);
- }
-
- void testCannotAddTwoAmountsWithDifferentCommodities()
- {
- amount_t a("$ 6");
- amount_t b("9 GLD");
- TS_ASSERT_THROWS(a+b, amount_error*);
- }
-
- void testCompareTwoAmountsWithSameCommodity()
- {
- amount_t a("6 SCOX");
- amount_t b("9 SCOX");
- TS_ASSERT(a < b);
- TS_ASSERT(a <= b);
- TS_ASSERT(!(a > b));
- TS_ASSERT(!(a >= b));
- TS_ASSERT(!(a == b));
- }
-
- void testCannotCompareTwoAmountsWithDifferentCommodities()
- {
- amount_t a("$ 6");
- amount_t b("9 GLD");
-
- TS_ASSERT_THROWS(a < b, amount_error*);
- TS_ASSERT_THROWS(a <= b, amount_error*);
- TS_ASSERT_THROWS(a > b, amount_error*);
- TS_ASSERT_THROWS(a >= b, amount_error*);
- TS_ASSERT(!(a == b));
- }
-};
-
-#endif // __TESTAMOUNT_H
diff --git a/tests/baseline/1001 b/tests/baseline/1001
deleted file mode 100644
index f570768a..00000000
--- a/tests/baseline/1001
+++ /dev/null
@@ -1 +0,0 @@
-Error: "tests/cases/1001.dat", line 10: Only one transaction with null amount allowed per entry
diff --git a/tests/baseline/1002 b/tests/baseline/1002
deleted file mode 100644
index 8ca4d8d4..00000000
--- a/tests/baseline/1002
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xgain -20
- Liabilities:MasterCard
diff --git a/tests/baseline/1003 b/tests/baseline/1003
deleted file mode 100644
index 61e03c48..00000000
--- a/tests/baseline/1003
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xtime -20
- Liabilities:MasterCard
diff --git a/tests/baseline/1004 b/tests/baseline/1004
deleted file mode 100644
index dbbfea17..00000000
--- a/tests/baseline/1004
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xopti -20
- Liabilities:MasterCard
diff --git a/tests/baseline/1005 b/tests/baseline/1005
deleted file mode 100644
index 8541a38d..00000000
--- a/tests/baseline/1005
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xgain 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1006 b/tests/baseline/1006
deleted file mode 100644
index 0ea315f9..00000000
--- a/tests/baseline/1006
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xtime 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1007 b/tests/baseline/1007
deleted file mode 100644
index 40f2827a..00000000
--- a/tests/baseline/1007
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- xopti 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1008 b/tests/baseline/1008
deleted file mode 100644
index 385151b2..00000000
--- a/tests/baseline/1008
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xgain $-20.00
- Equity:Options
diff --git a/tests/baseline/1009 b/tests/baseline/1009
deleted file mode 100644
index 127ad02a..00000000
--- a/tests/baseline/1009
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xtime $-20.00
- Equity:Options
diff --git a/tests/baseline/1010 b/tests/baseline/1010
deleted file mode 100644
index e408036b..00000000
--- a/tests/baseline/1010
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xopti $-20.00
- Equity:Options
diff --git a/tests/baseline/1011 b/tests/baseline/1011
deleted file mode 100644
index 9c70db18..00000000
--- a/tests/baseline/1011
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xgain 0
- Equity:Options
diff --git a/tests/baseline/1012 b/tests/baseline/1012
deleted file mode 100644
index 890005ab..00000000
--- a/tests/baseline/1012
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xtime 0
- Equity:Options
diff --git a/tests/baseline/1013 b/tests/baseline/1013
deleted file mode 100644
index 1b7bb71e..00000000
--- a/tests/baseline/1013
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- xopti 0
- Equity:Options
diff --git a/tests/baseline/1014 b/tests/baseline/1014
deleted file mode 100644
index 384133b6..00000000
--- a/tests/baseline/1014
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Capital Gains $-20.00
- Liabilities:MasterCard
diff --git a/tests/baseline/1015 b/tests/baseline/1015
deleted file mode 100644
index 46d5f454..00000000
--- a/tests/baseline/1015
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- time -20
- Liabilities:MasterCard
diff --git a/tests/baseline/1016 b/tests/baseline/1016
deleted file mode 100644
index 7fa39204..00000000
--- a/tests/baseline/1016
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Brokerage:Options -20.00 COMP
- Liabilities:MasterCard
diff --git a/tests/baseline/1017 b/tests/baseline/1017
deleted file mode 100644
index 14b37f8b..00000000
--- a/tests/baseline/1017
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Capital Gains 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1018 b/tests/baseline/1018
deleted file mode 100644
index 9f3761f8..00000000
--- a/tests/baseline/1018
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- time 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1019 b/tests/baseline/1019
deleted file mode 100644
index 10f14f4e..00000000
--- a/tests/baseline/1019
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Brokerage:Options 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1020 b/tests/baseline/1020
deleted file mode 100644
index f1547ca7..00000000
--- a/tests/baseline/1020
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Expenses -20
- Liabilities:MasterCard
diff --git a/tests/baseline/1021 b/tests/baseline/1021
deleted file mode 100644
index 7e3fe64d..00000000
--- a/tests/baseline/1021
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 stock optionx
- Expenses 0
- Liabilities:MasterCard
diff --git a/tests/baseline/1022 b/tests/baseline/1022
deleted file mode 100644
index 953a3c02..00000000
--- a/tests/baseline/1022
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Capital Gains $-20.00
- Equity:Options
diff --git a/tests/baseline/1023 b/tests/baseline/1023
deleted file mode 100644
index 62274097..00000000
--- a/tests/baseline/1023
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- time $-20.00
- Equity:Options
diff --git a/tests/baseline/1024 b/tests/baseline/1024
deleted file mode 100644
index 8272dfd9..00000000
--- a/tests/baseline/1024
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Brokerage:Options -20.00 COMP
- Equity:Options
diff --git a/tests/baseline/1025 b/tests/baseline/1025
deleted file mode 100644
index 52dc8139..00000000
--- a/tests/baseline/1025
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Capital Gains 0
- Equity:Options
diff --git a/tests/baseline/1026 b/tests/baseline/1026
deleted file mode 100644
index 5071338a..00000000
--- a/tests/baseline/1026
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- time 0
- Equity:Options
diff --git a/tests/baseline/1027 b/tests/baseline/1027
deleted file mode 100644
index 31d7c8ab..00000000
--- a/tests/baseline/1027
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Brokerage:Options 45.60 COMP
- Equity:Options
diff --git a/tests/baseline/1028 b/tests/baseline/1028
deleted file mode 100644
index 8272dfd9..00000000
--- a/tests/baseline/1028
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Brokerage:Options -20.00 COMP
- Equity:Options
diff --git a/tests/baseline/1029 b/tests/baseline/1029
deleted file mode 100644
index 31d7c8ab..00000000
--- a/tests/baseline/1029
+++ /dev/null
@@ -1,4 +0,0 @@
-
-2006/10/20 Stock option vesting schedule
- Brokerage:Options 45.60 COMP
- Equity:Options
diff --git a/tests/cases/1001.dat b/tests/cases/1001.dat
deleted file mode 100644
index c781fb4f..00000000
--- a/tests/cases/1001.dat
+++ /dev/null
@@ -1,10 +0,0 @@
-1.00s = 100c
-1.00G = 100s
-
-D 1.00G
-
-2006/03/14 Opening Balances
- Assets:Ebonheart 63869c
- Assets:Tajer 248720c
- Assets:Gruulmorg
- Equity:Gold
diff --git a/tests/cases/1002.dat b/tests/cases/1002.dat
deleted file mode 100644
index 8719b603..00000000
--- a/tests/cases/1002.dat
+++ /dev/null
@@ -1,25 +0,0 @@
-D $1,000.00
-
-A Liabilities:MasterCard
-
-@def foo(x)=x*1000
-
-2006/02/14 Buy
- Broker AAPL 10 @ $200.00 ; this is a little note [2006/10/10]
- Broker AAPL 10 @ $300.00
- Bank ; this is a comment
-
-2006/02/14 Sell
- Bank $2000.00 + $500.00
- Broker AAPL -5 [2005/10/20] {$200.0015} @ $500.00
- Capital Gains $-1500.00
-
-2005/10/20 Stock option vesting schedule
- Brokerage:Options (1.00 COMP {$10.00}*min((([2006/08/20]-[2005/10/20])/3600/24)*0.15, 5000))
- Equity:Options
-
-P 2006/02/27 00:00:00 COMP $15.00
-
-;2005/10/20 Stock option vesting schedule
-; Brokerage:Time (1+@now)
-; Equity:Time
diff --git a/tests/cases/1030.dat b/tests/cases/1030.dat
deleted file mode 100644
index 60fcac1c..00000000
--- a/tests/cases/1030.dat
+++ /dev/null
@@ -1,24 +0,0 @@
-2006/03/01 Basis
- Assets:Pool $1000
- (Shares) 1000 shares {$1.00}
- Equity
-
-P 2006/03/01 shares $1.00
-
-2006/03/10 Purchase
- (Payable:You) -500 shares {$1}
- (Shares) -500 shares
- Assets:Investment $500
- Income:Investments $-500
-
-2006/03/16 Growth
- Assets:Pool $500
- Income:Capital Gains
-
-P 2006/03/16 shares $1.50
-
-2006/03/16 Cash out
- (Payable:You) 250 shares {$1}
- (Shares) 250 shares
- Expenses:Investors
- Assets (- valueof({1 shares}) * 250)
diff --git a/tests/cases/1032.dat b/tests/cases/1032.dat
deleted file mode 100644
index 1b103f1d..00000000
--- a/tests/cases/1032.dat
+++ /dev/null
@@ -1,834 +0,0 @@
-i 2003/10/06 15:21:00 EDG fp_conv
-o 2003/10/06 15:47:53 retrieved documents from ACM and the Web
-i 2003/10/08 16:25:08 EDG fp_conv
-o 2003/10/08 17:10:50 read Steele document; need to print and implement
-i 2003/10/18 14:54:34 EDG fp_conv
-o 2003/10/18 16:56:59
-i 2003/10/18 23:50:34 EDG fp_conv
-o 2003/10/19 01:08:12
-i 2003/10/19 10:54:33 EDG fp_conv
-o 2003/10/19 12:41:56
-i 2003/10/19 16:21:07 EDG fp_conv
-o 2003/10/19 18:29:39
-i 2003/10/21 14:54:10 EDG fp_conv
-o 2003/10/21 18:07:07
-i 2003/10/21 22:44:17 EDG fp_conv
-o 2003/10/21 23:55:57
-i 2003/10/22 22:26:53 EDG fp_conv
-o 2003/10/22 23:22:49
-i 2003/10/23 02:44:00 EDG fp_conv
-o 2003/10/23 03:34:00
-i 2003/10/23 16:12:27 EDG fp_conv
-o 2003/10/23 17:39:08
-i 2003/10/26 10:32:16 ForumJobs Meeting
-o 2003/10/26 15:59:28
-i 2003/10/26 17:26:23 ForumJobs Meeting
-o 2003/10/26 17:57:52
-i 2003/10/27 16:02:10 EDG fp_conv
-o 2003/10/27 17:33:53
-i 2003/10/27 22:38:57 EDG fp_conv
-o 2003/10/28 23:37:51 Steele is working in C, with fgmp
-i 2003/10/28 12:13:46 EDG fp_conv
-o 2003/10/28 12:27:31 sought documents relating to MP math
-i 2003/10/28 16:14:41 EDG fp_conv
-o 2003/10/28 18:32:44 still need to implement mul/div/mod
-i 2003/10/29 22:18:23 EDG fp_conv
-o 2003/10/29 23:38:07
-i 2003/10/30 16:39:19 EDG fp_conv
-o 2003/10/30 17:18:07
-i 2003/10/30 23:33:14 EDG fp_conv
-o 2003/10/31 01:21:18
-i 2003/10/31 13:16:38 EDG fp_conv
-o 2003/10/31 15:01:32
-i 2003/10/31 16:49:51 EDG fp_conv
-o 2003/10/31 17:26:45
-i 2003/10/31 23:15:10 EDG fp_conv
-o 2003/11/01 00:48:11
-i 2003/11/01 12:50:49 EDG fp_conv
-o 2003/11/01 14:01:35
-i 2003/11/01 18:53:48 EDG fp_conv
-o 2003/11/01 19:16:41
-i 2003/11/02 21:50:36 EDG fp_conv
-o 2003/11/03 00:05:10
-i 2003/11/03 19:30:48 EDG fp_conv
-o 2003/11/03 21:44:02
-i 2003/11/04 19:55:44 EDG fp_conv
-o 2003/11/04 20:54:24
-i 2003/11/05 15:36:45 EDG fp_conv
-o 2003/11/05 18:35:36
-i 2003/11/06 16:23:41 EDG fp_conv
-o 2003/11/06 16:37:04
-i 2003/11/06 17:23:27 EDG fp_conv
-o 2003/11/06 17:37:22
-i 2003/11/07 00:02:44 EDG fp_conv
-o 2003/11/07 01:44:34
-i 2003/11/07 14:52:46 EDG fp_conv
-o 2003/11/07 15:07:55
-i 2003/11/07 17:16:59 EDG fp_conv
-o 2003/11/07 18:01:49
-i 2003/11/08 16:47:41 EDG fp_conv
-o 2003/11/08 17:25:38
-i 2003/11/09 15:25:01 EDG fp_conv
-o 2003/11/09 15:49:55
-i 2003/11/10 17:54:44 EDG fp_conv
-o 2003/11/10 18:43:49
-i 2003/11/11 15:02:51 EDG fp_conv
-o 2003/11/11 15:23:49
-i 2003/11/13 20:37:34 EDG fp_conv
-o 2003/11/13 21:24:47
-i 2003/11/14 01:23:47 EDG fp_conv
-o 2003/11/14 02:58:15
-i 2003/11/16 19:43:32 EDG fp_conv
-o 2003/11/16 20:13:59
-i 2003/11/16 21:37:30 EDG fp_conv
-o 2003/11/16 23:32:12
-i 2003/11/16 23:53:07 EDG fp_conv
-o 2003/11/17 00:10:06
-i 2003/11/19 01:14:33 EDG fp_conv
-o 2003/11/19 02:29:34
-i 2003/11/19 14:54:48 EDG fp_conv
-o 2003/11/19 18:27:36
-i 2003/11/19 22:49:09 EDG fp_conv
-o 2003/11/19 23:42:47
-i 2003/11/19 23:53:56 EDG fp_conv
-o 2003/11/20 00:22:53
-i 2003/11/23 00:27:28 EDG fp_conv
-o 2003/11/23 02:36:37
-i 2003/11/23 14:24:29 EDG fp_conv
-o 2003/11/23 14:46:21
-i 2003/11/23 15:23:12 EDG fp_conv
-o 2003/11/23 16:24:58
-i 2003/11/24 19:04:26 EDG fp_conv
-o 2003/11/24 20:40:45
-i 2003/11/24 21:13:32 EDG fp_conv
-o 2003/11/24 22:50:26
-i 2003/11/25 16:04:57 EDG fp_conv
-o 2003/11/25 19:16:07
-i 2003/11/25 20:01:32 EDG fp_conv
-o 2003/11/25 20:20:37
-i 2003/11/25 22:03:56 EDG fp_conv
-o 2003/11/25 22:32:45
-i 2003/11/30 18:45:02 EDG fp_conv
-o 2003/11/30 19:45:58
-i 2003/11/30 21:49:24 EDG fp_conv
-o 2003/11/30 22:36:42
-i 2003/12/03 15:48:03 EDG fp_conv
-o 2003/12/03 17:07:22
-i 2003/12/04 14:46:53 EDG fp_conv
-o 2003/12/04 16:05:17
-i 2003/12/07 16:00:38 ForumJobs Meeting
-o 2003/12/07 19:00:27
-i 2003/12/08 00:41:29 EDG fp_conv
-o 2003/12/08 01:18:18
-i 2003/12/08 14:12:19 EDG fp_conv
-o 2003/12/08 14:57:03
-i 2003/12/08 16:14:25 EDG fp_conv
-o 2003/12/08 17:37:53
-i 2003/12/08 22:11:16 EDG fp_conv
-o 2003/12/09 02:18:03
-i 2003/12/09 16:19:26 ForumJobs
-o 2003/12/09 18:41:55
-i 2003/12/09 19:46:55 ForumJobs
-o 2003/12/09 20:12:32
-i 2003/12/09 21:25:34 ForumJobs
-o 2003/12/09 23:23:50
-i 2003/12/09 23:48:46 EDG fp_conv
-o 2003/12/10 03:17:33
-i 2003/12/10 13:50:03 EDG fp_conv
-o 2003/12/10 14:30:31
-i 2003/12/10 16:50:40 EDG fp_conv
-o 2003/12/11 05:12:28
-i 2003/12/11 14:31:30 EDG fp_conv
-o 2003/12/11 18:17:08
-i 2003/12/12 00:56:19 EDG fp_conv
-o 2003/12/12 02:38:32
-i 2003/12/12 16:42:33 EDG fp_conv
-o 2003/12/12 20:13:46
-i 2003/12/12 22:09:46 EDG fp_conv
-o 2003/12/13 01:26:52
-i 2003/12/14 16:00:43 ForumJobs Meeting
-o 2003/12/14 18:44:38
-i 2003/12/14 20:12:59 EDG fp_conv
-o 2003/12/15 02:49:53
-i 2003/12/15 15:21:19 EDG fp_conv
-o 2003/12/15 17:59:45
-i 2003/12/15 19:06:10 EDG fp_conv
-o 2003/12/16 00:12:14
-i 2003/12/16 00:12:15 ForumJobs
-o 2003/12/16 01:16:51
-i 2003/12/16 16:43:32 EDG fp_conv
-o 2003/12/16 18:44:46
-i 2003/12/16 19:54:15 EDG fp_conv
-o 2003/12/17 01:08:19
-i 2003/12/17 01:34:12 ForumJobs
-o 2003/12/17 01:51:34
-i 2003/12/17 16:56:39 EDG fp_conv
-o 2003/12/17 19:15:58
-i 2003/12/17 22:49:59 EDG fp_conv
-o 2003/12/18 00:47:10
-i 2003/12/18 16:53:31 ForumJobs
-o 2003/12/18 18:35:43
-i 2003/12/19 18:12:39 ForumJobs
-o 2003/12/19 20:01:01
-i 2003/12/23 17:30:29 ForumJobs
-o 2003/12/23 18:10:41
-i 2004/01/13 12:32:55 ForumJobs
-o 2004/01/13 12:53:55
-i 2004/01/14 14:23:47 EDG fp_conv
-o 2004/01/14 19:25:42
-i 2004/01/15 17:20:01 EDG fp_conv
-o 2004/01/15 18:40:34
-i 2004/01/16 12:50:26 EDG fp_conv
-o 2004/01/16 18:39:45
-i 2004/01/16 19:23:09 EDG fp_conv
-o 2004/01/16 20:41:14
-i 2004/01/19 12:48:57 EDG fp_conv
-o 2004/01/19 15:18:38
-i 2004/01/20 16:07:50 ForumJobs
-o 2004/01/20 19:18:04
-i 2004/01/21 13:18:04 EDG fp_conv
-o 2004/01/21 18:18:04
-i 2004/01/22 13:39:27 EDG fp_conv
-o 2004/01/22 18:31:03
-i 2004/01/22 19:12:42 EDG fp_conv
-o 2004/01/22 20:48:41
-i 2004/01/23 12:58:41 EDG fp_conv
-o 2004/01/23 15:27:58
-i 2004/01/23 16:00:00 ForumJobs
-o 2004/01/23 19:15:00
-i 2004/01/23 21:30:26 EDG fp_conv
-o 2004/01/23 23:45:56
-i 2004/01/25 17:19:42 ForumJobs
-o 2004/01/25 18:22:37
-i 2004/01/26 22:34:31 ForumJobs
-o 2004/01/26 23:35:23
-i 2004/01/27 12:53:42 EDG fp_conv
-o 2004/01/27 13:23:15
-i 2004/01/27 19:42:50 EDG fp_conv
-o 2004/01/27 19:57:28
-i 2004/01/27 22:08:53 ForumJobs
-o 2004/01/27 22:44:40
-i 2004/01/27 23:14:41 EDG fp_conv
-o 2004/01/27 23:48:05
-i 2004/01/28 00:00:27 ForumJobs
-o 2004/01/28 00:39:21
-i 2004/01/28 17:04:22 ForumJobs
-o 2004/01/28 17:34:31
-i 2004/01/29 14:07:44 ForumJobs
-o 2004/01/29 16:07:04
-i 2004/01/29 17:15:58 ForumJobs
-o 2004/01/29 18:55:40
-i 2004/01/29 22:11:41 ForumJobs
-o 2004/01/29 23:31:41
-i 2004/01/30 15:56:02 ForumJobs
-o 2004/01/30 17:54:06
-i 2004/01/30 20:43:00 ForumJobs
-o 2004/01/30 21:56:30
-i 2004/01/30 22:16:09 ForumJobs
-o 2004/01/30 22:28:35
-i 2004/02/03 17:19:26 ForumJobs
-o 2004/02/03 19:24:08
-i 2004/02/08 14:42:44 ForumJobs
-o 2004/02/08 18:07:07
-i 2004/02/10 18:05:54 EDG fp_conv
-o 2004/02/10 19:10:24
-i 2004/02/10 19:10:25 ForumJobs
-o 2004/02/10 19:16:23
-i 2004/02/11 18:04:55 ForumJobs
-o 2004/02/11 19:25:12
-i 2004/02/11 21:42:52 ForumJobs
-o 2004/02/12 01:16:28
-i 2004/02/12 16:01:50 ForumJobs
-o 2004/02/12 16:45:17
-i 2004/02/17 15:36:11 ForumJobs
-o 2004/02/17 17:37:50
-i 2004/02/17 22:20:06 ForumJobs
-o 2004/02/17 23:20:18
-i 2004/02/20 18:00:44 EDG fp_conv
-o 2004/02/20 19:21:42
-i 2004/02/23 21:16:24 EDG fp_conv
-o 2004/02/24 00:01:01
-i 2004/02/24 21:29:21 EDG fp_conv
-o 2004/02/24 21:53:23
-i 2004/02/25 10:55:19 EDG fp_conv
-o 2004/02/25 13:30:24
-i 2004/02/27 13:57:39 EDG fp_conv
-o 2004/02/27 15:49:31
-i 2004/02/27 16:18:22 EDG fp_conv
-o 2004/02/27 17:47:34
-i 2004/03/02 11:45:36 ForumJobs
-o 2004/03/02 12:45:38
-i 2004/03/02 12:45:38 EDG fp_conv
-o 2004/03/02 18:01:03
-i 2004/03/02 21:03:44 ForumJobs
-o 2004/03/02 21:39:25
-i 2004/03/03 12:05:24 EDG fp_conv
-o 2004/03/03 17:47:43
-i 2004/03/03 20:34:26 EDG fp_conv
-o 2004/03/03 22:04:50
-i 2004/03/04 19:38:23 EDG fp_conv
-o 2004/03/04 21:08:57
-i 2004/03/07 16:53:41 ForumJobs
-o 2004/03/07 17:45:30
-i 2004/03/09 14:24:33 ForumJobs
-o 2004/03/09 15:07:53
-i 2004/03/09 15:07:55 EDG fp_conv
-o 2004/03/09 17:53:35
-i 2004/03/22 23:21:08 ForumJobs
-o 2004/03/23 00:09:32
-i 2004/03/23 15:45:28 ForumJobs
-o 2004/03/23 16:38:24
-i 2004/03/30 23:30:17 ForumJobs
-o 2004/03/31 01:31:43
-i 2004/04/02 17:49:46 ForumJobs
-o 2004/04/02 21:02:43
-i 2004/04/03 20:33:51 ForumJobs
-o 2004/04/03 22:49:54
-i 2004/04/04 18:46:00 ForumJobs
-o 2004/04/04 19:03:09
-i 2004/04/05 20:21:23 ForumJobs
-o 2004/04/05 20:51:24
-i 2004/04/06 15:32:37 ForumJobs
-o 2004/04/06 16:40:53
-i 2004/04/08 12:54:44 ForumJobs
-o 2004/04/08 13:27:18
-i 2004/04/08 14:50:39 ForumJobs
-o 2004/04/08 15:39:51
-i 2004/04/08 16:05:52 ForumJobs
-o 2004/04/08 17:16:33
-i 2004/04/08 23:46:34 ForumJobs
-o 2004/04/09 00:57:38
-i 2004/04/10 13:00:57 ForumJobs
-o 2004/04/10 14:53:01
-i 2004/04/12 16:18:02 ForumJobs
-o 2004/04/12 17:34:57
-i 2004/04/12 23:39:20 ForumJobs
-o 2004/04/13 00:32:45
-i 2004/04/14 12:23:48 ForumJobs
-o 2004/04/14 12:50:42
-i 2004/04/15 16:48:51 ForumJobs
-o 2004/04/15 17:55:10 invoice #1
-i 2004/04/26 12:34:11 ForumJobs
-o 2004/04/26 13:04:54
-i 2004/05/06 14:00:28 ForumJobs
-o 2004/05/06 14:38:53
-i 2004/07/27 14:11:31 Borland
-o 2004/07/27 14:35:56 discussed fake symbol consolidation schemes
-i 2004/07/29 17:54:42 Borland
-o 2004/07/29 18:32:50 discussed hashing issues in fake ns sym lookup
-i 2004/07/30 12:41:33 Borland
-o 2004/07/30 12:57:16 answered namespace lookup questions
-i 2005/04/04 13:03:18 3dex oss
-o 2005/04/04 14:33:18
-i 2005/04/18 11:03:18 3dex oss
-o 2005/04/18 12:36:18
-i 2005/04/18 14:03:18 3dex oss
-o 2005/04/18 16:57:56
-i 2005/05/10 13:45:16 EDG dr
-o 2005/05/10 15:30:52 10 issues checked
-i 2005/05/12 14:32:16 EDG dr
-o 2005/05/12 18:12:55
-i 2005/05/13 11:20:51 EDG dr
-o 2005/05/13 12:41:03
-i 2005/05/13 15:50:54 EDG dr
-o 2005/05/13 16:13:23 break
-i 2005/05/13 16:43:59 EDG dr
-o 2005/05/13 17:37:44
-i 2005/05/16 12:30:37 EDG dr
-o 2005/05/16 13:02:55
-i 2005/05/16 16:02:11 EDG dr
-o 2005/05/16 16:36:20
-i 2005/05/17 18:33:14 EDG dr
-o 2005/05/17 18:51:02
-i 2005/05/18 14:32:08 EDG dr
-o 2005/05/18 15:07:43
-i 2005/05/20 20:02:55 EDG dr
-o 2005/05/20 21:21:14
-i 2005/05/20 21:42:16 EDG dr
-o 2005/05/20 21:52:59
-i 2005/05/21 15:39:59 EDG dr
-o 2005/05/21 16:33:27
-i 2005/05/23 20:48:20 EDG dr
-o 2005/05/23 22:17:08
-i 2005/05/24 13:08:29 EDG dr
-o 2005/05/24 15:25:06
-i 2005/06/28 15:08:29 3dex security
-o 2005/06/28 18:44:13
-i 2005/06/28 22:38:57 3dex ledger
-o 2005/06/28 23:51:31
-i 2005/06/29 16:11:41 3dex ledger
-o 2005/06/29 19:46:04
-i 2005/07/01 15:03:35 3dex ledger
-o 2005/07/01 20:41:08
-i 2005/07/02 14:00:35 3dex ledger
-o 2005/07/02 18:00:35
-i 2005/07/03 13:30:35 3dex ledger
-o 2005/07/03 17:00:35
-i 2005/07/04 14:30:35 3dex ledger
-o 2005/07/04 19:00:35
-i 2005/07/04 20:44:35 3dex ledger
-o 2005/07/04 22:01:35
-i 2005/07/05 17:20:29 3dex ledger
-o 2005/07/05 22:58:35
-i 2005/07/06 23:43:14 3dex ledger
-o 2005/07/07 03:09:01
-i 2005/07/07 19:43:14 3dex ledger
-o 2005/07/07 21:09:01
-i 2005/07/09 13:55:22 3dex ledger
-o 2005/07/09 14:34:29
-i 2005/07/09 15:08:05 3dex ledger
-o 2005/07/09 17:46:15
-i 2005/07/12 21:24:03 3dex ledger
-o 2005/07/13 02:00:03
-i 2005/07/14 21:24:03 3dex ledger
-o 2005/07/14 21:59:40
-i 2005/07/16 22:03:57 3dex ledger
-o 2005/07/17 00:34:07
-i 2005/07/17 10:53:38 3dex ledger
-o 2005/07/17 11:56:49
-i 2005/08/10 15:45:54 3dex soap
-o 2005/08/10 16:12:02
-i 2005/08/11 15:04:23 3dex soap
-o 2005/08/11 16:07:35
-i 2005/08/15 15:07:18 3dex soap
-o 2005/08/15 15:35:18
-i 2005/08/15 15:36:14 3dex soap
-o 2005/08/15 16:18:41
-i 2005/08/17 16:21:10 3dex soap
-o 2005/08/17 16:53:37
-i 2005/08/18 14:01:46 3dex soap
-o 2005/08/18 18:33:12
-i 2005/08/25 13:30:44 3dex soap
-o 2005/08/25 15:38:09
-i 2005/08/25 16:52:18 3dex soap
-o 2005/08/25 17:54:52
-i 2005/08/25 20:19:34 3dex soap
-o 2005/08/25 21:32:07
-i 2005/08/28 18:06:40 3dex soap
-o 2005/08/28 18:36:55
-i 2005/08/28 19:34:56 3dex soap
-o 2005/08/28 19:55:25
-i 2005/10/22 00:55:10 3dex video
-o 2005/10/22 01:52:58
-i 2005/10/22 22:00:59 3dex video
-o 2005/10/22 22:58:30
-i 2005/10/25 13:00:00 MOW meeting
-o 2005/10/25 17:00:00
-i 2005/10/26 10:00:00 MOW meeting
-o 2005/10/26 14:00:00
-i 2005/10/26 18:51:52 MOW planning
-o 2005/10/26 18:57:43
-i 2005/10/27 20:34:28 MOW website
-o 2005/10/27 21:40:28
-i 2005/10/28 22:04:28 MOW website
-o 2005/10/28 22:50:28
-i 2005/10/29 23:04:28 MOW planning
-o 2005/10/29 23:40:28
-i 2005/10/30 22:18:28 MOW website
-o 2005/10/31 01:22:28
-i 2005/10/31 05:15:29 3dex video
-o 2005/10/31 05:55:34
-i 2005/10/31 15:51:55 3dex video
-o 2005/10/31 17:37:09
-i 2005/11/01 01:15:34 MOW website
-o 2005/11/01 02:34:55
-i 2005/11/01 18:04:47 MOW website
-o 2005/11/01 18:35:25
-i 2005/11/01 20:39:42 MOW website
-o 2005/11/01 23:00:08
-i 2005/11/02 00:26:09 MOW website
-o 2005/11/02 04:14:33
-i 2005/11/02 17:07:40 MOW website
-o 2005/11/02 18:13:49
-i 2005/11/02 22:09:53 MOW website
-o 2005/11/02 22:41:31
-i 2005/11/03 00:11:02 MOW website
-o 2005/11/03 04:52:25
-i 2005/11/03 04:55:38 3dex video
-o 2005/11/03 06:22:42
-i 2005/11/03 19:45:00 MOW website
-o 2005/11/03 22:53:12
-i 2005/11/04 00:16:33 MOW website
-o 2005/11/04 00:43:07
-i 2005/11/04 02:01:23 MOW website
-o 2005/11/04 04:31:25
-i 2005/11/04 14:11:55 MOW website
-o 2005/11/04 16:48:30
-i 2005/11/04 16:59:06 MOW website
-o 2005/11/04 19:54:46
-i 2005/11/05 22:29:03 MOW website
-o 2005/11/06 04:53:57
-i 2005/11/07 02:13:36 MOW website
-o 2005/11/07 04:38:12
-i 2005/11/07 20:29:07 MOW website
-o 2005/11/07 23:03:45
-i 2005/11/07 23:53:46 MOW website
-o 2005/11/08 04:35:27
-i 2005/11/08 16:02:23 MOW website
-o 2005/11/08 17:26:28
-i 2005/11/09 00:25:44 MOW website
-o 2005/11/09 03:35:00
-i 2005/11/09 14:28:03 MOW website
-o 2005/11/09 14:49:27
-i 2005/11/09 17:13:19 MOW website
-o 2005/11/09 17:29:51
-i 2005/11/10 00:13:33 MOW website
-o 2005/11/10 03:08:40
-i 2005/11/10 15:22:12 MOW website
-o 2005/11/10 16:33:16
-i 2005/11/10 19:10:44 MOW website
-o 2005/11/10 22:19:44
-i 2005/11/11 01:00:54 MOW website
-o 2005/11/11 01:31:39
-i 2005/11/11 01:50:07 MOW website
-o 2005/11/11 03:13:36
-i 2005/11/11 03:35:18 MOW website
-o 2005/11/11 05:32:27
-i 2005/11/13 20:07:14 MOW website
-o 2005/11/13 21:14:05
-i 2005/11/13 22:02:04 MOW website
-o 2005/11/14 01:34:44
-i 2005/11/14 23:35:33 MOW website
-o 2005/11/15 12:25:00
-i 2005/11/15 01:31:53 MOW website
-o 2005/11/15 01:54:55
-i 2005/11/15 16:58:26 MOW website
-o 2005/11/15 18:17:43
-i 2005/11/15 21:16:00 MOW website
-o 2005/11/15 22:57:24
-i 2005/11/15 23:52:00 MOW website
-o 2005/11/16 07:08:14
-i 2005/11/16 20:06:33 MOW website
-o 2005/11/16 23:00:45
-i 2005/11/17 00:15:29 MOW website
-o 2005/11/17 09:39:11
-i 2005/11/17 15:33:03 MOW website: Polishing MainIndex.aspx
-o 2005/11/17 17:12:52
-i 2005/11/17 20:40:53 MOW website: Fixing the display of StoryTable.ascx
-o 2005/11/18 00:14:58
-i 2005/11/18 00:15:19 MOW website: Improve Asset class
-o 2005/11/18 03:42:35
-i 2005/11/19 19:04:00 MOW website: Fix MainIndex page
-o 2005/11/19 22:30:14
-i 2005/11/19 22:56:38 MOW website: Finalize HTML for AuthorIndex and Profile
-o 2005/11/20 07:49:00
-i 2005/11/20 19:02:48 MOW website: Resolving final issues
-o 2005/11/20 23:58:01
-i 2005/11/22 00:04:47 MOW website: MainIndex - Change header display and fixed alignment
-o 2005/11/22 02:54:14
-i 2005/11/22 02:54:14 MOW website: AuthorProfile - Fix alignment issues created by MainIndex fixes
-o 2005/11/22 03:08:13
-i 2005/11/22 03:08:13 MOW website: Breadcrumb navigation
-o 2005/11/22 04:13:01
-i 2005/11/22 04:13:01 MOW website: CreateTheme - Fixing style
-o 2005/11/22 04:45:41
-i 2005/11/22 04:45:41 MOW website: Confirming deletion
-o 2005/11/22 05:14:26
-i 2005/11/22 05:14:29 MOW website: Yellow message boxes
-o 2005/11/22 06:17:15
-i 2005/11/22 06:47:00 MOW website: MainIndex - Testing and fixing HTML
-o 2005/11/22 08:20:19
-i 2005/11/22 17:41:19 MOW website: MainIndex - Use PostedDate in Themes for sorting
-o 2005/11/22 18:14:23
-i 2005/11/22 18:49:32 MOW website: MainIndex - Use PostedDate in Themes for sorting
-o 2005/11/22 20:01:52
-i 2005/11/23 00:04:07 MOW website: AssetList - Finishing uploads
-o 2005/11/23 01:13:28
-i 2005/11/24 16:49:19 MOW website: AssetList - Support ordering
-o 2005/11/24 20:20:23
-i 2005/11/24 20:50:28 MOW website: AssetList - Finishing uploads
-o 2005/11/24 22:13:13
-i 2005/11/27 19:33:05 MOW website: StoryDetails - Adding other tables
-o 2005/11/27 21:15:26
-i 2005/11/28 20:27:07 MOW website: StoryDetails - Adding other tables
-o 2005/11/28 21:17:52
-i 2005/11/28 21:58:54 MOW website: StoryDetails - Adding other tables
-o 2005/11/29 00:49:57
-i 2005/11/29 02:16:10 MOW website: Use field validators again
-o 2005/11/29 03:20:58
-i 2005/11/29 04:09:57 MOW website: Use field validators again
-o 2005/11/29 04:35:41
-i 2005/11/30 00:08:28 MOW website: AddedStories - The main added story list
-o 2005/11/30 01:00:32
-i 2005/11/30 20:58:15 MOW website: AddedStories - The main added story list
-o 2005/11/30 22:01:42
-i 2005/11/30 22:57:15 MOW website: AddedStories - The main added story list
-o 2005/12/01 03:02:46
-i 2005/12/01 20:32:47 MOW website: AddedStories - The main added story list
-o 2005/12/01 21:18:13
-i 2005/12/01 21:18:27 MOW website: MainIndex - Further corrections using latest HTML
-o 2005/12/01 21:55:20
-i 2005/12/01 22:55:49 MOW website: MainIndex - Further corrections using latest HTML
-o 2005/12/02 03:21:50
-i 2005/12/02 12:19:06 MOW website: BookDescription
-o 2005/12/02 13:27:17
-i 2005/12/02 13:27:22 MOW website: Cleanup
-o 2005/12/02 17:35:32
-i 2005/12/05 17:50:37 MOW website: Cleanup
-o 2005/12/05 17:52:33
-i 2005/12/05 18:44:48 MOW website: Cleanup
-o 2005/12/05 22:13:06
-i 2005/12/05 22:29:40 MOW website: Cleanup
-o 2005/12/06 01:00:03
-i 2005/12/06 01:38:51 MOW website: Cleanup
-o 2005/12/06 02:30:04
-i 2005/12/06 18:44:24 MOW website: Cleanup
-o 2005/12/06 20:00:21
-i 2005/12/06 21:00:03 MOW website: Cleanup
-o 2005/12/07 00:44:28
-i 2005/12/07 00:44:46 MOW website: AuthorProfile - Support for CommLanguage and Passwords
-o 2005/12/07 02:10:41
-i 2005/12/07 02:11:11 MOW website: ShowImage - Make Popup size based on Image size
-o 2005/12/07 02:35:37
-i 2005/12/07 02:41:14 MOW website: ShowImage - Make Popup size based on Image size
-o 2005/12/07 03:02:45
-i 2005/12/07 04:22:17 MOW website: ShowImage - Make Popup size based on Image size
-o 2005/12/07 06:00:31
-i 2005/12/07 06:00:45 MOW website: AuthorIndex - Fixes for the Cleanup
-o 2005/12/07 06:31:09
-i 2005/12/07 10:10:21 MOW website: AddedStories - Add support for searching by author
-o 2005/12/07 11:37:51
-i 2005/12/07 12:55:55 MOW planning
-o 2005/12/07 13:26:03
-i 2005/12/07 13:26:19 MOW website: Cleanup
-o 2005/12/07 14:20:32
-i 2005/12/07 15:13:21 MOW website: Cleanup
-o 2005/12/07 15:46:54
-i 2005/12/07 17:52:33 MOW website: Cleanup
-o 2005/12/07 18:36:52
-i 2005/12/08 10:31:32 MOW website: Cleanup
-o 2005/12/08 16:28:12
-i 2005/12/08 20:37:50 MOW website: Cleanup
-o 2005/12/08 22:38:42
-i 2005/12/09 13:44:36 MOW website: StoryDetails - Split into multiple pages
-o 2005/12/09 14:09:44
-i 2005/12/11 14:46:31 MOW website: StoryDetails - Split into multiple pages
-o 2005/12/11 16:09:49
-i 2005/12/12 11:27:15 MOW website: StoryDetails - Split into multiple pages
-o 2005/12/12 14:39:05
-i 2005/12/12 14:58:15 MOW website: StoryDetails - Split into multiple pages
-o 2005/12/12 17:06:12
-i 2005/12/12 17:06:19 MOW website: Advertisements
-o 2005/12/12 18:22:28
-i 2005/12/12 19:07:13 MOW website: Advertisements
-o 2005/12/12 21:47:22
-i 2005/12/13 17:05:38 MOW website: Events
-o 2005/12/13 17:54:49
-i 2005/12/13 19:08:43 MOW website: Events
-o 2005/12/13 21:43:52
-i 2005/12/14 15:35:08 MOW website: Events
-o 2005/12/14 16:30:54
-i 2005/12/15 13:01:22 MOW website: Events
-o 2005/12/15 14:41:30
-i 2005/12/15 17:25:51 MOW website: Events
-o 2005/12/15 18:07:43
-i 2005/12/16 08:19:13 MOW website: Events
-o 2005/12/16 10:51:19
-i 2005/12/19 14:32:21 MOW website: Bugs
-o 2005/12/19 18:17:29
-i 2005/12/19 19:52:21 MOW website: Events
-o 2005/12/19 22:01:36
-i 2005/12/21 18:52:02 MOW website: TakeAction
-o 2005/12/21 21:30:58
-i 2005/12/29 22:35:56 MOW website: TakeAction
-o 2005/12/29 23:26:52
-i 2005/12/30 22:51:30 MOW website: Flags
-o 2005/12/31 00:02:40
-i 2006/01/02 19:12:34 MOW website: Communication
-o 2006/01/02 19:58:53
-i 2006/01/05 17:53:58 MOW website: Schedule
-o 2006/01/05 18:30:02
-i 2006/01/06 00:08:19 MOW website: Cleanup
-o 2006/01/06 01:36:11
-i 2006/01/07 17:25:54 MOW website: Cleanup
-o 2006/01/07 19:30:29
-i 2006/01/07 22:05:33 MOW website: Cleanup
-o 2006/01/08 00:45:18
-i 2006/01/08 15:36:25 MOW website: Cleanup
-o 2006/01/08 16:41:19
-i 2006/01/08 18:04:57 MOW website: Cleanup
-o 2006/01/08 20:03:15
-i 2006/01/08 20:50:43 MOW website: Cleanup
-o 2006/01/08 22:12:04
-i 2006/01/08 22:12:09 sina
-o 2006/01/08 23:19:16
-i 2006/01/08 23:19:17 MOW website: Cleanup
-o 2006/01/09 01:01:51
-i 2006/01/09 14:46:53 MOW website: Cleanup
-o 2006/01/09 17:19:53
-i 2006/01/09 18:19:54 MOW website: Cleanup
-o 2006/01/09 19:35:47
-i 2006/01/12 14:50:26 MOW website: Cleanup
-o 2006/01/12 17:34:41
-i 2006/01/12 19:59:47 MOW website: Cleanup
-o 2006/01/12 23:33:20
-i 2006/01/13 15:32:37 MOW website: Cleanup
-o 2006/01/13 16:03:19
-i 2006/01/14 18:50:12 sina
-o 2006/01/14 19:22:54
-i 2006/01/15 01:14:21 sina
-o 2006/01/15 01:50:04
-i 2006/01/15 02:21:13 MOW website: PressReleases
-o 2006/01/15 03:11:35
-i 2006/01/16 02:25:45 sina
-o 2006/01/16 02:59:01
-i 2006/01/16 18:08:28 MOW planning
-o 2006/01/16 18:21:21
-i 2006/01/16 21:43:57 sina
-o 2006/01/16 22:57:09
-i 2006/01/17 00:23:05 sina
-o 2006/01/17 02:51:55
-i 2006/01/17 18:01:54 sina
-o 2006/01/17 18:22:33
-i 2006/01/17 19:00:48 sina
-o 2006/01/17 19:19:36
-i 2006/01/17 19:34:10 sina
-o 2006/01/17 19:50:48
-i 2006/01/17 19:53:38 MOW website: v11
-o 2006/01/17 21:09:27
-i 2006/01/17 21:33:29 sina
-o 2006/01/17 21:55:42
-i 2006/01/17 22:02:38 sina
-o 2006/01/17 22:28:36
-i 2006/01/17 22:28:59 MOW website: v11
-o 2006/01/17 22:48:06
-i 2006/01/18 01:57:59 MOW website: v11
-o 2006/01/18 03:27:34
-i 2006/01/18 03:50:52 sina
-o 2006/01/18 04:32:47
-i 2006/01/18 18:07:31 MOW website: TakeAction
-o 2006/01/18 21:01:43
-i 2006/01/18 23:53:49 MOW website: TakeAction
-o 2006/01/19 01:20:50
-i 2006/01/19 14:50:56 MOW website: TakeAction
-o 2006/01/19 15:40:04
-i 2006/01/19 17:53:04 MOW website: TakeAction
-o 2006/01/19 19:25:36
-i 2006/01/22 00:59:17 MOW website: Cleanup
-o 2006/01/22 01:23:58
-i 2006/01/22 07:43:01 MOW website: Cleanup
-o 2006/01/22 10:02:30
-i 2006/01/22 19:18:23 MOW website: Cleanup
-o 2006/01/22 19:48:01
-i 2006/01/22 20:31:36 MOW website: Cleanup
-o 2006/01/22 23:05:58
-i 2006/01/23 18:45:59 MOW website: SubTheme
-o 2006/01/23 19:50:39
-i 2006/01/23 21:05:19 MOW website: SubTheme
-o 2006/01/24 01:02:44
-i 2006/01/24 20:07:33 MOW website: Bugs
-o 2006/01/24 20:39:11
-i 2006/01/25 08:38:02 MOW website: Bugs
-o 2006/01/25 10:17:25
-i 2006/01/25 11:54:50 MOW website: Bugs
-o 2006/01/25 14:26:52
-i 2006/01/27 03:42:03 MOW website: Bugs
-o 2006/01/27 04:35:28
-i 2006/01/27 05:25:53 MOW website: Bugs
-o 2006/01/27 06:14:55
-i 2006/01/27 16:27:55 MOW website: Bugs
-o 2006/01/27 16:36:42
-i 2006/01/27 17:08:46 MOW website: Bugs
-o 2006/01/27 17:38:40
-i 2006/01/29 15:42:37 MOW website: Bugs
-o 2006/01/29 16:12:01
-i 2006/01/29 22:12:15 MOW website: Bugs
-o 2006/01/30 00:30:12
-i 2006/01/30 13:24:14 MOW website: Comments
-o 2006/01/30 14:54:21
-i 2006/01/30 15:38:38 MOW website: Events
-o 2006/01/30 18:30:18
-i 2006/01/30 18:50:55 MOW website: AboutTheBook
-o 2006/01/30 19:14:55
-i 2006/01/31 12:30:40 MOW website: AboutTheBook
-o 2006/01/31 14:20:46
-i 2006/01/31 16:11:25 MOW website: Events
-o 2006/01/31 18:35:55
-i 2006/02/01 03:44:57 MOW website: public
-o 2006/02/01 04:21:29
-i 2006/02/01 10:40:37 MOW website: public
-o 2006/02/01 15:19:13
-i 2006/02/01 16:49:14 MOW website: public
-o 2006/02/01 19:37:46
-i 2006/02/02 09:55:16 MOW website: public
-o 2006/02/02 10:34:26
-i 2006/02/02 15:47:38 MOW website: public
-o 2006/02/02 18:39:48
-i 2006/02/03 09:14:47 MOW website: public
-o 2006/02/03 10:21:18
-i 2006/02/03 16:21:20 MOW website: public
-o 2006/02/03 17:26:02
-i 2006/02/05 11:49:52 MOW website: public
-o 2006/02/05 22:49:53
-i 2006/02/06 16:49:23 MOW website: public
-o 2006/02/06 18:10:33
-i 2006/02/07 17:01:45 MOW website: public
-o 2006/02/07 18:39:24
-i 2006/02/07 21:00:15 sina
-o 2006/02/08 23:27:28
-i 2006/02/08 11:47:31 MOW website: public
-o 2006/02/08 12:09:20
-i 2006/02/08 12:21:06 MOW website: public
-o 2006/02/08 12:54:37
-i 2006/02/10 21:20:03 MOW website: public
-o 2006/02/10 23:36:40
-i 2006/02/16 21:26:56 3dex scheduler
-o 2006/02/16 22:52:50
-i 2006/02/16 23:35:24 3dex scheduler
-o 2006/02/17 01:11:31
-i 2006/02/17 17:57:19 MOW website: public
-o 2006/02/17 19:09:45
-i 2006/02/17 21:00:15 sina
-o 2006/02/17 21:30:15
-i 2006/02/18 22:00:57 3dex scheduler
-o 2006/02/18 22:59:26
-i 2006/02/19 01:14:16 3dex scheduler
-o 2006/02/19 02:32:59
-i 2006/02/19 17:05:01 3dex scheduler
-o 2006/02/19 17:26:51
-i 2006/02/20 22:28:05 3dex scheduler
-o 2006/02/20 22:48:37
-i 2006/02/21 14:50:37 MOW website: Events
-o 2006/02/21 16:55:24
-i 2006/02/21 17:14:06 MOW website: Events
-o 2006/02/21 18:20:14
-i 2006/02/21 19:34:15 MOW website: Events
-o 2006/02/21 20:00:09
-i 2006/02/23 18:02:57 sina
-o 2006/02/23 19:35:47
-i 2006/02/28 16:01:01 MOW website: Factoids
-o 2006/02/28 18:32:39
-i 2006/02/28 22:13:01 MOW website: testing
-o 2006/02/28 23:41:58
-i 2006/03/02 12:52:49 MOW website: Factoids
-o 2006/03/02 14:13:21
-i 2006/03/02 16:01:03 MOW website: bugs
-o 2006/03/02 17:45:58
-i 2006/03/02 18:10:59 MOW website: bugs
-o 2006/03/02 18:59:01
-i 2006/03/03 16:23:29 MOW website: bugs
-o 2006/03/03 17:23:29
-i 2006/03/10 16:45:13 MOW website: testing
-o 2006/03/10 17:25:14
-i 2006/03/11 16:54:29 MOW website: testing
-o 2006/03/11 18:03:01
-i 2006/03/11 21:06:39 MOW website: testing
-o 2006/03/11 21:36:29
-i 2006/03/11 23:59:37 sina
-o 2006/03/12 03:30:39
-i 2006/03/13 00:41:27 MOW website: testing
-o 2006/03/13 02:04:44
-i 2006/03/14 03:19:06 MOW website: testing
-o 2006/03/14 03:37:49
-i 2006/03/15 02:03:32 MOW website: bugs
-o 2006/03/15 04:04:44
-i 2006/03/15 21:02:35 College:Setup
-o 2006/03/15 22:10:44
-i 2006/03/16 01:08:22 College:Setup
-o 2006/03/16 02:28:17
-i 2006/03/16 03:02:34 College:Setup
-o 2006/03/16 03:34:47
-i 2006/03/16 08:08:17 College:Setup
-o 2006/03/16 08:59:51
-i 2006/03/22 10:31:58 sina
-o 2006/03/22 13:06:15
diff --git a/tests/confirm.py b/tests/confirm.py
deleted file mode 100755
index f4947224..00000000
--- a/tests/confirm.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python
-
-# This script confirms what ledger tells you.
-
-import sys
-import os
-import re
-
-def clean(num):
- return float(re.sub("(\s+|\$|,)","", num))
-
-running_total = 0.0
-index = 1
-last_line = ""
-errors = 0
-
-report = sys.argv[1]
-for line in os.popen("./ledger -f utils/standard.dat -e 2004/4 %s reg %s" %
- (report, sys.argv[2])):
- match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[55:])
- if not match:
- continue
- value = clean(match.group(1))
- total = clean(match.group(2))
-
- running_total += value
- diff = abs(running_total - total)
- if report == "-V" or report == "-G" and diff < 0.015:
- diff = 0.0
- if diff > 0.001:
- print "! discrepancy of %.2f (%.2f - %.2f) at line %d:" % \
- (running_total - total, running_total, total, index)
- print line,
- running_total = total
- errors += 1
-
- index += 1
- last_line = line
-
-balance_total = 0.0
-
-for line in os.popen("./ledger -f utils/standard.dat -e 2004/4 %s bal %s" %
- (report, sys.argv[2])):
- if line[0] != '-':
- balance_total = clean(line[:20])
-
-diff = abs(balance_total - running_total)
-if report == "-V" or report == "-G" and diff < 0.015:
- diff = 0.0
-if diff > 0.001:
- print
- print "! discrepancy of %.2f (%.2f - %.2f) between register and balance" % \
- (balance_total - running_total, balance_total, running_total)
- print last_line,
- print line,
- errors += 1
-
-sys.exit(errors)
diff --git a/tests/parser.h b/tests/parser.h
deleted file mode 100644
index aa1a3a74..00000000
--- a/tests/parser.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef __TESTFILEFORMAT_H
-#define __TESTFILEFORMAT_H
-
-#include <cxxtest/TestSuite.h>
-
-#include <ledger.h>
-
-using namespace std;
-using namespace ledger;
-
-class TestFileFormat : public CxxTest::TestSuite
-{
-public:
- void testEmptyFileIsTextualFile()
- {
- stringstream emptyStream(stringstream::in);
- textual_parser_t textualParser;
- TS_ASSERT(textualParser.test(emptyStream));
- TS_ASSERT(emptyStream.good());
- TS_ASSERT_EQUALS(0, emptyStream.tellg());
- }
-
- void testEmptyFileIsNotXMLFile()
- {
-#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
- stringstream emptyStream(stringstream::in);
- xml_parser_t xmlParser;
- TS_ASSERT(!xmlParser.test(emptyStream));
- TS_ASSERT(emptyStream.good());
- TS_ASSERT_EQUALS(0, emptyStream.tellg());
-#endif
- }
-
- void testEmptyFileIsNotGnuCashFile()
- {
-#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
- stringstream emptyStream(stringstream::in);
- gnucash_parser_t gnucashParser;
- TS_ASSERT(!gnucashParser.test(emptyStream));
- TS_ASSERT(emptyStream.good());
- TS_ASSERT_EQUALS(0, emptyStream.tellg());
-#endif
- }
-
- void testEmptyFileIsNotBinaryFile()
- {
- stringstream emptyStream(stringstream::in);
- binary_parser_t binaryParser;
- TS_ASSERT(!binaryParser.test(emptyStream));
- TS_ASSERT(emptyStream.good());
- TS_ASSERT_EQUALS(0, emptyStream.tellg());
- }
-
- void testEmptyFileIsNotQIFFile()
- {
- stringstream emptyStream(stringstream::in);
- qif_parser_t qifParser;
- TS_ASSERT(!qifParser.test(emptyStream));
- TS_ASSERT(emptyStream.good());
- TS_ASSERT_EQUALS(0, emptyStream.tellg());
- }
-
-};
-
-#endif // __TESTFILEFORMAT_H
diff --git a/tests/regress b/tests/regress
deleted file mode 100755
index 9a6c4412..00000000
--- a/tests/regress
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-
-TMPDIR=/tmp
-TESTS=tests
-UTILS=utils
-CASES=$TESTS/cases
-
-result=0
-
-generate=false
-if [ "$1" = "--generate" ]; then
- generate=true
-fi
-
-runtest() {
- num=$1
- shift
- if [ $generate = true ]; then
- echo generating $num
- ./ledger "$@" > $TESTS/baseline/$num 2> $TMPDIR/errors-$$.out
- cat $TMPDIR/errors-$$.out >> $TESTS/baseline/$num
- rm -f $TMPDIR/*-$$.out
- elif [ -r $TESTS/baseline/$num ]; then
- ./ledger "$@" > $TMPDIR/test-$$.out 2> $TMPDIR/errors-$$.out
- cat $TMPDIR/errors-$$.out >> $TMPDIR/test-$$.out
-
- diff $TESTS/baseline/$num $TMPDIR/test-$$.out \
- > $TMPDIR/result-$$.out 2>&1
- if [ -s $TMPDIR/result-$$.out ]; then
- echo Error: Regression $num failed
- echo ":: regression $num: ./ledger $@" >> errors.out
- cat $TMPDIR/result-$$.out >> errors.out
- result=`expr $result + 1`
- fi
- rm -f $TMPDIR/*-$$.out
- fi
-}
-
-echo Running Ledger regression tests...
-
-runtest 1032 -f $CASES/1032.dat -S t bal
-
-runtest 1031 -f $CASES/1030.dat reg
-runtest 1030 -f $CASES/1030.dat bal
-
-runtest 1029 -f $CASES/1002.dat entry 2006/10/20 "stock option"
-runtest 1028 -f $CASES/1002.dat entry 2006/10/20 "stock option" -20
-runtest 1027 -f $CASES/1002.dat entry 2006/10/20 "stock option" opti
-runtest 1026 -f $CASES/1002.dat entry 2006/10/20 "stock option" time
-runtest 1025 -f $CASES/1002.dat entry 2006/10/20 "stock option" gain
-runtest 1024 -f $CASES/1002.dat entry 2006/10/20 "stock option" opti -20
-runtest 1023 -f $CASES/1002.dat entry 2006/10/20 "stock option" time -20
-runtest 1022 -f $CASES/1002.dat entry 2006/10/20 "stock option" gain -20
-
-runtest 1021 -f $CASES/1002.dat entry 2006/10/20 "stock optionx"
-runtest 1020 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" -20
-runtest 1019 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" opti
-runtest 1018 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" time
-runtest 1017 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" gain
-runtest 1016 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" opti -20
-runtest 1015 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" time -20
-runtest 1014 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" gain -20
-
-runtest 1013 -f $CASES/1002.dat entry 2006/10/20 "stock option" xopti
-runtest 1012 -f $CASES/1002.dat entry 2006/10/20 "stock option" xtime
-runtest 1011 -f $CASES/1002.dat entry 2006/10/20 "stock option" xgain
-runtest 1010 -f $CASES/1002.dat entry 2006/10/20 "stock option" xopti -20
-runtest 1009 -f $CASES/1002.dat entry 2006/10/20 "stock option" xtime -20
-runtest 1008 -f $CASES/1002.dat entry 2006/10/20 "stock option" xgain -20
-
-runtest 1007 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xopti
-runtest 1006 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xtime
-runtest 1005 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xgain
-runtest 1004 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xopti -20
-runtest 1003 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xtime -20
-runtest 1002 -f $CASES/1002.dat entry 2006/10/20 "stock optionx" xgain -20
-
-runtest 1001 -f $CASES/1001.dat bal
-
-if [ -f $UTILS/standard.dat ]; then
- runtest 10 -f $UTILS/standard.dat --truncate=trailing -M -r -s -n reg rent
- runtest 9 -f $UTILS/standard.dat --truncate=trailing -M -r -s reg rent
- runtest 8 -f $UTILS/standard.dat --truncate=trailing -M -r -n reg rent
- runtest 7 -f $UTILS/standard.dat --truncate=trailing -M -r reg rent
- runtest 6 -f $UTILS/standard.dat --truncate=trailing -M reg rent
- runtest 5 -f $UTILS/standard.dat --truncate=trailing -r -s -n reg rent
- runtest 4 -f $UTILS/standard.dat --truncate=trailing -r -s reg rent
- runtest 3 -f $UTILS/standard.dat --truncate=trailing -r -n reg rent
- runtest 2 -f $UTILS/standard.dat --truncate=trailing -r reg rent
- runtest 1 -f $UTILS/standard.dat --truncate=trailing reg rent
-fi
-
-echo Running Ledger regression tests...done
-
-exit $result
diff --git a/tests/regtest b/tests/regtest
deleted file mode 100755
index 57dec8e0..00000000
--- a/tests/regtest
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-errors=0
-
-if [ ! -f utils/standard.dat ]; then
- exit 0
-fi
-
-for test in \
- "-O nrl:checking" \
- "-O ^expenses" \
- "-B 401" \
- "-V 401" \
- "-G 401" \
- "-B ira" \
- "-V ira" \
- "-G ira" \
- "-B retire" \
- "-V retire" \
- "-G retire"
-do
- echo testing: $test
- python tests/confirm.py $test
- errors=`expr $errors + $?`
-done
-
-exit $errors
diff --git a/tests/runtests.py b/tests/runtests.py
deleted file mode 100755
index 7649f775..00000000
--- a/tests/runtests.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env python
-
-import random
-import string
-import signal
-import os
-import sys
-import time
-
-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",
- #"--wide-register-format",
- #"--write-hdr-format",
- #"--write-xact-format",
- "--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 utils/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/tests/textual.h b/tests/textual.h
deleted file mode 100644
index adf24c77..00000000
--- a/tests/textual.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __TESTTEXTUALJOURNAL_H
-#define __TESTTEXTUALJOURNAL_H
-
-#include <cxxtest/TestSuite.h>
-
-#include <textual.h>
-#include <config.h>
-
-using namespace std;
-using namespace ledger;
-
-class TestTextualJournal : public CxxTest::TestSuite
-{
-public:
- void testEmptyFileIsTextualFile()
- {
- stringstream j(stringstream::in);
-
- j << "2005/10/15 Something" << endl;
- j << " A $ 42" << endl;
- j << " B" << endl;
-
- textual_parser_t textualParser;
- TS_ASSERT(textualParser.test(j));
- TS_ASSERT(j.good());
- TS_ASSERT_EQUALS(0, j.tellg());
-
- config_t config;
- std::auto_ptr<journal_t> journal(new journal_t);
- textualParser.parse(j, config, journal.get());
- }
-};
-
-#endif // __TESTTEXTUALJOURNAL_H