Looks like I am slowly getting somewhere:

    Test project /Users/lars/CodeDevelopment/Projects/Work/CGI/cgi-challenge/build
        Start 1: simple_stats
    1/5 Test #1: simple_stats .....................   Passed    0.04 sec
        Start 2: test_DateTime
    2/5 Test #2: test_DateTime ....................   Passed    0.07 sec
        Start 3: test_Interval
    3/5 Test #3: test_Interval ....................   Passed    0.01 sec
        Start 4: test_LogData
    4/5 Test #4: test_LogData .....................   Passed    0.01 sec
        Start 5: test_LogEntry
    5/5 Test #5: test_LogEntry ....................   Passed    0.00 sec

    100% tests passed, 0 tests failed out of 5

After spending most of the past half year creating websites and programming within the Ruby eco-system, the recent programming challenge has pulled me back quite forcefully into the world of C++ (which actually is not a bad thing at all).

Attacking a problem such as the one presented with I am gathering the usual suspects in terms of tools:

  • CMake - Cross-platform build system generator.
  • Doxygen - Documentation generator.
  • Boost - peer-reviewed portable C++ source libraries.

Quite obviously configuration and build system generation is being handled by CMake; ever since getting to know this tool, it has been at the backend of all my programming actitivies where source code compilation is required. “Side benefit” of this choice is that with CTest I also get a testing tool.

Another quite obvious choice is Doxygen for the generation of source code documentation. With the Markdown support introduced in version 1.8.0 the integration of extended documentation – such as design notes, background material, etc. – is rather straight forward; commonly used trick is to provide the read-me file in the top-level directory in Markdown syntax (README.md), such that the file can be easily read without any processing but also be used as mainpage for the HTML output.

Last but not least the Boost C++ libraries are always something to keep in mind when starting on a C++ project. Given the fact that Boost has been proven something of a staging area for features to be integrated with the official language standard it is a good thing to be aware of what this collection has in store for various types of problems.

Since unit testing of the various building block of the software under development is an absolute essential, I have been chosing the Boost Unit Test Framework to support and formalize the process. A bit of a learning curve after not working with it for a longer stretch of time, but well worth the investment, since testing already has uncovered a few errors.

        int year   = 2000;
        int month  = 1;
        int day    = 2;
        int hour   = 3;
        int minute = 4;
        int second = 5;

        cgi::DateTime dt = cgi::DateTime(year, month, day, hour, minute, second);

        BOOST_CHECK_EQUAL (dt.asString("%Y"), std::string("2000"));
        BOOST_CHECK_EQUAL (dt.asString("%m"), std::string("01"));
        BOOST_CHECK_EQUAL (dt.asString("%d"), std::string("02"));
        BOOST_CHECK_EQUAL (dt.asString("%H"), std::string("03"));
        BOOST_CHECK_EQUAL (dt.asString("%M"), std::string("04"));

        BOOST_CHECK_EQUAL (dt.asString("%Y-%m-%d"), std::string("2000-01-02"));
        BOOST_CHECK_EQUAL (dt.asString("%H:%M:%S"), std::string("03:04:05"));

Next step new is integration of the individual building block into a full working application.