I am trying to understand the output of the gcov tool. Running it without parameters makes sense, but I want to try to understand the options for covering branches. Unfortunately, it is difficult to understand what the branches do and why they are not accepted. Below is the result for the method (compile using the latest LLVM / Clang build).
function -[TestCoverageAppDelegate loopThroughArray:] called 5 returned 100% blocks executed 88% 5: 30:- (NSInteger)loopThroughArray:(NSArray *)array { 5: 31: NSInteger i = 0; 22: 32: for (NSString *string in array) { branch 0 taken 0 branch 1 taken 7 -: 33: 22: 34: } branch 0 taken 4 branch 1 taken 3 branch 2 taken 0 branch 3 taken 3 5: 35: return i; -: 36:}
I missed 5 tests through this, passing nil, an empty array, an array with 1 object and an array with 2 objects and an array with 4 objects. I can guess that in the first case, branch 1 means βgo to loopβ, but I donβt know what branch 0 is. In the second case, branch 0 seems to go through the loop again, branch 1 seems to end the loop, and branch 3 continues / exits the loop, but I have no idea what branch 2 is or why / when it will be executed.
If someone knows how to decrypt information about the branch, or knows any detailed documentation about what all this means, I would appreciate help.
Martin Pilkington
source share