diff options
author | Cameron Moore <moorereason@gmail.com> | 2016-05-07 16:34:53 -0500 |
---|---|---|
committer | Cameron Moore <moorereason@gmail.com> | 2016-06-25 17:57:05 -0500 |
commit | e2aea65170985d7428c468ce0591557ad95af884 (patch) | |
tree | 2c7e21e00b2b57f829426a690442095e46e73483 /helpers | |
parent | 29ca323a34e8f6e673c70a1af9c9f95a916229bd (diff) |
helpers: Remove ToReader funcs
Remove StringToReader and BytesToReader in favor of using the stdlib directly.
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/general.go | 10 | ||||
-rw-r--r-- | helpers/general_test.go | 21 |
2 files changed, 4 insertions, 27 deletions
diff --git a/helpers/general.go b/helpers/general.go index 8d627831c..731452d9d 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -130,16 +130,6 @@ func ReaderToString(lines io.Reader) string { return b.String() } -// StringToReader does the opposite of ReaderToString. -func StringToReader(in string) io.Reader { - return strings.NewReader(in) -} - -// BytesToReader does the opposite of ReaderToBytes. -func BytesToReader(in []byte) io.Reader { - return bytes.NewReader(in) -} - // ReaderContains reports whether subslice is within r. func ReaderContains(r io.Reader, subslice []byte) bool { diff --git a/helpers/general_test.go b/helpers/general_test.go index e735620ca..089bb9b1a 100644 --- a/helpers/general_test.go +++ b/helpers/general_test.go @@ -14,10 +14,11 @@ package helpers import ( - "github.com/stretchr/testify/assert" "reflect" "strings" "testing" + + "github.com/stretchr/testify/assert" ) func TestGuessType(t *testing.T) { @@ -62,20 +63,6 @@ func TestFirstUpper(t *testing.T) { } } -func TestBytesToReader(t *testing.T) { - asBytes := ReaderToBytes(strings.NewReader("Hello World!")) - asReader := BytesToReader(asBytes) - assert.Equal(t, []byte("Hello World!"), asBytes) - assert.Equal(t, asBytes, ReaderToBytes(asReader)) -} - -func TestStringToReader(t *testing.T) { - asString := ReaderToString(strings.NewReader("Hello World!")) - assert.Equal(t, "Hello World!", asString) - asReader := StringToReader(asString) - assert.Equal(t, asString, ReaderToString(asReader)) -} - var containsTestText = (`На берегу пустынных волн Стоял он, дум великих полн, И вдаль глядел. Пред ним широко @@ -136,7 +123,7 @@ var containsAdditionalTestData = []struct { func TestReaderContains(t *testing.T) { for i, this := range append(containsBenchTestData, containsAdditionalTestData...) { - result := ReaderContains(StringToReader(this.v1), this.v2) + result := ReaderContains(strings.NewReader(this.v1), this.v2) if result != this.expect { t.Errorf("[%d] got %t but expected %t", i, result, this.expect) } @@ -150,7 +137,7 @@ func BenchmarkReaderContains(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { for i, this := range containsBenchTestData { - result := ReaderContains(StringToReader(this.v1), this.v2) + result := ReaderContains(strings.NewReader(this.v1), this.v2) if result != this.expect { b.Errorf("[%d] got %t but expected %t", i, result, this.expect) } |