From 9ad090c5fea60c9925b7eb30155ce01961c3537f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 18 Jul 2020 22:26:00 -0400 Subject: testing/iotest: add TestReader to test readers There are many reader behaviors that are subtle and worth testing, and it's nice to have one complete tester instead of many incomplete ones. For #41190, which will use this as part of a larger file system implementation tester. Change-Id: Ib4cc7fae94b0d9b45dfacadc52baa77ad3761322 Reviewed-on: https://go-review.googlesource.com/c/go/+/243909 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Rob Pike Reviewed-by: Emmanuel Odeke --- src/testing/iotest/reader_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/testing/iotest/reader_test.go') diff --git a/src/testing/iotest/reader_test.go b/src/testing/iotest/reader_test.go index 6004e841e5..f149e74c74 100644 --- a/src/testing/iotest/reader_test.go +++ b/src/testing/iotest/reader_test.go @@ -8,6 +8,7 @@ import ( "bytes" "errors" "io" + "strings" "testing" ) @@ -249,3 +250,12 @@ func TestErrReader(t *testing.T) { }) } } + +func TestStringsReader(t *testing.T) { + const msg = "Now is the time for all good gophers." + + r := strings.NewReader(msg) + if err := TestReader(r, []byte(msg)); err != nil { + t.Fatal(err) + } +} -- cgit v1.2.1