(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestRoundTrip(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | tests := []struct { |
| 18 | name string |
| 19 | tag codec.Tag |
| 20 | data []byte |
| 21 | }{ |
| 22 | { |
| 23 | name: "empty data", |
| 24 | tag: codec.TagV1, |
| 25 | data: []byte{}, |
| 26 | }, |
| 27 | { |
| 28 | name: "simple data", |
| 29 | tag: codec.TagV1, |
| 30 | data: []byte("hello world"), |
| 31 | }, |
| 32 | { |
| 33 | name: "binary data", |
| 34 | tag: codec.TagV1, |
| 35 | data: []byte{0x00, 0x01, 0x02, 0xff, 0xfe}, |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tt := range tests { |
| 40 | t.Run(tt.name, func(t *testing.T) { |
| 41 | t.Parallel() |
| 42 | |
| 43 | var buf bytes.Buffer |
| 44 | err := codec.WriteFrame(&buf, tt.tag, tt.data) |
| 45 | require.NoError(t, err) |
| 46 | |
| 47 | readBuf := make([]byte, codec.MaxMessageSizeV1) |
| 48 | tag, data, err := codec.ReadFrame(&buf, readBuf) |
| 49 | require.NoError(t, err) |
| 50 | require.Equal(t, tt.tag, tag) |
| 51 | require.Equal(t, tt.data, data) |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestReadFrameTooLarge(t *testing.T) { |
| 57 | t.Parallel() |
nothing calls this directly
no test coverage detected