Testing CalculatorPlus
Learn how to test CalculatorPlus precompile.
Now that we have gone through an example of how to test the Calculator precompile, it is time that you develop your own tests for CalculatorPlus.
Rather than explicitly tell you what test cases to write, we decided to leave that to you. After all, testing is a subjective profession - a test suite that fits one security needs might be inadequate for someone else.
However, if you want an idea for what to test for, the following are some recommendations:
- Unit Tests: create some unit tests involving values that you can come up with. Ideally, write 3-5 unit tests for each function.
- Fuzz Tests: test more than 1000 random inputs for each function
Note
For both unit and fuzz tests, make sure to account for the case when the denominator is equal to 0 in
simplFrac
.