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

Function TestCompiledPathPartsReturnsCopy

path_compiler_test.go:274–290  ·  view source on GitHub ↗

Verifies: SYS-REQ-114 (JSONPath compiled paths) reqproof:proptest:skip targeted witness/regression test; not a property-test subject

(t *testing.T)

Source from the content-addressed store, hash-verified

272// Verifies: SYS-REQ-114 (JSONPath compiled paths)
273// reqproof:proptest:skip targeted witness/regression test; not a property-test subject
274func TestCompiledPathPartsReturnsCopy(t *testing.T) {
275 path, err := CompilePath("person.name")
276 if err != nil {
277 t.Fatalf("CompilePath returned error: %v", err)
278 }
279
280 parts := path.Parts()
281 parts[0] = "changed"
282
283 got, err := path.GetString([]byte(`{"person":{"name":"Ada"},"changed":{"name":"Grace"}}`))
284 if err != nil {
285 t.Fatalf("GetString returned error: %v", err)
286 }
287 if got != "Ada" {
288 t.Fatalf("mutating Parts changed compiled path: got %q, want Ada", got)
289 }
290}
291
292func BenchmarkParsePath(b *testing.B) {
293 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 3

CompilePathFunction · 0.85
PartsMethod · 0.80
GetStringMethod · 0.45

Tested by

no test coverage detected