(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func 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 | |
| 64 | func TestByteModeLengthCalculations(t *testing.T) { |
| 65 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…