MCPcopy Index your code
hub / github.com/bitfield/script / TestFirstDoesNotConsumeUnnecessaryData

Function TestFirstDoesNotConsumeUnnecessaryData

script_test.go:579–595  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

577}
578
579func TestFirstDoesNotConsumeUnnecessaryData(t *testing.T) {
580 t.Parallel()
581 // First uses a 4096-byte buffer, so will always read at least
582 // that much, but no more (once N lines have been read).
583 r := strings.NewReader(strings.Repeat("line\n", 1000))
584 got, err := script.NewPipe().WithReader(r).First(1).String()
585 if err != nil {
586 t.Fatal(err)
587 }
588 want := "line\n"
589 if want != got {
590 t.Errorf("want output %q, got %q", want, got)
591 }
592 if r.Len() == 0 {
593 t.Errorf("no data left in reader")
594 }
595}
596
597func TestFreqHandlesLongLines(t *testing.T) {
598 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewPipeFunction · 0.92
StringMethod · 0.80
FirstMethod · 0.80
WithReaderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…