Skip to content

Instantly share code, notes, and snippets.

@jwillker
Last active May 8, 2022 19:30
Show Gist options
  • Select an option

  • Save jwillker/67fc9aaa0e320796388d34e7aad8a353 to your computer and use it in GitHub Desktop.

Select an option

Save jwillker/67fc9aaa0e320796388d34e7aad8a353 to your computer and use it in GitHub Desktop.
func Test_sum(t *testing.T) {
tests := []struct {
name string
x int
y int
want int
}{
{
name: "one plus two",
x: 1,
y: 2,
want: 3,
},
{
name: "one plus zero",
x: 1,
y: 0,
want: 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, sum(tt.x, tt.y))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment