Create a public class TestArraySum that provides a single void class method named test.
test accepts a single parameter: an instance of ArraySum.
Each ArraySum provides a method sum that accepts an int[] and returns the sum of the values as an int,
or 0 if the array is null.
However, some ArraySum implementations are broken!
Your job is to identify all of them correctly.
To do this you should use assert to test various inputs.
Here's an example:
Your function does not need to return a value. Instead, if the code is correct no assertion should fail, and if it is incorrect one should.
As you design test inputs, here are two conflicting objectives to keep in mind:
null,
off-by-one errors, not handling special cases properly, etc.Good luck and have fun!
Stuck? You may find these lessons helpful: