Does anyone have an approach for unit testing functions that return a random result? In the past I have just run the function say 10,000 times and checked that the result is one that is expected each time, but this is obviously inefficient and not conclusive.
Interesting question,
Usually the random number generator has a seed value.
If you supply your own seed, then you get the same sequence each time.
@soegaard2 That’s an interesting idea.
Another option is to let the random number generator be an argument of the function (which defaults to the standard number generator).
Then at test time you can supply a number generator that returns what ever number your test function wants to test.
@soegaard2 Yes that does sound like a good plan.
@c has joined the channel
@dan.hillier.anderson has joined the channel
@greg Thank you for your great introduction to Macro. Which helped me a lot. https://www.greghendershott.com/fear-of-macros/index.html\|https://www.greghendershott.com/fear-of-macros/index.html And this fun little article. https://greghendershott.com/2013/01/fear-of-macros.html\|https://greghendershott.com/2013/01/fear-of-macros.html