Skip to content

Instantly share code, notes, and snippets.

@evie404
Last active May 1, 2018 17:11
Show Gist options
  • Save evie404/adad552be2e92eda67ab5b4e6003fbcc to your computer and use it in GitHub Desktop.
Save evie404/adad552be2e92eda67ab5b4e6003fbcc to your computer and use it in GitHub Desktop.
interview snipplet
package main
import "fmt"
func plusone(a int) int {
return a + 1
}
type testCase struct {
input int
expected int
}
func main() {
testCases := []testCase{
{
1,
2,
},
{
2,
3,
},
{
3,
4,
},
{
4,
5,
},
}
for _, t := range testCases {
input := t.input
expected := t.expected
actual := plusone(input)
fmt.Printf("input: %v\n", input)
fmt.Printf("expected: %v\n", expected)
fmt.Printf("actual: %v\n", actual)
if expected != actual {
fmt.Println("Test case is incorrect.")
return
}
fmt.Println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment