stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r647225 - /stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp
Date Tue, 06 May 2008 19:54:37 GMT
vitek@apache.org wrote:
> Author: vitek
> Date: Fri Apr 11 10:05:18 2008
> New Revision: 647225
> 
> URL: http://svn.apache.org/viewvc?rev=647225&view=rev
> Log:
> 
> 2008-04-11  Travis Vitek  <vitek@roguewave.com>
> 
> 	STDCXX-783
> 	* tests/algorithms/25.random.shuffle.cpp (test_random_shuffle): Move
> 	rw_assert() into loop to avoid bogus cadvise warning.
> 
> 
> Modified:
>     stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp
> 
> Modified: stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp
> URL: http://svn.apache.org/viewvc/stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp?rev=647225&r1=647224&r2=647225&view=diff
> ==============================================================================
> --- stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp (original)
> +++ stdcxx/trunk/tests/algorithms/25.random.shuffle.cpp Fri Apr 11 10:05:18 2008
> @@ -306,22 +306,16 @@
>          0xfa, 0xbb, 0xdd, 0xa5, 0xa3, 0x73, 0x18, 0xd9
>      };
>  
> -    bool success = true;
> -    std::size_t i = 0;
> -    for (; i != sizeof array / sizeof *array; ++i) {
> -        success = array [i] == result [i];
> -        if (!success)
> -            break;
> +    for (std::size_t i = 0; i != sizeof array / sizeof *array; ++i) {
> +        const bool success = array [i] == result [i];
> +        if (!success) {
> +            rw_assert (0, 0, line, 
> +                       "randomly shuffled sequence failed to match "
> +                       "the expected result (data portability failure) "
> +                       "%d != %d at %zu",
> +                       array [i], result [i], i + 1);
> +        }

AFAICT, this changes the behavior of the loop in a way we don't
want: the loop will no longer break on the first failure and might
generate dozens of lines of output. The effect I think we want is:

     if (!rw_assert (array [i] == result [i], 0, line,
                     "randomly shuffled sequence failed to match "
                     "the expected result (data portability failure) "
                     "%d != %d at %zu",
                     array [i], result [i], i + 1))
         break;

Martin

Mime
View raw message