(t *testing.T)
| 166 | } |
| 167 | |
| 168 | func 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 | |
| 202 | func TestMapExceedsLimit(t *testing.T) { |
| 203 | data := UnlimitedData{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…