From 7f8465f1adc241295a71d05e9b0d52b8f25fd668 Mon Sep 17 00:00:00 2001 From: saxon Date: Tue, 29 Jan 2019 22:07:06 +1030 Subject: [PATCH] stream/mts/psi/descriptor_test.go: added comments to test funcs - as well as some todos for further testing. --- stream/mts/psi/descriptor_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/stream/mts/psi/descriptor_test.go b/stream/mts/psi/descriptor_test.go index dd763b82..cbb743a2 100644 --- a/stream/mts/psi/descriptor_test.go +++ b/stream/mts/psi/descriptor_test.go @@ -127,6 +127,10 @@ var ( } ) +// TestHasDescriptorExists checks that PSIBytes.HasDescriptor performs as expected +// when the PSI we're interested in has the descriptor of interest. HasDescriptor +// should return the descriptor bytes. +// TODO: HasDescriptor also returns index of descriptor - we should check this. func TestHasDescriptorExists(t *testing.T) { p := PSIBytes(tstPsi3.Bytes()) _, got := p.HasDescriptor(LocationDescTag) @@ -140,6 +144,10 @@ func TestHasDescriptorExists(t *testing.T) { } } +// TestHasDescriptorAbsent checks that PSIBytes.HasDescriptor performs as expected +// when the PSI does not have the descriptor of interest. HasDescriptor should +// return a nil slice and a negative index. +// TODO: check index here as well. func TestHasDescriptorAbsent(t *testing.T) { p := PSIBytes(tstPsi3.Bytes()) const fakeTag = 236 @@ -150,6 +158,10 @@ func TestHasDescriptorAbsent(t *testing.T) { } } +// TestHasDescriptorNone checks that PSIBytes.HasDescriptor behaves as expected +// when the PSI does not have any descriptors. HasDescriptor should return a nil +// slice. +// TODO: again check index here. func TestHasDescriptorNone(t *testing.T) { p := PSIBytes(tstPsi2.Bytes()) _, got := p.HasDescriptor(LocationDescTag) @@ -159,6 +171,8 @@ func TestHasDescriptorNone(t *testing.T) { } } +// TestProgramInfoLen checks that PSIBytes.ProgramInfoLen correctly extracts +// the program info length from a PSI. func TestProgramInfoLen(t *testing.T) { p := PSIBytes(tstPsi1.Bytes()) got := p.ProgramInfoLen() @@ -168,6 +182,8 @@ func TestProgramInfoLen(t *testing.T) { } } +// TestDescriptors checks that PSIBytes.descriptors correctly returns the descriptors +// from a PSI when descriptors exist. func TestDescriptors(t *testing.T) { p := PSIBytes(tstPsi1.Bytes()) got := p.descriptors() @@ -181,6 +197,8 @@ func TestDescriptors(t *testing.T) { } } +// TestDescriptors checks that PSIBYtes.desriptors correctly returns nil when +// we try to get descriptors from a psi without any descriptors. func TestDescriptorsNone(t *testing.T) { p := PSIBytes(tstPsi2.Bytes()) got := p.descriptors() @@ -190,6 +208,8 @@ func TestDescriptorsNone(t *testing.T) { } } +// TestCreateDescriptorEmpty checks that PSIBytes.createDescriptor correctly adds +// a descriptor to the descriptors list in a PSI when it has no descriptors already. func TestCreateDescriptorEmpty(t *testing.T) { got := PSIBytes(tstPsi2.Bytes()) got.createDescriptor(TimeDescTag, make([]byte, TimeDataSize)) @@ -200,6 +220,9 @@ func TestCreateDescriptorEmpty(t *testing.T) { } } +// TestCreateDescriptorNotEmpty checks that PSIBytes.createDescriptor correctly adds +// a descriptor to the descriptors list in a PSI when it already has one with +// a different tag. func TestCreateDescriptorNotEmpty(t *testing.T) { got := PSIBytes(tstPsi1.Bytes()) got.createDescriptor(LocationDescTag, make([]byte, LocationDataSize)) @@ -210,6 +233,8 @@ func TestCreateDescriptorNotEmpty(t *testing.T) { } } +// TestAddDescriptorEmpty checks that PSIBytes.AddDescriptor correctly adds a descriptor +// when there are no other descriptors present in the PSI. func TestAddDescriptorEmpty(t *testing.T) { got := PSIBytes(tstPsi2.Bytes()) if err := got.AddDescriptor(TimeDescTag, make([]byte, TimeDataSize)); err != nil { @@ -221,6 +246,8 @@ func TestAddDescriptorEmpty(t *testing.T) { } } +// TestAddDescriptorNonEmpty checks that PSIBytes.AddDescriptor correctly adds a +// descriptor when there is already a descriptor of a differing type in a PSI. func TestAddDescriptorNonEmpty(t *testing.T) { got := PSIBytes(tstPsi1.Bytes()) if err := got.AddDescriptor(LocationDescTag, make([]byte, LocationDataSize)); err != nil { @@ -231,3 +258,5 @@ func TestAddDescriptorNonEmpty(t *testing.T) { t.Errorf(errNotExpectedOut, got, want) } } + +// TODO: check that we can update descriptor with AddDescriptor