13 ms·
Realize that both implementations offer the same functionality. You could even say the implementations are basically identical, except for the fact that one giv
by jstimpfle 10y ago
Realize that both implementations offer the same functionality. You could even say the implementations are basically identical, except for the fact that one gives more "calling surface". So it is is only the "ideal" of 100% branch coverage that misleads you into think you would need more tests.
The two branches of the big function don't interact in any way (they could also be paralleized), so 100% branch coverage has no benefit here.
In fact you need less tests with the big function if you don't know the context in which the functionality is used, since the surface area is smaller.
Another way to look at it is that 100% branch coverage only means all the branches in one isolated function are tested. However, the multiple-functions version calls other functions and the possible branches there are ignored. In other words the interaction with called functions is not tested.