(t *testing.T)
| 195 | } |
| 196 | |
| 197 | func TestDecodeString(t *testing.T) { |
| 198 | cases := []struct { |
| 199 | name string |
| 200 | fieldNum int |
| 201 | v []byte |
| 202 | wt csproto.WireType |
| 203 | expected string |
| 204 | }{ |
| 205 | { |
| 206 | name: "empty string", |
| 207 | fieldNum: 1, |
| 208 | v: []byte{0xA, 0x0}, |
| 209 | wt: csproto.WireTypeLengthDelimited, |
| 210 | expected: "", |
| 211 | }, |
| 212 | { |
| 213 | name: "non-empty string", |
| 214 | fieldNum: 2, |
| 215 | v: []byte{0x12, 0xE, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74}, |
| 216 | wt: csproto.WireTypeLengthDelimited, |
| 217 | expected: "this is a test", |
| 218 | }, |
| 219 | } |
| 220 | for _, tc := range cases { |
| 221 | t.Run(tc.name, func(t *testing.T) { |
| 222 | dec := csproto.NewDecoder(tc.v) |
| 223 | tag, wt, err := dec.DecodeTag() |
| 224 | assert.Equal(t, tc.fieldNum, tag, "tag should match") |
| 225 | assert.Equal(t, tc.wt, wt, "wire type should match") |
| 226 | assert.NoError(t, err, "should not fail") |
| 227 | |
| 228 | got, err := dec.DecodeString() |
| 229 | assert.NoError(t, err) |
| 230 | assert.Equal(t, tc.expected, got) |
| 231 | }) |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | func TestDecodeBytes(t *testing.T) { |
| 236 | cases := []struct { |
nothing calls this directly
no test coverage detected