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

Function TestCompilePathGet

path_compiler_test.go:121–144  ·  view source on GitHub ↗

Verifies: SYS-REQ-001 (Get) 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

119// Verifies: SYS-REQ-114 (JSONPath compiled paths)
120// reqproof:proptest:skip targeted witness/regression test; not a property-test subject
121func TestCompilePathGet(t *testing.T) {
122 path, err := CompilePath("person.name")
123 if err != nil {
124 t.Fatalf("CompilePath returned error: %v", err)
125 }
126
127 tests := []struct {
128 data string
129 want string
130 }{
131 {data: `{"person":{"name":"Ada"}}`, want: "Ada"},
132 {data: `{"person":{"name":"Grace"}}`, want: "Grace"},
133 }
134
135 for _, test := range tests {
136 got, err := path.GetString([]byte(test.data))
137 if err != nil {
138 t.Fatalf("GetString(%s) returned error: %v", test.data, err)
139 }
140 if got != test.want {
141 t.Fatalf("GetString(%s) = %q, want %q", test.data, got, test.want)
142 }
143 }
144}
145
146// Verifies: SYS-REQ-009 (Set)
147// Verifies: SYS-REQ-114 (JSONPath compiled paths)

Callers

nothing calls this directly

Calls 2

CompilePathFunction · 0.85
GetStringMethod · 0.45

Tested by

no test coverage detected