forked from wufenggirl/LeetCode-in-Golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom-flip-matrix_test.go
executable file
·71 lines (57 loc) · 1.22 KB
/
random-flip-matrix_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package problem0519
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Solution(t *testing.T) {
ast := assert.New(t)
rows, cols := 2, 3
s := Constructor(rows, cols)
recorder := make([]bool, rows*cols)
for i := 0; i < rows*cols; i++ {
f := s.Flip()
r, c := f[0], f[1]
old := recorder[r*cols+c]
recorder[r*cols+c] = true
ast.False(old)
}
s.Reset()
recorder = make([]bool, rows*cols)
for i := 0; i < rows*cols; i++ {
f := s.Flip()
r, c := f[0], f[1]
old := recorder[r*cols+c]
recorder[r*cols+c] = true
ast.False(old)
}
}
func Test_Solution_2(t *testing.T) {
ast := assert.New(t)
rows, cols := 1, 2
s := Constructor(rows, cols)
recorder := make([]bool, rows*cols)
for i := 0; i < rows*cols; i++ {
f := s.Flip()
r, c := f[0], f[1]
old := recorder[r*cols+c]
recorder[r*cols+c] = true
ast.False(old)
}
ast.Nil(s.Flip())
}
func Test_Solution_3(t *testing.T) {
ast := assert.New(t)
rows, cols := 10000, 10000
s := Constructor(rows, cols)
for times := 0; times < 200; times++ {
recorder := make([]bool, rows*cols)
s.Reset()
for i := 0; i < 4; i++ {
f := s.Flip()
r, c := f[0], f[1]
old := recorder[r*cols+c]
recorder[r*cols+c] = true
ast.False(old)
}
}
}