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)
| 119 | // Verifies: SYS-REQ-114 (JSONPath compiled paths) |
| 120 | // reqproof:proptest:skip targeted witness/regression test; not a property-test subject |
| 121 | func 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) |
nothing calls this directly
no test coverage detected