Last active
May 8, 2022 19:30
-
-
Save jwillker/67fc9aaa0e320796388d34e7aad8a353 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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