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

Function TestNestedArrayLimits

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

Source from the content-addressed store, hash-verified

166}
167
168func TestNestedArrayLimits(t *testing.T) {
169 // Test limits on nested arrays within maps
170 data := UnlimitedData{}
171
172 t.Run("NestedArray_ExceedsLimit", func(t *testing.T) {
173 buf := msgp.AppendMapHeader(nil, 1)
174 buf = msgp.AppendString(buf, "big_map")
175 buf = msgp.AppendMapHeader(buf, 1) // Within map limit
176 buf = msgp.AppendString(buf, "key")
177 buf = msgp.AppendArrayHeader(buf, 150) // Nested array exceeds limit of 100
178
179 _, err := data.UnmarshalMsg(buf)
180 if err != msgp.ErrLimitExceeded {
181 t.Errorf("Expected ErrLimitExceeded for nested array, got %v", err)
182 }
183 })
184
185 t.Run("NestedArray_WithinLimit", func(t *testing.T) {
186 buf := msgp.AppendMapHeader(nil, 1)
187 buf = msgp.AppendString(buf, "big_map")
188 buf = msgp.AppendMapHeader(buf, 1) // Within map limit
189 buf = msgp.AppendString(buf, "key")
190 buf = msgp.AppendArrayHeader(buf, 50) // Nested array within limit
191 for i := 0; i < 50; i++ {
192 buf = msgp.AppendInt(buf, i)
193 }
194
195 _, err := data.UnmarshalMsg(buf)
196 if err != nil {
197 t.Errorf("Unexpected error for nested array within limit: %v", err)
198 }
199 })
200}
201
202func TestMapExceedsLimit(t *testing.T) {
203 data := UnlimitedData{}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…