←back to thread

177 points signa11 | 1 comments | | HN request time: 0.272s | source
1. thaumasiotes ◴[] No.42162457[source]
A tangential issue:

> Unfortunately, it can only catch undefined behavior that actually happens, so if your test suite doesn’t cover all your code branches you might have undefined behavior lurking in the code somewhere.

Covering every branch is not enough to say you have full coverage.

    if( condition1 ) {
      /* complicated things */
    }
    if( condition2 ) {
      /* complicated things */
    }
    if( condition3 ) {
      /* complicated things */
    }
There are only three branches and you can "cover" them all with six tests. (Heck - you can cover them all with just two tests!) But there are eight paths through the code, and six tests can cover at most six of them.