9 func TestNewsCategoryListData15_MarshalBinary(t *testing.T) {
13 Articles map[uint32]*NewsArtData
14 SubCats map[string]NewsCategoryListData15
27 name: "returns expected bytes when type is a bundle",
29 Type: []byte{0x00, 0x02},
30 Articles: map[uint32]*NewsArtData{
48 name: "returns expected bytes when type is a category",
50 Type: []byte{0x00, 0x03},
51 Articles: map[uint32]*NewsArtData{
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x01,
65 0x00, 0x00, 0x00, 0x02,
72 for _, tt := range tests {
73 t.Run(tt.name, func(t *testing.T) {
74 newscat := &NewsCategoryListData15{
77 Articles: tt.fields.Articles,
78 SubCats: tt.fields.SubCats,
79 Count: tt.fields.Count,
80 AddSN: tt.fields.AddSN,
81 DeleteSN: tt.fields.DeleteSN,
84 gotData, err := newscat.MarshalBinary()
85 if bytes.Equal(newscat.Type, []byte{0, 3}) {
86 // zero out the random GUID before comparison
87 for i := 4; i < 20; i++ {
91 if (err != nil) != tt.wantErr {
92 t.Errorf("MarshalBinary() error = %v, wantErr %v", err, tt.wantErr)
95 if !reflect.DeepEqual(gotData, tt.wantData) {
96 t.Errorf("MarshalBinary() gotData = %v, want %v", gotData, tt.wantData)