Adding Unit Tests
Learn how to add unit tests.
Although the autogenerated units tests were useful in finding whether if the gas requirements of our functions were being fulfilled, we are yet to test the actual logic of our functions. We can add more unit tests by simply adding more mappings to the tests variable.
To start, lets define the tests that we want to write for each function within our Calculator precompile:
add
: check that add(1, 2) returns 3nextTwo
: check that nextTwo(1) returns 2, 3repeat
: check that repeat(2, "EGS") returns "EGSEGS"
With this in mind, lets add the three units tests to the tests variable! Below is a code excerpt which shows the three unit tests incorporated: