I'm not a native English speaker. In my native language I'm aware of some terms used to refer to the condition checked to stop a recursion, and to the condition checked for extreme, unlikely or super-simple cases. In English, I've encountered the terms "edge case", "corner case", "boundary case" and "base case", but I can't quite figure out the differences and which is used to refer to what; I'd love to get some summary of the differences between them.

In particular, I would be very happy if someone could provide annotations for the lines in the following code sample:

2 Answers
2

Corner case occurs outside of normal operating parameters, specifically when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range for that parameter. (The "outside normal operating parameters" obviously means something like "outside typical combination of operating parameters", not strictly "outside allowed operating parameters". That is, you're still within the valid parameter space, but near its corner.)

Boundary case occurs when one of inputs is at or just beyond maximum or minimum limits.

So, the nomenclature seems to be totally confused, even though corner case seems to mean something a bit different (a combination of values) than edge and boundary cases, which are definitely synonymes. It's probably safe to say that edge, corner, and boundary cases are the same thing in common speech. Someone could mean to say different thing by each of them, but there's hardly any common agreement.

Your 1) and 2) are what you wrote, 3) is a edge/boundary case, 4) is a base case, and 5) is a special case.

Regardless of the differences between the words, what you'd use to describe a test depends on the semantics (meaning) of the test, not the exact code - In the example provided it's not obvious what each of the tests mean. That aside, here's how I understand them:

Sanity check = Does this even make sense? For example, if your application only outputs integers, sqrt(-1) does not make sense, and log(-1) is undefined no matter how sophisticated the mathematics library.

Input check = Tests the user input, as opposed to some internal data structure or the output of a function. For example, in Bash [ $# -gt 0 ] checks that you got at least one input parameter, which could also be a sanity check for a command like find or mail.

Edge / Boundary check = The maximum or minimum input which is expected to produce correct output. For example, a function which just adds one to a number will have an operating range from <MIN_INT> to <MAX_INT> - 1, since input smaller than <MIN_INT> can't be provided by the user and output larger than <MAX_INT> won't be useful.

Corner case check = A more complex boundary check (a corner is a two-dimensional boundary), for example combining <MIN_INT> and <MAX_INT> in a calculation.