MCPcopy
hub / github.com/tinylib/msgp / TestStructSizeEstimation

Function TestStructSizeEstimation

_generated/binary_marshaler_test.go:309–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func 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
335func TestMarshalerErrorHandling(t *testing.T) {
336 // Test marshaling with marshaler that can fail

Callers

nothing calls this directly

Calls 2

MsgsizeMethod · 0.65
MarshalMsgMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…