2 ms·
Ooh, I love the idea of `testcase(X)` to instrument test coverage.
by pornel 8y ago
Ooh, I love the idea of `testcase(X)` to instrument test coverage.
- repsilat 8y agoInteresting how it's different to branch coverage. If you have if(X) {} else {} if(Y) {} else {} "normal test coverage" is weaker than SQLite tests with the following lines added: testcase(X && Y); testcase(X && !Y); testcase(!X && Y); testcase(!X && !Y); I wasn't sure when reading the article, to be honest, but making sure you test things you don't explicitly branch on is kinda cool.
- gshrikant 8y agoI'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 8y 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.