mirror of
https://github.com/golang/go.git
synced 2024-09-22 02:48:50 +00:00
embed/internal/embedtest: test openFile.ReadAt with non-zero offset
Also fix log messages to report expected values in the standard "got foo, want bar" format. Change-Id: I6a9fd4abe1f86c2651c72c2bf7ac4588028e5923 Reviewed-on: https://go-review.googlesource.com/c/go/+/484715 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
parent
750e91152b
commit
5da1f41513
@ -184,7 +184,7 @@ func TestOffset(t *testing.T) {
|
||||
t.Fatal("Open:", err)
|
||||
}
|
||||
|
||||
const want = "hello, world\n"
|
||||
want := "hello, world\n"
|
||||
|
||||
// Read the entire file.
|
||||
got := make([]byte, len(want))
|
||||
@ -227,9 +227,24 @@ func TestOffset(t *testing.T) {
|
||||
t.Fatal("ReadAt:", err)
|
||||
}
|
||||
if n != len(want) {
|
||||
t.Fatal("ReadAt:", n)
|
||||
t.Fatalf("ReadAt: got %d bytes, want %d bytes", n, len(want))
|
||||
}
|
||||
if string(got) != want {
|
||||
t.Fatalf("ReadAt: %q", got)
|
||||
t.Fatalf("ReadAt: got %q, want %q", got, want)
|
||||
}
|
||||
|
||||
// Use ReadAt with non-zero offset.
|
||||
off = int64(7)
|
||||
want = want[off:]
|
||||
got = make([]byte, len(want))
|
||||
n, err = at.ReadAt(got, off)
|
||||
if err != nil {
|
||||
t.Fatal("ReadAt:", err)
|
||||
}
|
||||
if n != len(want) {
|
||||
t.Fatalf("ReadAt: got %d bytes, want %d bytes", n, len(want))
|
||||
}
|
||||
if string(got) != want {
|
||||
t.Fatalf("ReadAt: got %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user