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

Function TestFixedArraysNotLimited

_generated/limits_test.go:103–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestFixedArraysNotLimited(t *testing.T) {
104 // Test that fixed arrays are not subject to limits
105 // BigArray [1000]int should work even though 1000 > 100 (array limit)
106 data := UnlimitedData{}
107
108 t.Run("FixedArray_DecodeMsg", func(t *testing.T) {
109 buf := msgp.AppendMapHeader(nil, 1)
110 buf = msgp.AppendString(buf, "big_array")
111 buf = msgp.AppendArrayHeader(buf, 1000) // Fixed array size, should not be limited
112 for i := 0; i < 1000; i++ {
113 buf = msgp.AppendInt(buf, i)
114 }
115
116 reader := msgp.NewReader(bytes.NewReader(buf))
117 err := data.DecodeMsg(reader)
118 if err != nil {
119 t.Errorf("Fixed arrays should not be limited, got error: %v", err)
120 }
121 })
122
123 t.Run("FixedArray_UnmarshalMsg", func(t *testing.T) {
124 buf := msgp.AppendMapHeader(nil, 1)
125 buf = msgp.AppendString(buf, "big_array")
126 buf = msgp.AppendArrayHeader(buf, 1000) // Fixed array size, should not be limited
127 for i := 0; i < 1000; i++ {
128 buf = msgp.AppendInt(buf, i)
129 }
130
131 _, err := data.UnmarshalMsg(buf)
132 if err != nil {
133 t.Errorf("Fixed arrays should not be limited, got error: %v", err)
134 }
135 })
136}
137
138func TestSliceLimitsApplied(t *testing.T) {
139 // Test that dynamic slices are subject to limits

Callers

nothing calls this directly

Calls 7

AppendMapHeaderFunction · 0.92
AppendStringFunction · 0.92
AppendArrayHeaderFunction · 0.92
AppendIntFunction · 0.92
NewReaderFunction · 0.92
DecodeMsgMethod · 0.65
UnmarshalMsgMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…