Improve testing for Animal Magic Exercise

I had a conversation with my mentor exercise, Animal Magic, about the tests for the exercise.

I have pasted some of my observations/questions, and added an in my eyes, improved and more correct test.


I have seen multiple community examples like

Where they do rand.Intn(20) 1 but still marks as tests passed. I don’t get that. That would in my eyes from time to time result in a die roll of 21, and no only between 1 and 20 as stated in the requirements.

Can someone explain this to me

Intn returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n) from the default Source. It panics if n <= 0.

Intn(20) returns a value between 0 and 19 (including 0 and 19 but not 20).

Intn(20) + 1 returns a number between 1 and 20, inclusive, that is, what you would get rolling a 20 sided die.

It was not meant to be posted in this state, it was published before I finished editing it. My bad.

This was the post I was meant to post.

I guess that makes this post a duplicate of Improve testing for Animal Magic Exercise now :smile: Please continue any discussion there.

Agreed, but couldn’t even delete it. Can you mark it as duplicate?