]> Cypherpunks repositories - gostls13.git/commitdiff
strconv: use Scanner in fp_test
authorRob Pike <r@golang.org>
Wed, 20 Feb 2013 21:38:19 +0000 (13:38 -0800)
committerRob Pike <r@golang.org>
Wed, 20 Feb 2013 21:38:19 +0000 (13:38 -0800)
R=rsc
CC=golang-dev
https://golang.org/cl/7385045

src/pkg/strconv/fp_test.go

index 294b7a9bfbb50e2b9cd199fb1111a3dfcfb5d133..6de2f8bc6f2f10741c456948527580f3e8722546 100644 (file)
@@ -7,7 +7,6 @@ package strconv_test
 import (
        "bufio"
        "fmt"
-       "io"
        "os"
        "strconv"
        "strings"
@@ -102,19 +101,10 @@ func TestFp(t *testing.T) {
        }
        defer f.Close()
 
-       b := bufio.NewReader(f)
+       s := bufio.NewScanner(f)
 
-       lineno := 0
-       for {
-               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++
+       for lineno := 1; s.Scan(); lineno++ {
+               line := s.Text()
                if len(line) == 0 || line[0] == '#' {
                        continue
                }
@@ -148,4 +138,7 @@ func TestFp(t *testing.T) {
                                "want ", a[3], " got ", s)
                }
        }
+       if s.Err() != nil {
+               t.Fatal("testfp: read testdata/testfp.txt: ", s.Err())
+       }
 }