============================================================================= Delete — empty key component leaves the payload unchanged, no panic (SYS-REQ-034 / SYS-REQ-035) ============================================================================= Verifies: SYS-REQ-034 [boundary] Verifies: SYS-R
(t *testing.T)
| 217 | // parser must return the original byte payload unchanged and must not panic |
| 218 | // on the `keys[lk-1][0]` dereference. |
| 219 | func TestDeleteEmptyKeyPathComponent(t *testing.T) { |
| 220 | cases := []struct { |
| 221 | name string |
| 222 | data string |
| 223 | keys []string |
| 224 | }{ |
| 225 | {name: "single empty key", data: `{"a":1,"b":2}`, keys: []string{""}}, |
| 226 | {name: "empty key trailing", data: `{"a":1}`, keys: []string{"a", ""}}, |
| 227 | {name: "empty key leading", data: `{"a":1}`, keys: []string{"", "a"}}, |
| 228 | } |
| 229 | for _, tc := range cases { |
| 230 | t.Run(tc.name, func(t *testing.T) { |
| 231 | var got []byte |
| 232 | runNoPanic(t, tc.name, func() { |
| 233 | got = Delete([]byte(tc.data), tc.keys...) |
| 234 | }) |
| 235 | want := []byte(tc.data) |
| 236 | if string(got) != string(want) { |
| 237 | t.Fatalf("Delete(%q,%v) = %q, want original payload %q (unchanged)", |
| 238 | tc.data, tc.keys, string(got), tc.data) |
| 239 | } |
| 240 | }) |
| 241 | } |
| 242 | } |
nothing calls this directly
no test coverage detected