Add a test of utils::factorial#19
Conversation
|
It is possible to test to larger input values, but the exponents on the outputs are so large that the small differences in the mantissa due to different floating point errors between the function and the test code result in values that differ enough to need custom epsilon values. |
|
I added a big test case manually |
Axect
left a comment
There was a problem hiding this comment.
Thank you for adding test for the factorial function.. I've reviewed the changes, and I'm pleased to approve this PR. Here are my thoughts:
-
The test coverage for inputs from 0 to 90 is comprehensive and uses appropriate approximate comparisons to account for floating-point errors.
-
Including a test case for the largest factorial that fits in an f64 (170!) is an excellent addition. This edge case is important to verify.
-
Your explanation about the limitations of testing larger input values due to floating-point precision issues is clear and reasonable.
-
The code is well-written and easy to understand.
-
This contribution successfully addresses part of the testing requirements for #12.
Great job on implementing these tests. They will certainly improve the reliability of our factorial function. I'm merging this PR now. Thank you for your valuable contribution to the project!
This PR adds a test of the
factorialfunction inpuruspe, by calculating the factorial naively in a loop and comparing with the output. I use approximate comparisons because there are different floating point errors at very large outputs.This adds tests for one of the
utilsfunctions for #12.