Skip to content

Instantly share code, notes, and snippets.

@cyantarek
Last active June 19, 2018 08:38
Show Gist options
  • Save cyantarek/d1e56d6f788c4d713c3d2ae96acca9ee to your computer and use it in GitHub Desktop.
Save cyantarek/d1e56d6f788c4d713c3d2ae96acca9ee to your computer and use it in GitHub Desktop.
//calculator_test.go
package main
import "testing"
func TestAdd(t *testing.T) {
if result, _ := AddFunc(1,2); result != 3 {
t.Error("Test failed")
}
}
func TestAddWrong(t *testing.T) {
if result, _ := AddFunc(1,2); result == 4 {
t.Error("1 + 2 should not be 4")
}
}
func TestAddEmptyInput(t *testing.T) {
if _, err := AddFunc(); err == nil {
t.Error("Empty input can not be accepted")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment