MCPcopy Create free account
hub / github.com/buger/jsonparser / TestCodeMCDC_SearchKeysKeyLevelMismatch

Function TestCodeMCDC_SearchKeysKeyLevelMismatch

mcdc_supplement_test.go:821–834  ·  view source on GitHub ↗

Verifies: SYS-REQ-001 [boundary] Code MC/DC gap: parser.go:289 searchKeys keyLevel == level-1 Drive keyLevel != level-1 (FALSE branch). Use duplicate keys so keyLevel advances past the expected level.

(t *testing.T)

Source from the content-addressed store, hash-verified

819// Drive keyLevel != level-1 (FALSE branch).
820// Use duplicate keys so keyLevel advances past the expected level.
821func TestCodeMCDC_SearchKeysKeyLevelMismatch(t *testing.T) {
822 // In {"a":1,"a":{"b":2}}, searching for ["a","b"]:
823 // First "a" at level 1 matches keys[0], keyLevel becomes 1.
824 // Second "a" at level 1: equalStr matches keys[0]="a", but
825 // keyLevel(1) != level-1(0) — FALSE branch exercised.
826 // Then we descend into {"b":2} and find "b".
827 val, _, _, err := Get([]byte(`{"a":1,"a":{"b":2}}`), "a", "b")
828 if err != nil {
829 t.Fatalf("Get duplicate-key path error: %v", err)
830 }
831 if string(val) != "2" {
832 t.Fatalf("Get duplicate-key path = %q, want %q", string(val), "2")
833 }
834}
835
836// Verifies: SYS-REQ-001 [boundary]
837// Code MC/DC gap: parser.go:327 searchKeys keys[level][0] != '['

Callers

nothing calls this directly

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected