Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: Test Calculator

package main

import "testing"

func TestCalc(t *testing.T) {
	result, err := calc(2, "+", 3)

	if err != nil {
		t.Errorf("Error found where not expected %v", err)
	}
	if result != 5 {
		t.Errorf("Expected 5 received %v", result)
	}
}