In your opinion, do you think it is a waste of time to make checks that you know
there is no possible way of it being there/not being there, or would you just put
it there just in case there is a bug or something?
There are three possibilities, it's implossible
int i = 0;
if (i==1 && i==2) {
// useless test
}
It's possible but requires a change in the code somewhere.
int i = 0;
if (i>0) {
// line above should prevent this from happening.
// extreme case, if this branch is executing someone did something wrong
}
And finally it could simply be an invalid state, something which you don't think can happen given good data.
The first case is a total waste of time, no change to the code or the user input can result in that test succeeding. The second case is MOSTLY useless, but a variation on it can be useful. Basically, the second case as presented requires a change in the code to for that branch to be take, but a more complex example could be useful in validating an assumption that is baked into the following algorithim, but is not inherently enforced.
For instance, if instead of an int, it was creating a uninitialzed User, then a check that the name was empty could theoretically be valid -- the User could be changed so that a default name is supplied, and if a write once property was changed so that the default name could be changed, it could mess things up.
But really, there are better ways of testing for such things (unit test for instance, although that's not really what they are for).
Finally, there's the last case -- and whether you test for that depends upon what you can do about it that is useful. And just how unlikely you think it is -- if it is realistically never going to happen, then testing for it is a waste of time. If on the other hand, it shouldn't happen but can, then by all means catch it if you can do something useful.