OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package strconv_test | 5 package strconv_test |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "fmt" | 9 "fmt" |
10 "os" | 10 "os" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 f1, err1 := strconv.Atof32(s) | 89 f1, err1 := strconv.Atof32(s) |
90 if err1 != nil { | 90 if err1 != nil { |
91 return 0, false | 91 return 0, false |
92 } | 92 } |
93 return f1, true | 93 return f1, true |
94 } | 94 } |
95 | 95 |
96 func TestFp(t *testing.T) { | 96 func TestFp(t *testing.T) { |
97 f, err := os.Open("testfp.txt") | 97 f, err := os.Open("testfp.txt") |
98 if err != nil { | 98 if err != nil { |
99 » » t.Fatal("testfp: open testfp.txt:", err.String()) | 99 » » t.Fatal("testfp: open testfp.txt:", err) |
100 } | 100 } |
101 defer f.Close() | 101 defer f.Close() |
102 | 102 |
103 b := bufio.NewReader(f) | 103 b := bufio.NewReader(f) |
104 | 104 |
105 lineno := 0 | 105 lineno := 0 |
106 for { | 106 for { |
107 line, err2 := b.ReadString('\n') | 107 line, err2 := b.ReadString('\n') |
108 if err2 == os.EOF { | 108 if err2 == os.EOF { |
109 break | 109 break |
(...skipping 30 matching lines...) Expand all Loading... |
140 } | 140 } |
141 s = fmt.Sprintf(a[1], v1) | 141 s = fmt.Sprintf(a[1], v1) |
142 v = float64(v1) | 142 v = float64(v1) |
143 } | 143 } |
144 if s != a[3] { | 144 if s != a[3] { |
145 t.Error("testfp.txt:", lineno, ": ", a[0], " ", a[1], "
", a[2], " (", v, ") ", | 145 t.Error("testfp.txt:", lineno, ": ", a[0], " ", a[1], "
", a[2], " (", v, ") ", |
146 "want ", a[3], " got ", s) | 146 "want ", a[3], " got ", s) |
147 } | 147 } |
148 } | 148 } |
149 } | 149 } |
OLD | NEW |