stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject RE: svn commit: r398856 - /incubator/stdcxx/trunk/tests/strings/21.string.find.cpp
Date Wed, 03 May 2006 15:10:49 GMT
This verfies similar to http://issues.apache.org/jira/browse/STDCXX-175
possible problems.

Yes, it is tricky, the passed array has not enough length (-1 is
interpreted as max_size() + 1),
but I think that the method implementation should not create the string
with such length.
Formally the behaviour should be undefined, so we can remove these tests
as more strict than required by the standard.
But I suggest to leave them: all methods pass these tests and the
exception throwning looks more useful than undefined behaviour for this
situation.


With best wishes,
Anton Pevtsov
 

-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Wednesday, May 03, 2006 05:40
To: stdcxx-dev@incubator.apache.org
Subject: Re: svn commit: r398856 -
/incubator/stdcxx/trunk/tests/strings/21.string.find.cpp


antonp@apache.org wrote:
> Author: antonp
> Date: Tue May  2 01:37:49 2006
> New Revision: 398856
> 
> URL: http://svn.apache.org/viewcvs?rev=398856&view=rev
[...]
> +// used to exercise
> +// find (const value_type*, size_type, size_type)
> +static const TestCase ptr_size_size_test_cases [] = {
> +
> +#undef TEST
> +#define TEST(str, arg, off, size, res, bthrow)
\
> +    { __LINE__, off, size, -1, -1, -1, str, sizeof str - 1, arg,
\
> +      sizeof arg - 1, 0, 0, res, bthrow }
> +
> +    //    +--------------------------------------- controlled
sequence
> +    //    |            +-------------------------- sequence to be
found
> +    //    |            |               +---------- find() off
argument 
> +    //    |            |               |   +------ find() n argument 
> +    //    |            |               |   |   +-- expected result  
> +    //    |            |               |   |   |   exception info 
> +    //    |            |               |   |   |   |   0 - no
exception        
> +    //    |            |               |   |   |   |   1 -
length_error  
> +    //    |            |               |   |   |   |

> +    //    |            |               |   |   |   +----+

> +    //    V            V               V   V   V        V

[...]
> +    TEST ("",           "cba",         0, -1,  0,       1),
> +    TEST ("abcdefghij", "cba",         0, -1,  0,       1),
> +    TEST (LSTR,         "xxx",         0, -1,  0,       1),
> +    TEST ("abcdefghij", LSTR,          0, -1,  0,       1),

I'm not certain this is correct. Can you explain what makes you think
the find function should throw length_error in these cases (or in any
case for that matter)?

Thanks
Martin

Mime
View raw message