Skip to content

Commit caef57c

Browse files
committed
Create coin-change_test.go
1 parent 999287c commit caef57c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Diff for: coin-change_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package leetcode_solutions_golang
2+
3+
import "testing"
4+
5+
func Test_coinChange(t *testing.T) {
6+
type args struct {
7+
coins []int
8+
amount int
9+
}
10+
tests := []struct {
11+
name string
12+
args args
13+
want int
14+
}{
15+
{
16+
name: "test case 1",
17+
args: args{
18+
coins: []int{1, 2, 5},
19+
amount: 11,
20+
},
21+
want: 3,
22+
},
23+
{
24+
name: "test case 2",
25+
args: args{
26+
coins: []int{2},
27+
amount: 3,
28+
},
29+
want: -1,
30+
},
31+
{
32+
name: "test case 3",
33+
args: args{
34+
coins: []int{1},
35+
amount: 0,
36+
},
37+
want: 0,
38+
},
39+
}
40+
for _, tt := range tests {
41+
t.Run(tt.name, func(t *testing.T) {
42+
if got := coinChange(tt.args.coins, tt.args.amount); got != tt.want {
43+
t.Errorf("coinChange() = %v, want %v", got, tt.want)
44+
}
45+
})
46+
}
47+
}

0 commit comments

Comments
 (0)