Created
July 26, 2017 04:59
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func AddTwo(input int) int { | |
return input + 2 | |
} | |
func AddFour(input int) int { | |
return input + 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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