github.com/cnotch/ipchub@v1.1.0/av/codec/hevc/vps_test.go (about) 1 // Copyright (c) 2019,CAOHONGJU All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package hevc 6 7 import ( 8 "testing" 9 ) 10 11 func TestH265RawVPS_DecodeString(t *testing.T) { 12 tests := []struct { 13 name string 14 b64 string 15 wantErr bool 16 }{ 17 { 18 "base64_1", 19 "QAEMAf//BAgAAAMAnQgAAAMAAF2VmAk=", 20 false, 21 }, 22 { 23 "base64_2", 24 "QAEMAf//AWAAAAMAkAAAAwAAAwBdlZgJ", 25 false, 26 }, 27 } 28 for _, tt := range tests { 29 t.Run(tt.name, func(t *testing.T) { 30 vps := &H265RawVPS{} 31 if err := vps.DecodeString(tt.b64); (err != nil) != tt.wantErr { 32 t.Errorf("RawVPS.Parse() error = %v, wantErr %v", err, tt.wantErr) 33 } 34 }) 35 } 36 } 37 38 func Benchmark_VPSDecode(b *testing.B) { 39 vpsstr := "QAEMAf//AWAAAAMAkAAAAwAAAwBdlZgJ" 40 41 b.ResetTimer() 42 b.RunParallel(func(pb *testing.PB) { 43 for pb.Next() { 44 vps := &H265RawVPS{} 45 _ = vps.DecodeString(vpsstr) 46 } 47 }) 48 }