mirror of
https://github.com/jwetzell/artnet-go.git
synced 2026-08-19 05:43:57 +00:00
add test boilerplate
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtCommandUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtCommand
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtCommand{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtCommand: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtCommand does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtDataRequestUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtDataRequest
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtDataRequest{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtDataRequest: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtDataRequest does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtDiagDataUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtDiagData
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtDiagData{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtDiagData: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtDiagData does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+32
@@ -9,10 +9,12 @@ import (
|
||||
|
||||
func TestGoodArtDmx(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtDmx
|
||||
}{
|
||||
{
|
||||
Name: "512 All Zeroes",
|
||||
Data: []byte{65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14, 237, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
Expected: &artnet.ArtDmx{
|
||||
ID: [8]byte{'A', 'r', 't', '-', 'N', 'e', 't', 0x00},
|
||||
@@ -26,6 +28,36 @@ func TestGoodArtDmx(t *testing.T) {
|
||||
Data: make([]uint8, 512),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 1",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtDmx{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: artnet.OpDmx,
|
||||
ProtVerHi: 0,
|
||||
ProtVerLo: 14,
|
||||
Sequence: 0,
|
||||
Physical: 0,
|
||||
SubUni: 1,
|
||||
Net: 0,
|
||||
Data: make([]uint8, 512),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 2",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtDmx{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: artnet.OpDmx,
|
||||
ProtVerHi: 0,
|
||||
ProtVerLo: 14,
|
||||
Sequence: 0,
|
||||
Physical: 0,
|
||||
SubUni: 1,
|
||||
Net: 0,
|
||||
Data: append([]uint8{0xff, 0x7f}, make([]uint8, 510)...),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtIpProgUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtIpProg
|
||||
}{
|
||||
{
|
||||
Name: "ACT Packet 1",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0xf8, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtIpProg{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: artnet.OpIpProg,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
Command: 0x00,
|
||||
ProgIpHi: 0x00,
|
||||
ProgIp2: 0x00,
|
||||
ProgIp1: 0x00,
|
||||
ProgIpLo: 0x00,
|
||||
ProgSmHi: 0x00,
|
||||
ProgSm2: 0x00,
|
||||
ProgSm1: 0x00,
|
||||
ProgSmLo: 0x00,
|
||||
ProgPortHi: 0x00,
|
||||
ProgPortLo: 0x00,
|
||||
ProgDgHi: 0x00,
|
||||
ProgDg2: 0x00,
|
||||
ProgDg1: 0x00,
|
||||
ProgDgLo: 0x00,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtIpProg{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtIpProg: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtIpProg does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtIpProgReplyUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtIpProgReply
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtIpProgReply{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtIpProgReply: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtIpProgReply does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtNzsUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtNzs
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtNzs{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtNzs: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtNzs does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtPollUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtPoll
|
||||
}{
|
||||
{
|
||||
Name: "ACT Packet 1",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 2",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 3",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 4",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 5",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 6",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 7",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 8",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 9",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 10",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 11",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 12",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 13",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 14",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 15",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 16",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x21, 0x0a, 0x00, 0x00, 0x3e, 0x36, 0x19, 0x07, 0x33, 0x00, 0x06, 0x22, 0x69, 0x00, 0x00, 0x79, 0x53, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x43, 0x54, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ACT Packet 17",
|
||||
Data: []byte{0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x06, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x53, 0x79, 0x22, 0x69},
|
||||
Expected: &artnet.ArtPoll{
|
||||
ID: artnet.ArtNetID,
|
||||
OpCode: 0x2000,
|
||||
ProtVerHi: 0x00,
|
||||
ProtVerLo: 0x0e,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtPoll{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtPoll: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtPoll does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtSyncUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtSync
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtSync{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtSync: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtSync does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+14
-52
@@ -1,18 +1,20 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtTimeCode(t *testing.T) {
|
||||
func TestGoodArtTimeCodeUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtTimeCode
|
||||
}{
|
||||
{
|
||||
Name: "Basic timecode",
|
||||
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: [8]uint8{'A', 'r', 't', '-', 'N', 'e', 't', 0x00},
|
||||
@@ -31,58 +33,18 @@ func TestGoodArtTimeCode(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got := artnet.ArtTimeCode{}
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtTimeCode{}
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("failed to decode ArtTimeCode: %s", err)
|
||||
}
|
||||
|
||||
if got.OpCode != test.Expected.OpCode {
|
||||
t.Fatalf("ArtTimeCode OpCode does not match got: %d expected: %d", got.OpCode, test.Expected.OpCode)
|
||||
}
|
||||
|
||||
if !slices.Equal(got.ID[:], test.Expected.ID[:]) {
|
||||
t.Fatalf("ArtTimeCode ID does not match got: %+v expected: %+v", got.ID, test.Expected.ID)
|
||||
}
|
||||
|
||||
if got.Filler1 != test.Expected.Filler1 {
|
||||
t.Fatalf("ArtTimeCode Filler1 does not match got: %d expected: %d", got.Filler1, test.Expected.Filler1)
|
||||
}
|
||||
|
||||
if got.StreamId != test.Expected.StreamId {
|
||||
t.Fatalf("ArtTimeCode StreamId does not match got: %d expected: %d", got.StreamId, test.Expected.StreamId)
|
||||
}
|
||||
|
||||
if got.Frames != test.Expected.Frames {
|
||||
t.Fatalf("ArtTimeCode Frames does not match got: %d expected: %d", got.Frames, test.Expected.Frames)
|
||||
}
|
||||
|
||||
if got.Seconds != test.Expected.Seconds {
|
||||
t.Fatalf("ArtTimeCode Seconds does not match got: %d expected: %d", got.Seconds, test.Expected.Seconds)
|
||||
}
|
||||
|
||||
if got.Minutes != test.Expected.Minutes {
|
||||
t.Fatalf("ArtTimeCode Minutes does not match got: %d expected: %d", got.Minutes, test.Expected.Minutes)
|
||||
}
|
||||
|
||||
if got.Hours != test.Expected.Hours {
|
||||
t.Fatalf("ArtTimeCode Hours does not match got: %d expected: %d", got.Hours, test.Expected.Hours)
|
||||
}
|
||||
|
||||
if got.Type != test.Expected.Type {
|
||||
t.Fatalf("ArtTimeCode Type does not match got: %d expected: %d", got.Type, test.Expected.Type)
|
||||
}
|
||||
|
||||
if got.ProtVerHi != test.Expected.ProtVerHi {
|
||||
t.Fatalf("ArtTimeCode ProtVerHi does not match got: %d expected: %d", got.ProtVerHi, test.Expected.ProtVerHi)
|
||||
}
|
||||
|
||||
if got.ProtVerLo != test.Expected.ProtVerLo {
|
||||
t.Fatalf("ArtTimeCode ProtVerLo does not match got: %d expected: %d", got.ProtVerLo, test.Expected.ProtVerLo)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("failed to decode ArtTimeCode: %s", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtTimeCode does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package artnet_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/artnet-go"
|
||||
)
|
||||
|
||||
func TestGoodArtTriggerUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Data []byte
|
||||
Expected *artnet.ArtTrigger
|
||||
}{}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
got := &artnet.ArtTrigger{}
|
||||
|
||||
err := got.UnmarshalBinary(test.Data)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to Unmarshal ArtTrigger: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, test.Expected) {
|
||||
t.Fatalf("ArtTrigger does not match got: %+v expected: %+v", got, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user