mirror of https://bitbucket.org/ausocean/av.git
container/mts: not using string consts for error messages
This commit is contained in:
parent
3696e353f2
commit
edb056d19b
|
@ -253,11 +253,6 @@ func TestEncodePcm(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
errNotExpectedOut = "Unexpected output. \n Got : %v\n, Want: %v\n"
|
|
||||||
errUnexpectedErr = "Unexpected error: %v\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
const fps = 25
|
const fps = 25
|
||||||
|
|
||||||
// TestMetaEncode1 checks that we can externally add a single metadata entry to
|
// TestMetaEncode1 checks that we can externally add a single metadata entry to
|
||||||
|
@ -269,7 +264,7 @@ func TestMetaEncode1(t *testing.T) {
|
||||||
e := NewEncoder(nopCloser{&buf}, fps, EncodeH264)
|
e := NewEncoder(nopCloser{&buf}, fps, EncodeH264)
|
||||||
Meta.Add("ts", "12345678")
|
Meta.Add("ts", "12345678")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf(errUnexpectedErr, err.Error())
|
t.Errorf("unexpected error: %v\n", err.Error())
|
||||||
}
|
}
|
||||||
out := buf.Bytes()
|
out := buf.Bytes()
|
||||||
got := out[PacketSize+4:]
|
got := out[PacketSize+4:]
|
||||||
|
@ -284,7 +279,7 @@ func TestMetaEncode1(t *testing.T) {
|
||||||
want = psi.AddCrc(want)
|
want = psi.AddCrc(want)
|
||||||
want = psi.AddPadding(want)
|
want = psi.AddPadding(want)
|
||||||
if !bytes.Equal(got, want) {
|
if !bytes.Equal(got, want) {
|
||||||
t.Errorf(errNotExpectedOut, got, want)
|
t.Errorf("unexpected output. \n Got : %v\n, Want: %v\n", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +293,7 @@ func TestMetaEncode2(t *testing.T) {
|
||||||
Meta.Add("ts", "12345678")
|
Meta.Add("ts", "12345678")
|
||||||
Meta.Add("loc", "1234,4321,1234")
|
Meta.Add("loc", "1234,4321,1234")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf(errUnexpectedErr, err.Error())
|
t.Errorf("did not expect error: %v from writePSI", err.Error())
|
||||||
}
|
}
|
||||||
out := buf.Bytes()
|
out := buf.Bytes()
|
||||||
got := out[PacketSize+4:]
|
got := out[PacketSize+4:]
|
||||||
|
@ -313,7 +308,7 @@ func TestMetaEncode2(t *testing.T) {
|
||||||
want = psi.AddCrc(want)
|
want = psi.AddCrc(want)
|
||||||
want = psi.AddPadding(want)
|
want = psi.AddPadding(want)
|
||||||
if !bytes.Equal(got, want) {
|
if !bytes.Equal(got, want) {
|
||||||
t.Errorf(errNotExpectedOut, got, want)
|
t.Errorf("did not get expected results.\ngot: %v\nwant: %v\n", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,18 +321,18 @@ func TestExtractMeta(t *testing.T) {
|
||||||
Meta.Add("ts", "12345678")
|
Meta.Add("ts", "12345678")
|
||||||
Meta.Add("loc", "1234,4321,1234")
|
Meta.Add("loc", "1234,4321,1234")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf(errUnexpectedErr, err.Error())
|
t.Errorf("did not expect error: %v", err.Error())
|
||||||
}
|
}
|
||||||
out := buf.Bytes()
|
out := buf.Bytes()
|
||||||
got, err := ExtractMeta(out)
|
got, err := ExtractMeta(out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf(errUnexpectedErr, err.Error())
|
t.Errorf("did not expect error: %v", err.Error())
|
||||||
}
|
}
|
||||||
want := map[string]string{
|
want := map[string]string{
|
||||||
"ts": "12345678",
|
"ts": "12345678",
|
||||||
"loc": "1234,4321,1234",
|
"loc": "1234,4321,1234",
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf(errNotExpectedOut, got, want)
|
t.Errorf("did not get expected result.\ngot: %v\nwant: %v\n", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue