diff options
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | Makefile.in | 7 | ||||
-rwxr-xr-x | acprep | 1 | ||||
-rw-r--r-- | src/amount.cc | 2 | ||||
-rw-r--r-- | src/xml.cc | 12 | ||||
-rw-r--r-- | src/xml.h | 13 | ||||
-rw-r--r-- | tests/UnitTests.cc | 28 |
7 files changed, 44 insertions, 26 deletions
diff --git a/Makefile.am b/Makefile.am index 59d2add1..81e6da18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -234,6 +234,13 @@ PyUnitTests: $(srcdir)/tests/python/PyUnitTests.py | sed "s/%builddir%/$(ESC_builddir)/g" > $@ chmod 755 $@ +fullcheck: UnitTests + MallocGuardEdges=1 \ + MallocScribble=1 \ + MallocPreScribble=1 \ + DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib \ + $(top_builddir)/UnitTests --verify + ###################################################################### DISTCLEANFILES = Doxyfile.gen diff --git a/Makefile.in b/Makefile.in index 1d270283..530e5017 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1858,6 +1858,13 @@ PyUnitTests: $(srcdir)/tests/python/PyUnitTests.py | sed "s/%builddir%/$(ESC_builddir)/g" > $@ chmod 755 $@ +fullcheck: UnitTests + MallocGuardEdges=1 \ + MallocScribble=1 \ + MallocPreScribble=1 \ + DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib \ + $(top_builddir)/UnitTests --verify + alldocs: docs/ledger.info docs/ledger.pdf doxygen-docs $(top_builddir)/Doxyfile.gen: $(srcdir)/docs/Doxyfile @@ -63,6 +63,7 @@ while [ -n "$1" ]; do # CPPFLAGS="-I/usr/local/include/stlport $CPPFLAGS" # LIBS="$LIBS -lstlportstlg" #fi + CPPFLAGS="$CPPFLAGS -D_GLIBCXX_DEBUG=1" ;; CXXFLAGS="$CXXFLAGS -g" ;; --prof | --perf) diff --git a/src/amount.cc b/src/amount.cc index 85ba07f5..274d3001 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -283,7 +283,7 @@ namespace { } if (sign) { - char * newbuf = new char[std::strlen(result ? result : buf) + 1]; + char * newbuf = new char[std::strlen(result ? result : buf) + 2]; newbuf[0] = '-'; std::strcpy(&newbuf[1], result ? result : buf); mpz_set_str(dest, newbuf, 10); @@ -51,11 +51,6 @@ const char * document_t::ledger_builtins[] = { "transaction" }; -document_t::document_t(node_t * _top) - : stub(this), top(_top ? _top : &stub) { - TRACE_CTOR(xml::document_t, "node_t *, const char **, const int"); -} - document_t::~document_t() { TRACE_DTOR(xml::document_t); @@ -159,10 +154,9 @@ void document_t::print(std::ostream& out) const document_t * node_t::document; #endif -node_t::node_t(document_t * _document, parent_node_t * _parent, - flags_t _flags) - : supports_flags<>(_flags), - name_id(0), parent(_parent), next(NULL), prev(NULL), attrs(NULL) +node_t::node_t(document_t * _document, parent_node_t * _parent, flags_t _flags) + : supports_flags<>(_flags), name_id(0), parent(_parent), + next(NULL), prev(NULL), attrs(NULL) { TRACE_CTOR(node_t, "document_t *, node_t *"); document = _document; @@ -236,18 +236,23 @@ private: names_map names_index; - terminal_node_t stub; - - public: +public: node_t * top; +private: + terminal_node_t stub; + +public: // Ids 0-9 are reserved. 10-999 are for "builtin" names. 1000+ are // for dynamically registered names. enum special_names_t { CURRENT, PARENT, ROOT, ALL }; - document_t(node_t * _top = NULL); + document_t(node_t * _top = NULL) + : top(_top ? _top : &stub), stub(this) { + TRACE_CTOR(xml::document_t, "node_t *, const char **, const int"); + } ~document_t(); void set_top(node_t * _top); diff --git a/tests/UnitTests.cc b/tests/UnitTests.cc index 1c695340..7f5d1333 100644 --- a/tests/UnitTests.cc +++ b/tests/UnitTests.cc @@ -17,17 +17,7 @@ CPPUNIT_REGISTRY_ADD_TO_DEFAULT("Framework"); -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("corelib"); - -CPPUNIT_REGISTRY_ADD("numerics", "corelib"); -CPPUNIT_REGISTRY_ADD("balances", "corelib"); -CPPUNIT_REGISTRY_ADD("values", "corelib"); - -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("driver"); -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("journal"); -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("reports"); -CPPUNIT_REGISTRY_ADD_TO_DEFAULT("transforms"); - +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. @@ -62,9 +52,17 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(UnitTests, "framework"); 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 > 1) ? std::string(argv[1]) : std::string(""); + std::string testPath = ((argc > index) ? std::string(argv[index]) : + std::string("")); // Create the event manager and test controller CPPUNIT_NS::TestResult controller; @@ -85,8 +83,14 @@ int main(int argc, char* argv[]) 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(); |