diff options
| author | Russ Cox <rsc@golang.org> | 2025-10-16 23:21:14 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2025-10-21 11:33:43 -0700 |
| commit | c9c78c06ef4eac034c99efedfb4d23a3d51c1d6c (patch) | |
| tree | 1a2ff127736c945df4ab02acda5a260579eac3ca /src/strconv | |
| parent | 8f74f9daf4d2fe708cf28d0e2b9cce079fa19248 (diff) | |
| download | go-c9c78c06ef4eac034c99efedfb4d23a3d51c1d6c.tar.xz | |
strconv: embed testdata in test
This makes it easier to run test binaries on remote machines.
Change-Id: I3e5bc6cf10272a6743fd5d16ab1089d46f53232c
Reviewed-on: https://go-review.googlesource.com/c/go/+/712660
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/strconv')
| -rw-r--r-- | src/strconv/fp_test.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/strconv/fp_test.go b/src/strconv/fp_test.go index fd73958c97..376e8f591c 100644 --- a/src/strconv/fp_test.go +++ b/src/strconv/fp_test.go @@ -6,8 +6,8 @@ package strconv_test import ( "bufio" + _ "embed" "fmt" - "os" "strconv" "strings" "testing" @@ -92,15 +92,11 @@ func myatof32(s string) (f float32, ok bool) { return f1, true } -func TestFp(t *testing.T) { - f, err := os.Open("testdata/testfp.txt") - if err != nil { - t.Fatal("testfp: open testdata/testfp.txt:", err) - } - defer f.Close() - - s := bufio.NewScanner(f) +//go:embed testdata/testfp.txt +var testfp string +func TestFp(t *testing.T) { + s := bufio.NewScanner(strings.NewReader(testfp)) for lineno := 1; s.Scan(); lineno++ { line := s.Text() if len(line) == 0 || line[0] == '#' { |
