For testing purposes of a RandomGen-reliant function I need a RandomGen instance which will return the numbers I tell it to on instantiation so that I could compare the results of a tested function to the correct ones. I.e. on each call to random I want this function to return the next number from a list [5, 8, 2, 6, 6] (it may throw an error if it reaches the end or it may cycle). I expect an instance of that generator to be created as simply as StaticGen [5, 8, 2, 6, 6].
I am wondering if there exists such a library or maybe if I should take some different approach at my testing.
On Updates: turns out I originally stated the question wrong by specifying the next function instead of random as the one I wanted to return the values from a list. My apologies.
Well, you could distribute such a library. But it would be very short.
Well, as mentioned this won’t give you out the sequence you pass in. You could rewrite your functions, so instead of taking a random number generator like this:
They work like this instead:
That way you can use it with a random number generator:
Or you can use it with a list: