Code Coverage using gcov

I’ve just uploaded a code coverage test project, using the gcov GNU tool. The idea was to create a small application (simulating an ATM), and injecting into the CppUnit unit tests executable code coverage information, using the gcov utility. And the results just speak by themselves:

       32:  301:    const bool Date::isLeapYear() const
        -:  302:    {
       32:  303:        if ( _year % 4 != 0 )
        -:  304:        {
       19:  305:            return false;
        -:  306:        }
        -:  307:        else
        -:  308:        {
       13:  309:            if ( _year % 100 != 0 )
        -:  310:            {
    #####:  311:                return true;
        -:  312:            }
        -:  313:            else
        -:  314:            {
       13:  315:                if ( _year % 400 != 0 )
        -:  316:                {
        2:  317:                    return false;
        -:  318:                }
        -:  319:                else
        -:  320:                {
       11:  321:                    return true;
        -:  322:                }
        -:  323:            }
        -:  324:        }
        -:  325:    }
Continue reading