Added tests for IndexPid.

This commit is contained in:
scruzin 2019-07-11 19:29:46 +09:30
parent c717595adc
commit 01351a308b
1 changed files with 20 additions and 0 deletions

View File

@ -491,6 +491,26 @@ func TestSegmentForMeta(t *testing.T) {
if !reflect.DeepEqual(want, got) {
t.Errorf("did not get expected result for test %v\nGot: %v\nWant: %v\n", testn, got, want)
}
// Now test IndexPid.
i, m, err := IndexPid(clip.Bytes(), PatPid, PmtPid)
if err != nil {
t.Fatalf("IndexPid failed with error: %v", err)
}
if i != 0 {
t.Fatalf("IndexPid unexpected index; got %d, expected 0", i)
}
if m["n"] != "1" {
t.Fatalf("IndexPid unexpected metadata; got %s, expected 1", m["n"])
}
}
// Finally, test IndexPid error handling.
for _, d := range [][]byte{[]byte{}, make([]byte, PacketSize/2), make([]byte, PacketSize)} {
_, _, err := IndexPid(d, PatPid, PmtPid)
if err == nil {
t.Fatalf("IndexPid expected error")
}
}
}