-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtext_encoder_test.go
54 lines (39 loc) · 1.14 KB
/
text_encoder_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
package pdf417
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTextEncoder_CanEncode(t *testing.T) {
assert := assert.New(t)
encoder := CreateTextEncoder()
for ord := int(' '); ord < int('Z'); ord++ {
chr := rune(ord)
if chr == '"' {
continue
}
assert.True(
encoder.CanEncode(string(chr)),
"Unable to encode: %d %c",
ord,
chr,
)
}
}
func TestTextEncoder_GetSwitchCode(t *testing.T) {
assert := assert.New(t)
encoder := CreateTextEncoder()
assert.Equal(TEXT_SWITCH_CODE_WORD, encoder.GetSwitchCode("123"))
assert.Equal(TEXT_SWITCH_CODE_WORD, encoder.GetSwitchCode("foo"))
}
func TestTextEncoder_Encode(t *testing.T) {
assert := assert.New(t)
encoder := CreateTextEncoder()
assert.Equal([]int{900, 567, 615, 137, 808, 760}, encoder.Encode("Super !", true))
assert.Equal([]int{567, 615, 137, 808, 760}, encoder.Encode("Super !", false))
}
func TestTextEncoder_Encode2(t *testing.T) {
assert := assert.New(t)
encoder := CreateTextEncoder()
assert.Equal([]int{900, 567, 615, 137, 809}, encoder.Encode("Super ", true))
assert.Equal([]int{567, 615, 137, 809}, encoder.Encode("Super ", false))
}