Kotlinlearncs.online LogoJava
Return to List

Test Writing: Array Is All Larger

Created By: Geoffrey Challen
/ Version: 2022.2.0

Write a method arrayIsAllLarger that, given two Int arrays, returns true if all the values in the first array are larger than or equal to all the values in the same position in the second array. If the first array is longer than the second array, or the second array is longer than the first array, then the extra values can be ignored. If either array is empty, return false.

For example, given {1, 2, 4} and {0, 1, 7}, you should return false, since 7 is greater than 4. Given {1, 2, 4} and {0, 1} you should return true, since the first two values of the first array are greater than the first two values of the second array. Given {1, 2, 4} and {0, 1, 3, 8}, you should return true, since the first three values of the first array are greater than the first three values of the second array. Given {1, 2} and {1, 2}, you should return true, since all values in the two arrays are equal.

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Kotlin's assert or check methods