Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for ScanWords (0.07 sec)

  1. src/bufio/scan_test.go

    // Test that the word splitter returns the same data as strings.Fields.
    func TestScanWords(t *testing.T) {
    	for n, test := range wordScanTests {
    		buf := strings.NewReader(test)
    		s := NewScanner(buf)
    		s.Split(ScanWords)
    		words := strings.Fields(test)
    		var wordCount int
    		for wordCount = 0; wordCount < len(words); wordCount++ {
    			if !s.Scan() {
    				break
    			}
    			got := s.Text()
    			if got != words[wordCount] {
    Registered: Tue Nov 05 11:13:11 UTC 2024
    - Last Modified: Fri Sep 22 16:22:42 UTC 2023
    - 14.3K bytes
    - Viewed (0)
  2. src/bufio/scan.go

    		return true
    	}
    	return false
    }
    
    // ScanWords is a split function for a [Scanner] that returns each
    // space-separated word of text, with surrounding spaces deleted. It will
    // never return an empty string. The definition of space is set by
    // unicode.IsSpace.
    func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
    	// Skip leading spaces.
    	start := 0
    Registered: Tue Nov 05 11:13:11 UTC 2024
    - Last Modified: Mon Oct 23 09:06:30 UTC 2023
    - 14.2K bytes
    - Viewed (0)
Back to top