MCPcopy
hub / github.com/skip2/go-qrcode / TestClassifyDataMode

Function TestClassifyDataMode

encoder_test.go:14–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestClassifyDataMode(t *testing.T) {
15 type Test struct {
16 }
17
18 tests := []struct {
19 data []byte
20 actual []segment
21 }{
22 {
23 []byte{0x30},
24 []segment{
25 {
26 dataModeNumeric,
27 []byte{0x30},
28 },
29 },
30 },
31 {
32 []byte{0x30, 0x41, 0x42, 0x43, 0x20, 0x00, 0xf0, 0xf1, 0xf2, 0x31},
33 []segment{
34 {
35 dataModeNumeric,
36 []byte{0x30},
37 },
38 {
39 dataModeAlphanumeric,
40 []byte{0x41, 0x42, 0x43, 0x20},
41 },
42 {
43 dataModeByte,
44 []byte{0x00, 0xf0, 0xf1, 0xf2},
45 },
46 {
47 dataModeNumeric,
48 []byte{0x31},
49 },
50 },
51 },
52 }
53
54 for _, test := range tests {
55 encoder := newDataEncoder(dataEncoderType1To9)
56 encoder.encode(test.data)
57
58 if !reflect.DeepEqual(test.actual, encoder.actual) {
59 t.Errorf("Got %v, expected %v", encoder.actual, test.actual)
60 }
61 }
62}
63
64func TestByteModeLengthCalculations(t *testing.T) {
65 tests := []struct {

Callers

nothing calls this directly

Calls 2

newDataEncoderFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…