A Code Coverage Puzzle

A simple comparison is marked as not completely covered, although both branches of the if statement have been covered!?! How is that possible?

This is a small function I’ve created, which is also covered by unit tests. The light blue shade of the return statements indicate that they have been executed. So both branches of the if statement have been covered. But the light pink shade of the comparison indicates that the comparison has not been completely covered.
2014-12-01 16_54_38-BlogCode - Microsoft Visual Studio

Having a logical expression marked as not completely covered is common if it includes any && or || operators that are short circuited. But there are no such operators here. So what is the reason for the partial coverage?

I’ll post the answer and explanation later this week.

2 comments

  1. Is MyNumericType a class or a struct? Does it overload “<" and if so, what's the return type?

    (Thoughts: if it's a reference type, what if value or SingleDigitLimit is null? If the return type of < is Nullable, have you covered all three possible options?)

    1. MyNumericType is a struct. To be more specific it is a system struct, with a generic argument that is also a struct. That inner struct overloads the < operator.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.