[Mono-dev] Issues with System.Random

Adrian Willenbücher AWillenbuecher at gmx.de
Wed Mar 17 11:54:44 EDT 2010


Andreas Nahr wrote:
  > +				throw new ArgumentNullException ("buffer is
> null.");
> 
> is clearly an error. First parameter is the argument name, not some
> descriptive text.

That shouldn't be so hard to fix. Besides, the current implementation has the same error in Next(int) and Next(int,int)

> I can understand your point, but this means that your ARE testing
> implementation against implementation. It might be good for testing if you
> correctly implemented your algorithm, but it is imho not suited to test if
> it is a conforming CLR/.Net implementation (in fact if you would use it on
> MS.Net it would fail completely and if you use it on current mono it would
> also fail).

What would you propose for a proper unit test? Keep in mind that my tests test at least for everything that the old ones 
tested for (plus the exceptions), and are much more thorough.

>>> And moreover you removed ALL
>>> Random() constructor tests which most likely are the only of relevance to
>>> real-world applications.
>> Yes, I forgot this one. However, there's not much you can test for (except
> that it doesn't throw an exception): the 
>> state is private, so it can't be checked directly; the value of
> Environment.TickCount() might change between reading it 
> 
> Well you can at LEAST test all the provided Next() methods with something
> similar than you have written.

The Next(...) methods already have unit tests, I see no point in testing them again. Together with the test method for 
Random(), this should be enough in my opinion.


Best regards,
Adrian


More information about the Mono-devel-list mailing list