stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: string exception safety tests
Date Thu, 04 May 2006 20:21:46 GMT
Anton Pevtsov wrote:
> Ok, but I see another issue: the significant part of the test cases
> doesn't require memory allocation.
> These cases cann't produce bad_alloc and there is no reason to test
> exception safety on them. 
> Also the assert which verifies that an exception was thrown fails for
> such test cases.

You mean, for instance, the find tests? Yes, I agree that it would
make no sense to try to exercise exception safety in those, unless
of course we threw an exception from one of the traits members. But
that probably isn't worth the trouble. So I agree that we should
exercise exception safety only in tests for string modifiers,

> I suggest to exercise exception safety for the test cases which requires
> memory allocation in any case 
> (AFAIK, the size of the buffer allocated by string is
> platform-dependent, so the string should be really long to require the
> reallocation).
> What do you think about this? 

We can determine on a case by case basis whether allocation took
place or not and based on that decide whether an exception should
or should not be expected. I don't think we need to mak assumptions
about the size of the string or the function's arguments.


View raw message