forked from ruudk/golang-pdf417
-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_encoder_test.go
47 lines (35 loc) · 1.18 KB
/
number_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
package pdf417
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNumberEncoder_CanEncode(t *testing.T) {
assert := assert.New(t)
encoder := CreateNumberEncoder()
assert.True(encoder.CanEncode("0"))
assert.True(encoder.CanEncode("1"))
assert.True(encoder.CanEncode("2"))
assert.True(encoder.CanEncode("3"))
assert.True(encoder.CanEncode("4"))
assert.True(encoder.CanEncode("5"))
assert.True(encoder.CanEncode("6"))
assert.True(encoder.CanEncode("7"))
assert.True(encoder.CanEncode("8"))
assert.True(encoder.CanEncode("9"))
assert.False(encoder.CanEncode(""))
assert.False(encoder.CanEncode("a"))
assert.False(encoder.CanEncode("abc"))
assert.False(encoder.CanEncode("123"))
}
func TestNumberEncoder_GetSwitchCode(t *testing.T) {
assert := assert.New(t)
encoder := CreateNumberEncoder()
assert.Equal(NUMBER_SWITCH_CODE_WORD, encoder.GetSwitchCode("123"))
assert.Equal(NUMBER_SWITCH_CODE_WORD, encoder.GetSwitchCode("foo"))
}
func TestNumberEncoder_Encode(t *testing.T) {
assert := assert.New(t)
encoder := CreateNumberEncoder()
assert.Equal([]int{902, 112, 434}, encoder.Encode("01234", true))
assert.Equal([]int{112, 434}, encoder.Encode("01234", false))
}