aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/scan_test.go
AgeCommit message (Collapse)Author
2026-02-03bufio: realign struct ScannerShulhan
This reduce the Scanner allocation size from 112 to 72 bytes.
2023-09-22all: clean unnecessary casts for test filesJes Cok
This is a follow up of CL 528696. Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5 GitHub-Last-Rev: acaf3ac11c38042ad27b99e1c70a3c9f1a554a15 GitHub-Pull-Request: golang/go#62713 Reviewed-on: https://go-review.googlesource.com/c/go/+/529197 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2020-06-17bufio: test for exact error value in TestNegativeEOFReader and TestLargeReaderDmitri Shuralyov
CL 225357 added tests for Scanner not panicking on bad readers. CL 225557 created a named error value that is returned instead. CL 237739 documents that the bufio.ErrBadReadCount is returned when bufio.Scanner is used with an invalid io.Reader. This suggests we wouldn't want that behavior to be able to change without a test noticing it, so modify the tests to check for the exact error value instead of just any non-nil one. For #38053. Change-Id: I4b0b8eb6804ebfe2c768505ddb94f0b1017fcf8b Reviewed-on: https://go-review.googlesource.com/c/go/+/238217 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-25bufio: don't panic when Scanner sees an impossible Read countIan Lance Taylor
Fixes #38053 Change-Id: Ib0f9777f37eeaa07eb8ecb6df3e97e9d4b46dcd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/225357 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2017-04-19all: remove redundant returnsDaniel Martí
Returns at the end of func bodies where the funcs have no return values are pointless. Change-Id: I0da5ea78671503e41a9f56dd770df8c919310ce5 Reviewed-on: https://go-review.googlesource.com/41093 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21all: delete dead test codeDominik Honnef
This deletes unused code and helpers from tests. Change-Id: Ie31d46115f558ceb8da6efbf90c3c204e03b0d7e Reviewed-on: https://go-review.googlesource.com/20927 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24all: fix typos and spellingMartin Möhrmann
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-25bufio: fix scanning with a final empty token.Rob Pike
The Scan function's interface to the split function was not sufficient to handle an empty final token in a pure function; state was required. This was ugly. We introduce a special error value that a split function can return that signals that this token is OK, but is the last one and scanning should stop immediately _after_ this token. The same effect could be achieved using the same trick (a special error value) and checking for that error after Scan finishes, but it's a little clumsy. Providing a published sentinel value in bufio is cleaner and means everyone can use the same trick. The result is an error-free scan. Rewrite the test (that was only barely working) to use the value and be more robust. Also write a new example showing how to do it. Fixes #11836 Change-Id: Iaae77d0f95b4a2efa0175ced94d93c66353079e8 Reviewed-on: https://go-review.googlesource.com/14924 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-18bufio: allow Scanner to accept a user-provided bufferRob Pike
Add Scanner.Buffer, which lets the user give a buffer to the scanner and set the maximum token size. We call it Buffer not SetBuffer for consistency with Split, which perhaps should have been called SetSplit; too late regardless. Both Buffer and Split panic if they are called after Scan. The panic in Split is new, but the comment on the method already said it needed to be called first, so we might as well add the verification while we're doing it for Buffer. This method allows precise user control of storage. Fixes #11702. Change-Id: I80e3d0e3830562fdabd4f7b08f322e1378248c39 Reviewed-on: https://go-review.googlesource.com/14599 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: roger peppe <rogpeppe@gmail.com>
2014-11-06bufio: remove unused 'panicked' variable from testAndrew Gerrand
LGTM=r R=r CC=golang-codereviews https://golang.org/cl/166230044
2014-11-05bufio: fix reading of many blank lines in a rowRuss Cox
Fixes #9020. LGTM=bradfitz, r R=r, bradfitz CC=golang-codereviews https://golang.org/cl/170030043
2014-11-06bufio: don't loop generating empty tokensRob Pike
The new rules for split functions mean that we are exposed to the common bug of a function that loops forever at EOF. Pick these off by shutting down the scanner if too many consecutive empty tokens are delivered. Fixes #9020. LGTM=rsc, adg R=golang-codereviews, rsc, adg, bradfitz CC=golang-codereviews https://golang.org/cl/169970043
2014-09-25bufio: fix handling of empty tokens at end of line/fileRob Pike
Fixes #8672. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://golang.org/cl/145390043
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.