Ramblings of a code junkie

November 11, 2006

Developing ECode

Written by

So the last couple of weeks I’ve been working on creating a first version of ECode, formaly known as CodeParser. Progress is good, but a little too slow for my liking; real life tends to come in the way of fast progress :)

So what have I done on the tool chain I utilize for ECode? Well, as always I am using Emacs for code editing, no surprise here.

Version control is provided by means of tla, this with the future of contributers (hopefully) in mind. It will allow other people to create mirrors of the repository and make their own changes to the code.

The next new thing for me was cppunit. I used to write my own form of unit tests, I switched to utilizing cppunit to give a JUnit lookalike testsuite.

Some notes on cppunit usage. Use the Helper Macros since they greatly reduce the amount of code. Also utilize the TestFactoryRegistry since it removes the need to include every single testcase in the main running program. It will also help you not to forget any testcase ;)

The code for the main runner app now looks as follows:


int main(int argc, char *arg[]) {
    CppUnit::TextUi::TestRunner runner;
    CppUnit::TestFactoryRegistry registry = CppUnit::TestFactoryRegistry::getRegistry();

    runner.addTest( registry.makeTest() );

    bool wasSuccess =;
    return wasSuccess;

A simple failure (this is just an example and yes, I know the check is wrong) will produce the following output:


Test Results:
Run:  1   Failures: 1   Errors: 0

1) test: SymbolTest::testParent (F) line: 30 SymbolTest.cxx
assertion failed
- Expression: symbol->getParent() != parent

Simple and compact. Make sure you write your test in cxx / cpp files instead of the header file, else the TestFactoryRegistry will not work and any changes will not be picked up by make.

Hopefully a 0.1 release will not too far off :)

Zarro Taags!

Leave a Comment