Sanity checks in software development are quite common. When you've got a bug in your code and it doesn't make any sense, and you've looked at all the possible causes, then it is time for a sanity test.

It's when you find yourself staring at code that cannot possibly fail, such as:

n = sqrt(fabs(gamma));


and you insert this:

test = fabs(gamma);

if(test<0.0)
throw(runtime_error);

n = sqrt(test);


because maybe, just maybe, you've gone completely mad and sqrt is still being passed a negative number, even though fabs shouldn't allow that.

And of course the purpose of a sanity check is that it doesn't fail, giving you the reassurance to keep looking somewhere else for the bug.

And so, when a sanity test did fail today, I was left blank faced and slack jawed. Logically, under the terms of the test, it means that I have indeed gone mad. I thereby devote myself for the rest of the day to the worship of the Friday Dragon. A fearsome beast that creeps into the brain of innocent programmers on Friday afternoons and eats all their processing cycles.


This post was originally on LiveJournal.