Something is missing

Report a typo

Suppose we have a Calculator class with the following method:

fun sum(numbers: List<Int>?): Int {    
    if (numbers == null) {
        return 0
    }

    var sum = 0
    for (number in numbers) {
        sum += number
    }
    return sum
}

We also have a test method for the test case where the argument of the sum method is null:

@Test
fun testSum() {
    val calculator = Calculator()
    val collection: List<Int>? = null
    // TODO implement
}

Complete the missing line of code with an assertion that will compare the value returned by the sum method given collection as its argument and result in a successful test.

Enter a short text
___

Create a free account to access the full topic