MCPcopy
hub / github.com/pquerna/ffjson / TestCapture

Function TestCapture

fflib/v1/lexer_test.go:306–327  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

304}
305
306func TestCapture(t *testing.T) {
307 ffl := NewFFLexer([]byte(`{"hello": {"blah": [null, 1]}}`))
308
309 err := scanToTok(ffl, FFTok_left_bracket)
310 if err != nil {
311 t.Fatalf("scanToTok failed: %v", err)
312 }
313
314 err = scanToTok(ffl, FFTok_left_bracket)
315 if err != nil {
316 t.Fatalf("scanToTok failed: %v", err)
317 }
318
319 buf, err := ffl.CaptureField(FFTok_left_bracket)
320 if err != nil {
321 t.Fatalf("CaptureField failed: %v", err)
322 }
323
324 if bytes.Compare(buf, []byte(`{"blah": [null, 1]}`)) != 0 {
325 t.Fatalf("didnt capture subfield: buf: %v", string(buf))
326 }
327}

Callers

nothing calls this directly

Calls 4

CaptureFieldMethod · 0.95
NewFFLexerFunction · 0.85
scanToTokFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…