8 func TestNewsCategoryListData15_MarshalBinary(t *testing.T) {
12 Articles map[uint32]*NewsArtData
13 SubCats map[string]NewsCategoryListData15
26 name: "returns expected bytes when type is a bundle",
28 Type: [2]byte{0x00, 0x02},
29 Articles: map[uint32]*NewsArtData{
47 name: "returns expected bytes when type is a category",
49 Type: [2]byte{0x00, 0x03},
50 Articles: map[uint32]*NewsArtData{
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x01,
64 0x00, 0x00, 0x00, 0x02,
71 for _, tt := range tests {
72 t.Run(tt.name, func(t *testing.T) {
73 newscat := &NewsCategoryListData15{
76 Articles: tt.fields.Articles,
77 SubCats: tt.fields.SubCats,
78 Count: tt.fields.Count,
79 AddSN: tt.fields.AddSN,
80 DeleteSN: tt.fields.DeleteSN,
83 gotData, err := newscat.MarshalBinary()
84 if newscat.Type == [2]byte{0, 3} {
85 // zero out the random GUID before comparison
86 for i := 4; i < 20; i++ {
90 if (err != nil) != tt.wantErr {
91 t.Errorf("MarshalBinary() error = %v, wantErr %v", err, tt.wantErr)
94 if !reflect.DeepEqual(gotData, tt.wantData) {
95 t.Errorf("MarshalBinary() gotData = %v, want %v", gotData, tt.wantData)