(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestSliceLimitsApplied(t *testing.T) { |
| 139 | // Test that dynamic slices are subject to limits |
| 140 | data := UnlimitedData{} |
| 141 | |
| 142 | t.Run("Slice_ExceedsLimit", func(t *testing.T) { |
| 143 | buf := msgp.AppendMapHeader(nil, 1) |
| 144 | buf = msgp.AppendString(buf, "big_slice") |
| 145 | buf = msgp.AppendArrayHeader(buf, 150) // Exceeds array limit of 100 |
| 146 | |
| 147 | _, err := data.UnmarshalMsg(buf) |
| 148 | if err != msgp.ErrLimitExceeded { |
| 149 | t.Errorf("Expected ErrLimitExceeded for slice, got %v", err) |
| 150 | } |
| 151 | }) |
| 152 | |
| 153 | t.Run("Slice_WithinLimit", func(t *testing.T) { |
| 154 | buf := msgp.AppendMapHeader(nil, 1) |
| 155 | buf = msgp.AppendString(buf, "big_slice") |
| 156 | buf = msgp.AppendArrayHeader(buf, 50) // Within array limit of 100 |
| 157 | for i := 0; i < 50; i++ { |
| 158 | buf = msgp.AppendString(buf, "test") |
| 159 | } |
| 160 | |
| 161 | _, err := data.UnmarshalMsg(buf) |
| 162 | if err != nil { |
| 163 | t.Errorf("Unexpected error for slice within limit: %v", err) |
| 164 | } |
| 165 | }) |
| 166 | } |
| 167 | |
| 168 | func TestNestedArrayLimits(t *testing.T) { |
| 169 | // Test limits on nested arrays within maps |
nothing calls this directly
no test coverage detected
searching dependent graphs…