I'm using gcov to measure coverage in my C++ code. I'd like to get to 100% coverage, but am hampered by the fact that there are some lines of code that are theoretically un-hittable (methods that are required to be implemented but which are never called, default branches of switch
statements, etc.). Each of these branches contains an assert( false );
statement, but gcov still marks them as un-hit.
I'd like to be able to tell gcov to ignore these branches. Is there any way to give gcov that information -- by annotating the source code, or by any other mechanism?
Please use lcov. It hides gcov's complexity, produces nice output, allows detailed output per test, features easy file filtering and - ta-taa - line markers for already reviewed lines:
From geninfo(1):
The following markers are recognized by geninfo:
- LCOV_EXCL_LINE
- Lines containing this marker will be excluded.
- LCOV_EXCL_START
- Marks the beginning of an excluded section. The current line is part of this section.
- LCOV_EXCL_STOP
- Marks the end of an excluded section. The current line not part of this section.