Let's count

Report a typo

Look at the code below:

package simpleCalc

func calc(a, b int, op string) (int, bool) {
	switch op {
	case "+":
		return a + b, true
	case "-":
		return a - b, true
	case "*":
		return a * b, true
	case "/":
		if b == 0 {
			return 0, false
		}
		return a / b, true
	default:
		return 0, false
	}
}

What is the minimum number of test cases you need to write to cover the code with tests by 100 percent?

Full coverage doesn't mean checking all outcomes.

Enter a number
___

Create a free account to access the full topic