This commit is contained in:
VicRen
2020-12-03 15:30:04 +08:00
parent 410825768e
commit e16c9db6e6
4 changed files with 114 additions and 3 deletions
+71
View File
@@ -0,0 +1,71 @@
package main
import "testing"
func Test_goodPairsCount(t *testing.T) {
type args struct {
src []int
}
tests := []struct {
name string
args args
want int
}{
{
"test1",
args{[]int{1, 2, 3, 1, 1, 3}},
4,
},
{
"test2",
args{[]int{1, 1, 1, 1}},
6,
},
{
"test3",
args{[]int{1, 2, 3}},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := goodPairsCount(tt.args.src); got != tt.want {
t.Errorf("goodPairsCount() = %v, want %v", got, tt.want)
}
})
}
}
func Test_goodPairsCount2(t *testing.T) {
type args struct {
src []int
}
tests := []struct {
name string
args args
want int
}{
{
"test1",
args{[]int{1, 2, 3, 1, 1, 3}},
4,
},
{
"test2",
args{[]int{1, 1, 1, 1}},
6,
},
{
"test3",
args{[]int{1, 2, 3}},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := goodPairsCount2(tt.args.src); got != tt.want {
t.Errorf("goodPairsCount() = %v, want %v", got, tt.want)
}
})
}
}