News for hackers. Stuff that matters.
Re:There are only four billion floats, so test them all (2014) by thaumasiotes on Sunday October 11, 2020 @11:37AM (#24746494)
In this case, I think mocking is the right thing to do. You want to know that you can handle the case where two hashes collide. But for this purpose, you don't care at all how the hashes were generated.

If the website changes its URI hash algorithm, the "honest" test that just supplies two URIs that happened to collide under the earlier algorithm will suddenly become worthless. The mocked test will continue doing exactly what you always wanted it to do -- exercise the "what if the hashes collide?" case in your code.

Re:There are only four billion floats, so test them all (2014) by cle on Sunday October 11, 2020 @10:06PM (#24750804)
You still have to reason through “what if it collides with the real hash function?” How do you know it will behave the same if you don’t test it?

(I can sympathize with both approaches and don’t think either one is better.)