Commit f5743715 authored by Rob Pike's avatar Rob Pike

strconv: use Scanner in fp_test

R=rsc
CC=golang-dev
https://golang.org/cl/7385045
parent f9138301
...@@ -7,7 +7,6 @@ package strconv_test ...@@ -7,7 +7,6 @@ package strconv_test
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"io"
"os" "os"
"strconv" "strconv"
"strings" "strings"
...@@ -102,19 +101,10 @@ func TestFp(t *testing.T) { ...@@ -102,19 +101,10 @@ func TestFp(t *testing.T) {
} }
defer f.Close() defer f.Close()
b := bufio.NewReader(f) s := bufio.NewScanner(f)
lineno := 0 for lineno := 1; s.Scan(); lineno++ {
for { line := s.Text()
line, err2 := b.ReadString('\n')
if err2 == io.EOF {
break
}
if err2 != nil {
t.Fatal("testfp: read testdata/testfp.txt: " + err2.Error())
}
line = line[0 : len(line)-1]
lineno++
if len(line) == 0 || line[0] == '#' { if len(line) == 0 || line[0] == '#' {
continue continue
} }
...@@ -148,4 +138,7 @@ func TestFp(t *testing.T) { ...@@ -148,4 +138,7 @@ func TestFp(t *testing.T) {
"want ", a[3], " got ", s) "want ", a[3], " got ", s)
} }
} }
if s.Err() != nil {
t.Fatal("testfp: read testdata/testfp.txt: ", s.Err())
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment