switch tests to use cmp.Diff

This commit is contained in:
Joel Wetzell
2026-05-30 09:20:20 -05:00
parent d8da54172e
commit b7d8e8dddd
15 changed files with 73 additions and 61 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -924,7 +925,7 @@ func TestGoodArtAddressUnmarshal(t *testing.T) {
t.Fatalf("failed to Unmarshal ArtAddress: %s", err)
}
diff := cmp.Diff(test.Expected, got)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtAddress{}))
if diff != "" {
t.Fatalf("ArtAddress does not match\n%s", diff)
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtCommandUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtCommand{}))
if diff != "" {
t.Fatalf("ArtCommand does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtDataRequestUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtDataRequest{}))
if diff != "" {
t.Fatalf("ArtDataRequest does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtDiagDataUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtDiagData{}))
if diff != "" {
t.Fatalf("ArtDiagData does not match\n%s", diff)
}
})
}
+6 -21
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"slices"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -49,7 +50,7 @@ func TestGoodArtDmx(t *testing.T) {
}
for _, test := range tests {
got := artnet.ArtDmx{}
got := &artnet.ArtDmx{}
err := got.UnmarshalBinary(test.Data)
@@ -57,26 +58,10 @@ func TestGoodArtDmx(t *testing.T) {
t.Fatalf("failed to decode ArtDmx: %s", err)
}
if got.Sequence != test.Expected.Sequence {
t.Fatalf("ArtDmx Sequence does not match got: %d expected: %d", got.Sequence, test.Expected.Sequence)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtDmx{}))
if diff != "" {
t.Fatalf("ArtDmx does not match\n%s", diff)
}
if got.Physical != test.Expected.Physical {
t.Fatalf("ArtDmx Physical does not match got: %d expected: %d", got.Physical, test.Expected.Physical)
}
if got.SubUni != test.Expected.SubUni {
t.Fatalf("ArtDmx SubUni does not match got: %d expected: %d", got.SubUni, test.Expected.SubUni)
}
if got.Net != test.Expected.Net {
t.Fatalf("ArtDmx Net does not match got: %d expected: %d", got.Net, test.Expected.Net)
}
if !slices.Equal(got.Data, test.Expected.Data) {
t.Fatalf("ArtDmx Data does not match got: %+v expected: %+v", got.Data, test.Expected.Data)
}
}
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -44,8 +45,9 @@ func TestGoodArtIpProgUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtIpProg{}))
if diff != "" {
t.Fatalf("ArtIpProg does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtIpProgReplyUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtIpProgReply{}))
if diff != "" {
t.Fatalf("ArtIpProgReply does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtNzsUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtNzs{}))
if diff != "" {
t.Fatalf("ArtNzs does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -208,8 +209,9 @@ func TestGoodArtPollUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtPoll{}))
if diff != "" {
t.Fatalf("ArtPoll does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtPollReplyUnmarshal(t *testing.T) {
if err != nil {
t.Fatalf("failed to Unmarshal ArtPollReply: %s", err)
}
if !reflect.DeepEqual(got, test.Expected) {
t.Fatalf("ArtPollReply does not match got: %+v expected: %+v", got, test.Expected)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtPollReply{}))
if diff != "" {
t.Fatalf("ArtPollReply does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtSyncUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtSync{}))
if diff != "" {
t.Fatalf("ArtSync does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -36,8 +37,9 @@ func TestGoodArtTimeCodeUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtTimeCode{}))
if diff != "" {
t.Fatalf("ArtTimeCode does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -28,8 +29,9 @@ func TestGoodArtTodControlUnmarshal(t *testing.T) {
if err != nil {
t.Fatalf("failed to Unmarshal ArtTodControl: %s", err)
}
if !reflect.DeepEqual(got, test.Expected) {
t.Fatalf("ArtTodControl does not match got: %+v expected: %+v", got, test.Expected)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtTodControl{}))
if diff != "" {
t.Fatalf("ArtTodControl does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -185,8 +186,9 @@ func TestGoodArtTodRequestUnmarshal(t *testing.T) {
if err != nil {
t.Fatalf("failed to Unmarshal ArtTodRequest: %s", err)
}
if !reflect.DeepEqual(got, test.Expected) {
t.Fatalf("ArtTodRequest does not match got: %+v expected: %+v", got, test.Expected)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtTodRequest{}))
if diff != "" {
t.Fatalf("ArtTodRequest does not match\n%s", diff)
}
})
}
+5 -3
View File
@@ -1,9 +1,10 @@
package artnet_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/jwetzell/artnet-go"
)
@@ -22,8 +23,9 @@ func TestGoodArtTriggerUnmarshal(t *testing.T) {
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)
diff := cmp.Diff(test.Expected, got, cmpopts.IgnoreUnexported(artnet.ArtTrigger{}))
if diff != "" {
t.Fatalf("ArtTrigger does not match\n%s", diff)
}
})
}