Simplify OffsetWriter

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2020-12-10 18:15:43 +03:00
parent 8168181658
commit 8ff289ea4f
2 changed files with 11 additions and 21 deletions

View file

@ -12,7 +12,7 @@ type offsetWriter struct {
length int64
}
func newWriter(w io.Writer, offset, length int64) io.Writer {
func newWriter(w io.Writer, offset, length int64) *offsetWriter {
return &offsetWriter{
Writer: w,
offset: offset,

View file

@ -33,10 +33,8 @@ func TestOffsetWriter(t *testing.T) {
require.NoError(t, err)
}
wo := wt.(*offsetWriter)
require.Equal(t, o, wo.skipped)
require.Equal(t, l, wo.written)
require.Equal(t, o, wt.skipped)
require.Equal(t, l, wt.written)
require.Equal(t, b[o:o+l], w.Bytes())
})
@ -51,10 +49,8 @@ func TestOffsetWriter(t *testing.T) {
require.NoError(t, err)
}
wo := wt.(*offsetWriter)
require.Equal(t, o, wo.skipped)
require.Equal(t, l, wo.written)
require.Equal(t, o, wt.skipped)
require.Equal(t, l, wt.written)
require.Equal(t, b[o:o+l], w.Bytes())
})
@ -69,10 +65,8 @@ func TestOffsetWriter(t *testing.T) {
require.NoError(t, err)
}
wo := wt.(*offsetWriter)
require.Equal(t, o, wo.skipped)
require.Equal(t, l, wo.written)
require.Equal(t, o, wt.skipped)
require.Equal(t, l, wt.written)
require.Equal(t, b[o:o+l], w.Bytes())
})
@ -87,10 +81,8 @@ func TestOffsetWriter(t *testing.T) {
require.NoError(t, err)
}
wo := wt.(*offsetWriter)
require.Equal(t, o, wo.skipped)
require.Equal(t, s, wo.written)
require.Equal(t, o, wt.skipped)
require.Equal(t, s, wt.written)
require.Equal(t, b, w.Bytes())
})
@ -105,10 +97,8 @@ func TestOffsetWriter(t *testing.T) {
require.NoError(t, err)
}
wo := wt.(*offsetWriter)
require.Equal(t, o, wo.skipped)
require.Equal(t, s, wo.written)
require.Equal(t, o, wt.skipped)
require.Equal(t, s, wt.written)
require.Equal(t, b, w.Bytes())
})
}