Closed nanodeath closed 7 years ago
I prefer not to write unit tests for probabilistic functions. One can fix seeds, but they will still be completely unverifiable for humans. And if I change the algorithm a bit, even if I don't change it but just optimize the Observe() method to not call RNG so often, I would need completely new unit tests. You can take the other approach in Kollapse of course.
You wouldn't need a new unit test...you'd just update the expected image to match the new output. Otherwise, there's really no way to make changes with confidence that you didn't break something.
Or one could just check the hash of the bitmap (-data). Then they need to change only one line if they need to.
It would be a good idea to have some unit tests on this code. Ensure that given an input and some seed, it does a pixel-by-pixel comparison of that output with an expected output image. Would make changes much safer. (I have a few examples in Kollapse, if that helps any).