forked from yeqown/go-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask_test.go
52 lines (39 loc) · 1.28 KB
/
mask_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
package qrcode
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestMask(t *testing.T) {
qrc := &QRCode{
sourceText: "baidu.com google.com qq.com sina.com apple.com",
encodingOption: DefaultEncodingOption(),
}
err := qrc.init()
require.NoError(t, err)
var stateInitCnt int
qrc.mat.iter(IterDirection_COLUMN, func(x, y int, s qrvalue) {
if s.qrtype() == QRType_INIT {
stateInitCnt++
}
})
t.Logf("all QRType_INIT block count: %d", stateInitCnt)
SetDebugMode()
cpyMat := qrc.mat.Copy()
_ = debugDraw("./testdata/mask_origin.jpeg", *cpyMat)
mask0 := newMask(cpyMat, modulo0)
_ = debugDraw("./testdata/modulo0.jpeg", *mask0.mat)
mask1 := newMask(cpyMat, modulo1)
_ = debugDraw("./testdata/modulo1.jpeg", *mask1.mat)
mask2 := newMask(cpyMat, modulo2)
_ = debugDraw("./testdata/modulo2.jpeg", *mask2.mat)
mask3 := newMask(cpyMat, modulo3)
_ = debugDraw("./testdata/modulo3.jpeg", *mask3.mat)
mask4 := newMask(cpyMat, modulo4)
_ = debugDraw("./testdata/modulo4.jpeg", *mask4.mat)
mask5 := newMask(cpyMat, modulo5)
_ = debugDraw("./testdata/modulo5.jpeg", *mask5.mat)
mask6 := newMask(cpyMat, modulo6)
_ = debugDraw("./testdata/modulo6.jpeg", *mask6.mat)
mask7 := newMask(cpyMat, modulo7)
_ = debugDraw("./testdata/modulo7.jpeg", *mask7.mat)
}