export_test.go 558 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package bufio
  5. // Exported for testing only.
  6. import (
  7. "unicode/utf8"
  8. )
  9. var IsSpace = isSpace
  10. func (s *Scanner) MaxTokenSize(n int) {
  11. if n < utf8.UTFMax || n > 1e9 {
  12. panic("bad max token size")
  13. }
  14. if n < len(s.buf) {
  15. s.buf = make([]byte, n)
  16. }
  17. s.maxTokenSize = n
  18. }
  19. // ErrOrEOF is like Err, but returns EOF. Used to test a corner case.
  20. func (s *Scanner) ErrOrEOF() error {
  21. return s.err
  22. }