mirror of
https://github.com/jwetzell/artnet-go.git
synced 2026-08-16 20:43:23 +00:00
some byte slice cleanup
This commit is contained in:
+38
-2
@@ -15,7 +15,7 @@ func TestGoodArtTimeCode(t *testing.T) {
|
||||
{
|
||||
Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 151, 0, 14, 0, 0, 11, 17, 3, 0, 0},
|
||||
Expected: &artnet.ArtTimeCode{
|
||||
ID: []byte{'A', 'r', 't', '-', 'N', 'e', 't', 0x00},
|
||||
ID: [8]uint8{'A', 'r', 't', '-', 'N', 'e', 't', 0x00},
|
||||
OpCode: artnet.OpTimeCode,
|
||||
ProtVerHi: 0,
|
||||
ProtVerLo: 14,
|
||||
@@ -43,7 +43,7 @@ func TestGoodArtTimeCode(t *testing.T) {
|
||||
t.Fatalf("ArtTimeCode OpCode does not match got: %d expected: %d", got.OpCode, test.Expected.OpCode)
|
||||
}
|
||||
|
||||
if !slices.Equal(got.ID, test.Expected.ID) {
|
||||
if !slices.Equal(got.ID[:], test.Expected.ID[:]) {
|
||||
t.Fatalf("ArtTimeCode ID does not match got: %+v expected: %+v", got.ID, test.Expected.ID)
|
||||
}
|
||||
|
||||
@@ -85,3 +85,39 @@ func TestGoodArtTimeCode(t *testing.T) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkArtTimeCodeUnmarshalBinary(b *testing.B) {
|
||||
data := []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 151, 0, 14, 0, 0, 11, 17, 3, 0, 0}
|
||||
|
||||
for b.Loop() {
|
||||
got := artnet.ArtTimeCode{}
|
||||
|
||||
err := got.UnmarshalBinary(data)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to decode ArtTimeCode: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkArtTimeCodeMarshalBinary(b *testing.B) {
|
||||
data := artnet.ArtTimeCode{
|
||||
ID: [8]uint8{'A', 'r', 't', '-', 'N', 'e', 't', 0x00},
|
||||
OpCode: artnet.OpTimeCode,
|
||||
ProtVerHi: 0,
|
||||
ProtVerLo: 14,
|
||||
Filler1: 0,
|
||||
StreamId: 0,
|
||||
Frames: 11,
|
||||
Seconds: 17,
|
||||
Minutes: 3,
|
||||
Hours: 0,
|
||||
Type: 0,
|
||||
}
|
||||
|
||||
for b.Loop() {
|
||||
_, err := data.MarshalBinary()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to encode ArtTimeCode: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user