From a1231839b531b15e9745e92fe2396456029729a1 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Tue, 22 Jan 2013 13:44:35 -0800 Subject: [PATCH] mime, strconv: Make testdata more consistent. All packages place testdata in a specific directory with the name "testdata". The mime and strconv packages have been updated to use the same convention. mime: Move "mime/test.types" to "mime/testdata/test.types". Update test code accordingly. strconv: Move "strconv/testfp.txt" to "strconv/testdata/testfp.txt". Update test code accordingly. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7098072 --- src/pkg/mime/{ => testdata}/test.types | 0 src/pkg/mime/type_unix.go | 2 +- src/pkg/strconv/fp_test.go | 14 +++++++------- src/pkg/strconv/{ => testdata}/testfp.txt | 0 4 files changed, 8 insertions(+), 8 deletions(-) rename src/pkg/mime/{ => testdata}/test.types (100%) rename src/pkg/strconv/{ => testdata}/testfp.txt (100%) diff --git a/src/pkg/mime/test.types b/src/pkg/mime/testdata/test.types similarity index 100% rename from src/pkg/mime/test.types rename to src/pkg/mime/testdata/test.types diff --git a/src/pkg/mime/type_unix.go b/src/pkg/mime/type_unix.go index 2dab1eac78d..88eb83a735d 100644 --- a/src/pkg/mime/type_unix.go +++ b/src/pkg/mime/type_unix.go @@ -52,7 +52,7 @@ func initMime() { } func initMimeForTests() map[string]string { - typeFiles = []string{"test.types"} + typeFiles = []string{"testdata/test.types"} return map[string]string{ ".t1": "application/test", ".t2": "text/test; charset=utf-8", diff --git a/src/pkg/strconv/fp_test.go b/src/pkg/strconv/fp_test.go index 171defa4417..294b7a9bfbb 100644 --- a/src/pkg/strconv/fp_test.go +++ b/src/pkg/strconv/fp_test.go @@ -96,9 +96,9 @@ func myatof32(s string) (f float32, ok bool) { } func TestFp(t *testing.T) { - f, err := os.Open("testfp.txt") + f, err := os.Open("testdata/testfp.txt") if err != nil { - t.Fatal("testfp: open testfp.txt:", err) + t.Fatal("testfp: open testdata/testfp.txt:", err) } defer f.Close() @@ -111,7 +111,7 @@ func TestFp(t *testing.T) { break } if err2 != nil { - t.Fatal("testfp: read testfp.txt: " + err2.Error()) + t.Fatal("testfp: read testdata/testfp.txt: " + err2.Error()) } line = line[0 : len(line)-1] lineno++ @@ -120,7 +120,7 @@ func TestFp(t *testing.T) { } a := strings.Split(line, " ") if len(a) != 4 { - t.Error("testfp.txt:", lineno, ": wrong field count") + t.Error("testdata/testfp.txt:", lineno, ": wrong field count") continue } var s string @@ -130,21 +130,21 @@ func TestFp(t *testing.T) { var ok bool v, ok = myatof64(a[2]) if !ok { - t.Error("testfp.txt:", lineno, ": cannot atof64 ", a[2]) + t.Error("testdata/testfp.txt:", lineno, ": cannot atof64 ", a[2]) continue } s = fmt.Sprintf(a[1], v) case "float32": v1, ok := myatof32(a[2]) if !ok { - t.Error("testfp.txt:", lineno, ": cannot atof32 ", a[2]) + t.Error("testdata/testfp.txt:", lineno, ": cannot atof32 ", a[2]) continue } s = fmt.Sprintf(a[1], v1) v = float64(v1) } if s != a[3] { - t.Error("testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ", + t.Error("testdata/testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ", "want ", a[3], " got ", s) } } diff --git a/src/pkg/strconv/testfp.txt b/src/pkg/strconv/testdata/testfp.txt similarity index 100% rename from src/pkg/strconv/testfp.txt rename to src/pkg/strconv/testdata/testfp.txt