3 ms·
I'm probably being a blockhead but I didn't quite get how the testcase macro is used in instrumenting coverage. Can you explain that?
by gshrikant 7y ago
I'm probably being a blockhead but I didn't quite get how the testcase macro is used in instrumenting coverage. Can you explain that?
- nairboon 7y agoThe testcase macro is the following: # define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } If the testcase(condition) always evaluates to true, the code coverage analyzer would complain that the if ( X ) {sqlite3...} statement never evaluates to false and the branch coverage drops below 100%, the converse holds conversely if it was never evaluated to true in the first place. Only if the code using the testcase macro gets repeatedly called in a way so that the testcase macro evaluates sometimes to true and sometimes to false, the coverage stays at 100%. sqlite3Coverage() does some dummy work so that the call will not be optimized away by the compiler.