Hallvard B Furuseth
7/27/2015 3:00:00 PM
Julio Di Egidio <julio@diegidio.name> writes:
> On Monday, July 27, 2015 at 1:48:18 PM UTC+1, Hallvard Breien Furuseth wrote:
[Rearranging a bit]
>> That is, anti_rand() might output random numbers for a while, then
>> switch to (X,Y,Z, X,Y,Z ...) for a while, and so on.
>
> And so on what? Is it supposed to generate random numbers or not?
> Indeed, why call it anti_rand and not just rand? And why not just use
> some library function? (It is utterly non-trivial to code a decent
> random number generator.)
I do *not* want a random number generator. I want a random _pattern_
generator. See the Subject header. Generate some pattern and output
that, then another, and so on. Some regular patterns, some half-
randomized. Or something like that.
>> switch (anti_rand() % CASES) {
> That is not a good approach: if the range of anti_rand is not an exact
> multiple of the number of cases, you get that some cases are hit more
> frequently than others. But you'll have to clarify about anti_rand
> before I get to suggest a better approach:
Not quite, but the program must be adapted to anti_rand(), yes.
>> I expect someone has dealt with this problem before.
>
> I do use random input for some tests, it may be useful to
> automatically generate a large number of test cases with varying
> input: the only drawback is that tests are not repeatable unless you
> specify a seed for the random number generator.
I expect to output the seed at the beginning of the test, and make the
program deterministic after picking the seed. Or offer that as an
option, anyway.
--
Hallvard