summaryrefslogtreecommitdiff
path: root/src/lib/strconv/testfp.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-11-19 14:38:05 -0800
committerRob Pike <r@golang.org>2008-11-19 14:38:05 -0800
commitc0214c3d90c3d51fd6f6d9f0df18c8b03897c762 (patch)
tree1730d4f615a2188091ddbbd363141a06796eeae5 /src/lib/strconv/testfp.go
parent8b15e7853c171cf417707aeed2460fc5cf37a377 (diff)
downloadgolang-c0214c3d90c3d51fd6f6d9f0df18c8b03897c762.tar.gz
add a type testing.T and use it in tests.
update uses of gotest. minor tweak to testing structure for protobuf. R=rsc DELTA=276 (71 added, 75 deleted, 130 changed) OCL=19614 CL=19621
Diffstat (limited to 'src/lib/strconv/testfp.go')
-rw-r--r--src/lib/strconv/testfp.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lib/strconv/testfp.go b/src/lib/strconv/testfp.go
index 0518c528a..6665a9c00 100644
--- a/src/lib/strconv/testfp.go
+++ b/src/lib/strconv/testfp.go
@@ -9,6 +9,7 @@ import (
"os";
"strconv";
"strings";
+ "testing";
)
func pow2(i int) float64 {
@@ -91,7 +92,7 @@ func myatof32(s string) (f float32, ok bool) {
return f1, true;
}
-export func TestFp() bool {
+export func TestFp(t *testing.T) {
fd, err := os.Open("testfp.txt", os.O_RDONLY, 0);
if err != nil {
panicln("testfp: open testfp.txt:", err.String());
@@ -103,7 +104,6 @@ export func TestFp() bool {
}
lineno := 0;
- ok := true;
for {
line, err2 := b.ReadLineString('\n', false);
if err2 == bufio.EndOfFile {
@@ -118,7 +118,7 @@ export func TestFp() bool {
}
a := strings.split(line, " ");
if len(a) != 4 {
- print("testfp.txt:", lineno, ": wrong field count\n");
+ t.Errorf("testfp.txt:", lineno, ": wrong field count\n");
continue;
}
var s string;
@@ -128,25 +128,23 @@ export func TestFp() bool {
var ok bool;
v, ok = myatof64(a[2]);
if !ok {
- print("testfp.txt:", lineno, ": cannot atof64 ", a[2]);
+ t.Errorf("testfp.txt:", lineno, ": cannot atof64 ", a[2]);
continue;
}
s = fmt.sprintf(a[1], v);
case "float32":
v1, ok := myatof32(a[2]);
if !ok {
- print("testfp.txt:", lineno, ": cannot atof32 ", a[2]);
+ t.Errorf("testfp.txt:", lineno, ": cannot atof32 ", a[2]);
continue;
}
s = fmt.sprintf(a[1], v1);
v = float64(v1);
}
if s != a[3] {
- print("testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ",
+ t.Errorf("testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ",
"want ", a[3], " got ", s, "\n");
- ok = false;
}
//else print("testfp.txt:", lineno, ": worked! ", s, "\n");
}
- return ok;
}