Verifies: SYS-REQ-009 [boundary] MCDC SYS-REQ-009: N/A
(t *testing.T)
| 337 | // Verifies: SYS-REQ-009 [boundary] |
| 338 | // MCDC SYS-REQ-009: N/A |
| 339 | func TestSetSupplementalArrayInsertionCoverage(t *testing.T) { |
| 340 | t.Run("append into existing top level array path", func(t *testing.T) { |
| 341 | // When setting an index beyond the current array length for a |
| 342 | // primitive (non-object) array, the code overwrites rather than |
| 343 | // appends because createInsertComponent with object=true wraps |
| 344 | // the value. This is the actual parser behavior. |
| 345 | got, err := Set([]byte(`{"top":[1]}`), []byte(`2`), "top", "[1]") |
| 346 | if err != nil { |
| 347 | t.Fatalf("Set array append returned error: %v", err) |
| 348 | } |
| 349 | if string(got) != `{"top":[2]}` { |
| 350 | t.Fatalf("Set array append result = %s, want %s", string(got), `{"top":[2]}`) |
| 351 | } |
| 352 | }) |
| 353 | |
| 354 | t.Run("append object into nested existing array", func(t *testing.T) { |
| 355 | got, err := Set([]byte(`{"top":[{"middle":[{"present":true}]}]}`), []byte(`{"bottom":"value"}`), "top", "[0]", "middle", "[1]") |
| 356 | if err != nil { |
| 357 | t.Fatalf("Set nested array append returned error: %v", err) |
| 358 | } |
| 359 | if string(got) != `{"top":[{"middle":[{"present":true},{"bottom":"value"}]}]}` { |
| 360 | t.Fatalf("Set nested array append result = %s", string(got)) |
| 361 | } |
| 362 | }) |
| 363 | } |
| 364 | |
| 365 | // Verifies: SYS-REQ-014 [malformed] |
| 366 | // MCDC SYS-REQ-014: N/A |
nothing calls this directly
no test coverage detected
searching dependent graphs…