MCPcopy
hub / github.com/valyala/quicktemplate / testScannerSuccess

Function testScannerSuccess

parser/scanner_test.go:307–323  ·  view source on GitHub ↗
(t *testing.T, str string, expectedTokens []tt)

Source from the content-addressed store, hash-verified

305}
306
307func testScannerSuccess(t *testing.T, str string, expectedTokens []tt) {
308 r := bytes.NewBufferString(str)
309 s := newScanner(r, "memory")
310 var tokens []tt
311 for s.Next() {
312 tokens = append(tokens, tt{
313 ID: s.Token().ID,
314 Value: string(s.Token().Value),
315 })
316 }
317 if err := s.LastError(); err != nil {
318 t.Fatalf("unexpected error: %s. str=%q", err, str)
319 }
320 if !reflect.DeepEqual(tokens, expectedTokens) {
321 t.Fatalf("unexpected tokens %v. Expecting %v. str=%q", tokens, expectedTokens, str)
322 }
323}
324
325type tt struct {
326 ID int

Calls 4

newScannerFunction · 0.85
NextMethod · 0.80
TokenMethod · 0.80
LastErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…