(t *testing.T)
| 307 | } |
| 308 | |
| 309 | func TestStructSizeEstimation(t *testing.T) { |
| 310 | testStruct := &TestStruct{ |
| 311 | BinaryValue: BinaryTestType{Value: "test"}, |
| 312 | BinarySlice: []BinaryTestType{ |
| 313 | {Value: "slice1"}, |
| 314 | {Value: "slice2"}, |
| 315 | }, |
| 316 | BinaryMap: map[string]BinaryTestType{ |
| 317 | "key": {Value: "value"}, |
| 318 | }, |
| 319 | } |
| 320 | |
| 321 | // Get size estimate |
| 322 | size := testStruct.Msgsize() |
| 323 | |
| 324 | // Marshal and verify size estimate |
| 325 | data, err := testStruct.MarshalMsg(nil) |
| 326 | if err != nil { |
| 327 | t.Fatalf("MarshalMsg failed: %v", err) |
| 328 | } |
| 329 | |
| 330 | if len(data) > size { |
| 331 | t.Errorf("Msgsize underestimated: estimated %d, actual %d", size, len(data)) |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | func TestMarshalerErrorHandling(t *testing.T) { |
| 336 | // Test marshaling with marshaler that can fail |
nothing calls this directly
no test coverage detected
searching dependent graphs…