============================================================================= Delete truncation tests (SYS-REQ-048, SYS-REQ-049, SYS-REQ-050, SYS-REQ-056) ============================================================================= Verifies: SYS-REQ-048 [malformed] Delete on input truncated at a va
(t *testing.T)
| 198 | // Delete on input truncated at a value boundary (the PR #280 case) shall |
| 199 | // return the original input unchanged and shall not panic. |
| 200 | func TestDeleteTruncatedAtValueBoundary(t *testing.T) { |
| 201 | cases := []struct { |
| 202 | name string |
| 203 | data string |
| 204 | keys []string |
| 205 | }{ |
| 206 | {name: "PR280 case object", data: `{"test":1`, keys: []string{"test"}}, |
| 207 | {name: "truncated after colon", data: `{"a":`, keys: []string{"a"}}, |
| 208 | {name: "truncated number", data: `{"a":123`, keys: []string{"a"}}, |
| 209 | } |
| 210 | for _, tc := range cases { |
| 211 | t.Run(tc.name, func(t *testing.T) { |
| 212 | func() { |
| 213 | defer func() { |
| 214 | if r := recover(); r != nil { |
| 215 | t.Fatalf("Delete(%q, %v) panicked: %v", tc.data, tc.keys, r) |
| 216 | } |
| 217 | }() |
| 218 | result := Delete([]byte(tc.data), tc.keys...) |
| 219 | // On error, Delete returns original input unchanged |
| 220 | if string(result) != tc.data { |
| 221 | t.Logf("Delete(%q, %v) = %q (modified, may be valid)", tc.data, tc.keys, string(result)) |
| 222 | } |
| 223 | }() |
| 224 | }) |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // Verifies: SYS-REQ-049 [malformed] |
| 229 | // Delete where internalGet returns an error shall return original input unchanged. |