Unit tests and segfaults
Russel Winder
russel at winder.org.uk
Tue Dec 11 08:16:58 PST 2012
On Thursday, 6 December 2012 at 10:31:43 UTC, Alex Rønne Petersen
wrote:
> On 06-12-2012 10:02, Russel Winder wrote:
>> What is the right idiom for testing that a function call does
>> segfault
>> when you want it to?
>>
>
> There is basically no portable, clean way to do that. Why are
> you relying on segmentation faults? It's generally speaking a
> very bad idea because behavior depends entirely on the platform
> and architecture...
I am not relying on segfaults, that would just be silly ;-) The
issue is that unit tests should test error as well as success. I
want to know if I get a segfault when I have an infinite
recursion in an algorithm (due to incorrect parameters slipping
through data validation).
I am also trying to investigate tail recursion optimization and
getting a segfault is a way of detecting that it isn't happening.
(Sorry for the delay in replying I lost the email in my client.)
More information about the Digitalmars-d-learn
mailing list