You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Anton Pevtsov <An...@moscow.vdiweb.com> on 2006/01/23 17:15:53 UTC

test for lib.alg.random_shuffle

I'm porting the test for the lib.alg.random_shuffle algorithm and I have
a question about the current test implementation.

There is the special test case for the built-in random number generator
which does the following:
some test array is defined and initialized with numbers, when the
random_shuffle algorithm is called for this array, and the result is
compared with another predefined array (which was initialized with the
same numbers and "shuffled" manually). The results of the random_shuffle
of the given array depends on the implementation of the random number
generator used by random_shuffle,
and this results in that the test case may be passed for the 1025-th
invocation of the random_shuffle algorithm only. 

The question is: is it necessary to keep this test case in the ported
test version?


Thanks,
Anton Pevtsov


Re: test for lib.alg.random_shuffle

Posted by Martin Sebor <se...@roguewave.com>.
Anton Pevtsov wrote:
> I'm porting the test for the lib.alg.random_shuffle algorithm and I have
> a question about the current test implementation.
> 
> There is the special test case for the built-in random number generator
> which does the following:
> some test array is defined and initialized with numbers, when the
> random_shuffle algorithm is called for this array, and the result is
> compared with another predefined array (which was initialized with the
> same numbers and "shuffled" manually). The results of the random_shuffle
> of the given array depends on the implementation of the random number
> generator used by random_shuffle,

Correct.

> and this results in that the test case may be passed for the 1025-th
> invocation of the random_shuffle algorithm only. 

Not sure what you mean here.

> 
> The question is: is it necessary to keep this test case in the ported
> test version?

I believe the point of comparing the result of the algorithm against
the hardcoded values is to verify that the algorithm produces the same
results across all platforms and architectures. The standard doesn't
require this degree of portability but our implementation provides it
anyway -- to guarantee consistent behavior.

I'm not seeing any runtime problems with the test and I'm not sure
I understand where you think the problem is.

Martin