revid: addressing PR feedback

This commit is contained in:
Saxon 2019-04-23 13:18:41 +09:30
parent 9ba72fac62
commit e5f95d1ea0
3 changed files with 19 additions and 7 deletions

View File

@ -74,7 +74,7 @@ func TestEncodePcm(t *testing.T) {
}
}
}
clip := (*bytes.Buffer)(&buf).Bytes()
clip := buf.Bytes()
// Get the first MTS packet to check
var pkt packet.Packet

View File

@ -53,7 +53,7 @@ func TestMetaEncode1(t *testing.T) {
if err := e.writePSI(); err != nil {
t.Errorf(errUnexpectedErr, err.Error())
}
out := (*bytes.Buffer)(&buf).Bytes()
out := buf.Bytes()
got := out[PacketSize+4:]
want := []byte{
@ -82,7 +82,7 @@ func TestMetaEncode2(t *testing.T) {
if err := e.writePSI(); err != nil {
t.Errorf(errUnexpectedErr, err.Error())
}
out := (*bytes.Buffer)(&buf).Bytes()
out := buf.Bytes()
got := out[PacketSize+4:]
want := []byte{
0x00, 0x02, 0xb0, 0x36, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x24,

View File

@ -95,21 +95,33 @@ func (tl *testLogger) Log(level int8, msg string, params ...interface{}) {
// tstMtsEncoder emulates the mts.Encoder to the extent of the dst field.
// This will allow access to the dst to check that it has been set corrctly.
type tstMtsEncoder struct{ dst io.WriteCloser }
type tstMtsEncoder struct {
// dst is here soley to detect the type stored in the encoder.
// No data is written to dst.
dst io.WriteCloser
}
func (e *tstMtsEncoder) Write(d []byte) (int, error) { return len(d), nil }
func (e *tstMtsEncoder) Close() error { return nil }
// tstFlvEncoder emulates the flv.Encoder to the extent of the dst field.
// This will allow access to the dst to check that it has been set corrctly.
type tstFlvEncoder struct{ dst io.WriteCloser }
type tstFlvEncoder struct {
// dst is here soley to detect the type stored in the encoder.
// No data is written to dst.
dst io.WriteCloser
}
func (e *tstFlvEncoder) Write(d []byte) (int, error) { return len(d), nil }
func (e *tstFlvEncoder) Close() error { return nil }
// dummyMultiWriter emulates the MultiWriter provided by std lib, so that we
// can access the destinations.
type dummyMultiWriter struct{ dst []io.WriteCloser }
type dummyMultiWriter struct {
// dst is here soley to detect the types stored in the multiWriter.
// No data is written to dst.
dst []io.WriteCloser
}
func (w *dummyMultiWriter) Write(d []byte) (int, error) { return len(d), nil }
func (w *dummyMultiWriter) Close() error { return nil }
@ -259,7 +271,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
}
// Now check that this encoder has correct number of destinations (senders).
var ms io.Writer
var ms io.WriteCloser
switch encoderType {
case mtsEncoderStr:
ms = e.(*tstMtsEncoder).dst