98
97
func TestFp(t *testing.T) {
99
f, err := os.Open("testfp.txt")
98
f, err := os.Open("testdata/testfp.txt")
101
t.Fatal("testfp: open testfp.txt:", err)
100
t.Fatal("testfp: open testdata/testfp.txt:", err)
105
b := bufio.NewReader(f)
104
s := bufio.NewScanner(f)
109
line, err2 := b.ReadString('\n')
114
t.Fatal("testfp: read testfp.txt: " + err2.Error())
116
line = line[0 : len(line)-1]
106
for lineno := 1; s.Scan(); lineno++ {
118
108
if len(line) == 0 || line[0] == '#' {
121
111
a := strings.Split(line, " ")
123
t.Error("testfp.txt:", lineno, ": wrong field count")
113
t.Error("testdata/testfp.txt:", lineno, ": wrong field count")
131
121
v, ok = myatof64(a[2])
133
t.Error("testfp.txt:", lineno, ": cannot atof64 ", a[2])
123
t.Error("testdata/testfp.txt:", lineno, ": cannot atof64 ", a[2])
136
126
s = fmt.Sprintf(a[1], v)
138
128
v1, ok := myatof32(a[2])
140
t.Error("testfp.txt:", lineno, ": cannot atof32 ", a[2])
130
t.Error("testdata/testfp.txt:", lineno, ": cannot atof32 ", a[2])
143
133
s = fmt.Sprintf(a[1], v1)
147
t.Error("testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ",
137
t.Error("testdata/testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ",
148
138
"want ", a[3], " got ", s)
142
t.Fatal("testfp: read testdata/testfp.txt: ", s.Err())