(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestEncodeString(t *testing.T) { |
| 58 | cases := []struct { |
| 59 | name string |
| 60 | fieldNum int |
| 61 | v string |
| 62 | expected []byte |
| 63 | }{ |
| 64 | { |
| 65 | name: "empty string", |
| 66 | fieldNum: 1, |
| 67 | v: "", |
| 68 | expected: []byte{0xA, 0x0}, |
| 69 | }, |
| 70 | { |
| 71 | name: "non-empty string", |
| 72 | fieldNum: 2, |
| 73 | v: "this is a test", |
| 74 | expected: []byte{0x12, 0xE, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74}, |
| 75 | }, |
| 76 | } |
| 77 | for _, tc := range cases { |
| 78 | t.Run(tc.name, func(t *testing.T) { |
| 79 | dest := make([]byte, len(tc.expected)) |
| 80 | csproto.NewEncoder(dest).EncodeString(tc.fieldNum, tc.v) |
| 81 | assert.Equal(t, tc.expected, dest) |
| 82 | }) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | func TestEncodeBytes(t *testing.T) { |
| 87 | cases := []struct { |
nothing calls this directly
no test coverage detected