cipher_test.go (541B)
1 package scte35 2 3 import "testing" 4 5 func TestPackEncryption(t *testing.T) { 6 type ptest struct { 7 sis Splice 8 want uint8 9 } 10 var tests = []ptest{ 11 { 12 sis: Splice{Encrypted: true, Cipher: DES_CBC}, 13 want: 0b10000100, 14 }, 15 { 16 sis: Splice{Encrypted: true, Cipher: TripleDES}, 17 want: 0b10000110, 18 }, 19 } 20 for _, tt := range tests { 21 var b byte 22 if tt.sis.Encrypted { 23 b |= (1 << 7) 24 } 25 b |= byte(tt.sis.Cipher) << 1 26 if b != tt.want { 27 t.Errorf("pack encryption info %v: got %08b, want %08b", tt.sis, b, tt.want) 28 } 29 } 30 }