如何为 Perlin 噪声库编写单元测试?
How to write unit tests for a Perlin noise library?
我目前正在使用现有的 Perlin 噪声实现,它与我试图清理的一堆代码捆绑在一起。有问题的代码测试严重不足,我想确保它的每个组件都接受适当的测试,以防存在任何隐藏的错误。
但是,我不确定在这种情况下我将如何测试 Perlin 噪声实现的正确性。我欢迎所有建议。
这是一个棘手的问题,可能没有单一的最佳解决方案。
对于某些图像属性,您也许可以使用 Computer Vision techniques. I.E. if your Perlin noise output is supposed to be tile-able, an edge detection filter might be able to catch problems. I've also had some good results using FFT filters when I was working on an image classifier for perlin noise based wood grain textures. In my experience, implementing such tests can easily take more time then building the code being tested. To minimize that, I'd stick with libraries like OpenCV, Octave 等执行自动化测试。此外,此方法取决于已知的良好输出才能构建测试。
从某种意义上说,柏林噪声是一种随机数发生器。为此,您可以使用 RNG test suites like the NIST Statistical Test Suite or the Diehard tests。这种方法取决于已知的良好输出才能构建测试。
最后,您可以构建将结果输出到文件的测试,然后根据预期结果对每个测试进行手动确认。为方便起见,您可以通过网页加载图像集合,甚至可以集成报告复选框以收集来自测试人员的 pass/fail 响应。这个解决方案是我为测试难以量化、不可能或不切实际的属性而提出的最佳解决方案。 IE。看到了才知道我的粒子效果是对的
我目前正在使用现有的 Perlin 噪声实现,它与我试图清理的一堆代码捆绑在一起。有问题的代码测试严重不足,我想确保它的每个组件都接受适当的测试,以防存在任何隐藏的错误。
但是,我不确定在这种情况下我将如何测试 Perlin 噪声实现的正确性。我欢迎所有建议。
这是一个棘手的问题,可能没有单一的最佳解决方案。
对于某些图像属性,您也许可以使用 Computer Vision techniques. I.E. if your Perlin noise output is supposed to be tile-able, an edge detection filter might be able to catch problems. I've also had some good results using FFT filters when I was working on an image classifier for perlin noise based wood grain textures. In my experience, implementing such tests can easily take more time then building the code being tested. To minimize that, I'd stick with libraries like OpenCV, Octave 等执行自动化测试。此外,此方法取决于已知的良好输出才能构建测试。
从某种意义上说,柏林噪声是一种随机数发生器。为此,您可以使用 RNG test suites like the NIST Statistical Test Suite or the Diehard tests。这种方法取决于已知的良好输出才能构建测试。
最后,您可以构建将结果输出到文件的测试,然后根据预期结果对每个测试进行手动确认。为方便起见,您可以通过网页加载图像集合,甚至可以集成报告复选框以收集来自测试人员的 pass/fail 响应。这个解决方案是我为测试难以量化、不可能或不切实际的属性而提出的最佳解决方案。 IE。看到了才知道我的粒子效果是对的