Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Created July 26, 2017 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrnugget/fd46beead8545ed73aca46926e3bfc46 to your computer and use it in GitHub Desktop.
Save mrnugget/fd46beead8545ed73aca46926e3bfc46 to your computer and use it in GitHub Desktop.
Using test helpers in Go -- how do I know which test failed with vim-go?
package main
func AddTwo(input int) int {
return input + 2
}
func AddFour(input int) int {
return input + 4
}
package main
import "testing"
func TestAddTwo(t *testing.T) {
if !testIntegers(t, 2, AddTwo(1)) {
return
}
}
func TestAddFour(t *testing.T) {
if !testIntegers(t, 2, AddFour(1)) {
return
}
}
func testIntegers(t *testing.T, expected, actual int) bool {
if expected != actual {
t.Errorf("wrong integer. want=%d, got=%d",
expected, actual)
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment