Last active
December 21, 2021 09:01
-
-
Save percybolmer/33c74401052948d5f7189ecd097f1a10 to your computer and use it in GitHub Desktop.
A CO Pilot generated table test
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
// table driven unit tests for Deck.Draw | |
func TestDeck_Draw(t *testing.T) { | |
type args struct { | |
n int | |
} | |
tests := []struct { | |
name string | |
d Deck | |
args args | |
want []Card | |
}{ | |
{ | |
name: "Draw 5 cards from a deck", | |
d: NewDeck(), | |
args: args{n: 5}, | |
want: []Card{ | |
{ | |
Suit: "Spades", | |
Rank: "Ace", | |
}, | |
{ | |
Suit: "Spades", | |
Rank: "Two", | |
}, | |
{ | |
Suit: "Spades", | |
Rank: "Three", | |
}, | |
{ | |
Suit: "Spades", | |
Rank: "Four", | |
}, | |
{ | |
Suit: "Spades", | |
Rank: "Five", | |
}, | |
}, | |
}, | |
} | |
for _, tt := range tests { | |
t.Run(tt.name, func(t *testing.T) { | |
if got := tt.d.Draw(tt.args.n); !reflect.DeepEqual(got, tt.want) { | |
t.Errorf("Deck.Draw() = %v, want %v", got, tt.want) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment