Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 7471473

Browse files
committed
922 added
1 parent 16a0a83 commit 7471473

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
package problem0922
22

33
import (
4-
"fmt"
54
"testing"
65

76
"github.com/stretchr/testify/assert"
87
)
98

109
// tcs is testcase slice
1110
var tcs = []struct {
12-
A []int
13-
ans []int
11+
A []int
1412
}{
1513

1614
{
1715
[]int{4, 2, 5, 7},
18-
[]int{4, 5, 2, 7},
1916
},
2017

2118
// 可以有多个 testcase
@@ -25,8 +22,7 @@ func Test_sortArrayByParityII(t *testing.T) {
2522
ast := assert.New(t)
2623

2724
for _, tc := range tcs {
28-
fmt.Printf("~~%v~~\n", tc)
29-
ast.Equal(tc.ans, sortArrayByParityII(tc.A), "输入:%v", tc)
25+
ast.True(check(sortArrayByParityII(tc.A)))
3026
}
3127
}
3228

@@ -37,3 +33,12 @@ func Benchmark_sortArrayByParityII(b *testing.B) {
3733
}
3834
}
3935
}
36+
37+
func check(a []int) bool {
38+
for i := range a {
39+
if a[i]%2 != i%2 {
40+
return false
41+
}
42+
}
43+
return true
44+
}

0 commit comments

Comments
 (0)