Postmortem: Template unittests are bad & you shouldn't catch Error

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 23 15:25:57 UTC 2020


On 10/22/20 4:54 PM, H. S. Teoh wrote:
> On Thu, Oct 22, 2020 at 07:31:39PM +0000, Kagamin via Digitalmars-d wrote:
>> On Thursday, 22 October 2020 at 16:30:57 UTC, H. S. Teoh wrote:
>>> The problem with that is that it quickly falls into the paradox of
>>> who watches the watchers.  The next thing you know, I'm asking for a
>>> way to test that my code that catches asserts are actually catching
>>> asserts.  Next year I'll be asking for code to test my code that
>>> tests code that catches asserts. It never ends.
>>
>> Paradoxes don't exist. Tests are watchers, and practice shows their
>> presence is better than their absence.
> 
> I agree tests are watchers.  But it starts a bit ridiculous when you
> need to test your tests...

Testing that an error occurs in an error situation is not ridiculous.

Repeating the question that still isn't answered, I want to make sure 
when someone accesses a Nullable that is null using the `get` function, 
an error is thrown. How do I check for this other than trying it, and 
examining the error? The fact that it throws this specific error in this 
situation is part of the API, I want to test that API. How do I do it?

If this were an error code being returned we aren't having this 
conversation, it would be obviously acceptable. It needs to be 
acceptable here as well.

-Steve


More information about the Digitalmars-d mailing list