(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestEncodeByteString(t *testing.T) { |
| 60 | var bytesTests = []struct { |
| 61 | bs []byte |
| 62 | encoding string |
| 63 | }{ |
| 64 | {[]byte{}, "40"}, |
| 65 | {[]byte{0xab}, "41ab"}, |
| 66 | { |
| 67 | []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, |
| 68 | "5819 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18", |
| 69 | }, |
| 70 | } |
| 71 | // This doesn't test every size of integer that might encode the length |
| 72 | // of the byte string. |
| 73 | |
| 74 | for _, test := range bytesTests { |
| 75 | var b bytes.Buffer |
| 76 | e := NewEncoder(&b) |
| 77 | |
| 78 | if err := e.EncodeByteString(test.bs); err != nil { |
| 79 | t.Errorf("Encode. err: %v", err) |
| 80 | } |
| 81 | exp := fromHex(test.encoding) |
| 82 | |
| 83 | if !bytes.Equal(exp, b.Bytes()) { |
| 84 | t.Errorf("%v expected to encode to %v, actual %v", test.bs, exp, b.Bytes()) |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func TestEncodeTextString(t *testing.T) { |
| 90 | var textTests = []struct { |
nothing calls this directly
no test coverage detected