Le lundi 14 mars 2016 à 04:48 -0700, RAJ Rohit Jalem a écrit : > Thank you for helping. > > Can you explain me in the context of writing a test for this > function: https://github.com/JuliaStats/StatsBase.jl/blob/master/src/ > sampling.jl#L77-L81 > > Can it be possible to write tests for this using the Base.Test > package? How do I use srand() implementation for writing a test to > this? > > Sorry for a lot of questions. Was trying to get my head around > Base.Test! Like this: using StatsBase, Base.Test srand(1) @test samplepair(2) == (1, 2)
To find out that the call returns (1, 2), you need to call this first: srand(1) samplepair(2) Regards > regards, > Raj > > > > > > > Le lundi 14 mars 2016 à 04:19 -0700, RAJ Rohit Jalem a écrit : > > > How do I test functions that return random values. > > > > > > For example, this function here: https://coveralls.io/builds/5402 > > 764/ > > > source?filename=src%2Fsampling.jl#L77 > > > > > > Can it be done with the Base.Test package? If yes, then how? > > Use srand() before calling them to ensure you always get the same > > "random" value. For example, srand(1) will work. > > > > > > Regards
