(t *testing.T)
| 247 | } |
| 248 | |
| 249 | func TestEncodeUInt32(t *testing.T) { |
| 250 | cases := []struct { |
| 251 | name string |
| 252 | fieldNum int |
| 253 | v uint32 |
| 254 | expected []byte |
| 255 | }{ |
| 256 | { |
| 257 | name: "zero", |
| 258 | fieldNum: 1, |
| 259 | v: 0, |
| 260 | expected: []byte{0x8, 0x0}, |
| 261 | }, |
| 262 | { |
| 263 | name: "max uint", |
| 264 | fieldNum: 2, |
| 265 | v: math.MaxUint32, |
| 266 | expected: []byte{0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F}, |
| 267 | }, |
| 268 | { |
| 269 | name: "regular value", |
| 270 | fieldNum: 3, |
| 271 | v: 42, |
| 272 | expected: []byte{0x18, 0x2A}, |
| 273 | }, |
| 274 | } |
| 275 | for _, tc := range cases { |
| 276 | t.Run(tc.name, func(t *testing.T) { |
| 277 | dest := make([]byte, len(tc.expected)) |
| 278 | csproto.NewEncoder(dest).EncodeUInt32(tc.fieldNum, tc.v) |
| 279 | assert.Equal(t, tc.expected, dest) |
| 280 | }) |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | func TestEncodePackedUInt32(t *testing.T) { |
| 285 | dest := make([]byte, 9) |
nothing calls this directly
no test coverage detected