From 96377f8788411c589cc469ee9611bc399e023559 Mon Sep 17 00:00:00 2001 From: Saxon Date: Thu, 1 Aug 2019 00:15:07 +0930 Subject: [PATCH] codec/h264/h264dec/nalunit_test.go: added TestNewThreeDAVCExtension --- codec/h264/h264dec/nalunit_test.go | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/codec/h264/h264dec/nalunit_test.go b/codec/h264/h264dec/nalunit_test.go index 2519fafa..f3828880 100644 --- a/codec/h264/h264dec/nalunit_test.go +++ b/codec/h264/h264dec/nalunit_test.go @@ -50,3 +50,44 @@ func TestNewMVCExtension(t *testing.T) { } } } + +func TestNewThreeDAVCExtension(t *testing.T) { + tests := []struct { + in string + want ThreeDAVCExtension + err error + }{ + { + in: "0001 0000" + // u(8) view_idx = 16 + "1" + // u(1) depth_flag = true + "0" + // u(1) non_idr_flag = false + "010" + // u(1) temporal_id = 2 + "1" + // u(1) anchor_pic_flag = true + "1", // u(1) inter_view_flag = true + want: ThreeDAVCExtension{ + ViewIdx: 16, + DepthFlag: true, + NonIdrFlag: false, + TemporalID: 2, + AnchorPicFlag: true, + InterViewFlag: true, + }, + }, + } + + for i, test := range tests { + inBytes, err := binToSlice(test.in) + if err != nil { + t.Fatalf("did not expect error %v from binToSlice for test %d", err, i) + } + + got, err := NewThreeDAVCExtension(bits.NewBitReader(bytes.NewReader(inBytes))) + if err != test.err { + t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err) + } + + if !reflect.DeepEqual(*got, test.want) { + t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want) + } + } +}