(t *testing.T)
| 302 | } |
| 303 | |
| 304 | func TestEncodeUInt64(t *testing.T) { |
| 305 | cases := []struct { |
| 306 | name string |
| 307 | fieldNum int |
| 308 | v uint64 |
| 309 | expected []byte |
| 310 | }{ |
| 311 | { |
| 312 | name: "zero", |
| 313 | fieldNum: 1, |
| 314 | v: 0, |
| 315 | expected: []byte{0x8, 0x0}, |
| 316 | }, |
| 317 | { |
| 318 | name: "max uint", |
| 319 | fieldNum: 2, |
| 320 | v: math.MaxUint64, |
| 321 | expected: []byte{0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1}, |
| 322 | }, |
| 323 | { |
| 324 | name: "regular value", |
| 325 | fieldNum: 3, |
| 326 | v: 421138, |
| 327 | expected: []byte{0x18, 0x92, 0xDA, 0x19}, |
| 328 | }, |
| 329 | } |
| 330 | for _, tc := range cases { |
| 331 | t.Run(tc.name, func(t *testing.T) { |
| 332 | dest := make([]byte, len(tc.expected)) |
| 333 | csproto.NewEncoder(dest).EncodeUInt64(tc.fieldNum, tc.v) |
| 334 | assert.Equal(t, tc.expected, dest) |
| 335 | }) |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | func TestEncodePackedUInt64(t *testing.T) { |
| 340 | dest := make([]byte, 16) |
nothing calls this directly
no test coverage detected