2024-06-19 04:59:43 +00:00
|
|
|
package messages7
|
2024-06-18 05:08:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/internal/testutils/require"
|
2024-06-22 05:59:27 +00:00
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/packer"
|
2024-06-18 05:08:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnpackClientInfo(t *testing.T) {
|
|
|
|
u := packer.Unpacker{}
|
|
|
|
u.Reset([]byte{
|
|
|
|
0x00, 0x01, 0x00, 0x67, 0x6f, 0x70, 0x68, 0x65, 0x72, 0x00,
|
|
|
|
0x00, 0x40, 0x67, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x77, 0x61, 0x72,
|
|
|
|
0x64, 0x00, 0x64, 0x75, 0x6f, 0x64, 0x6f, 0x6e, 0x6e, 0x79, 0x00,
|
|
|
|
0x00, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x00, 0x73,
|
|
|
|
0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x00, 0x73, 0x74, 0x61,
|
|
|
|
0x6e, 0x64, 0x61, 0x72, 0x64, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0xfc, 0xaf, 0x05, 0xeb, 0x83, 0xd0, 0x0a, 0x80, 0xfe,
|
|
|
|
0x07, 0x80, 0xfe, 0x07, 0x80, 0xfe, 0x07, 0x80, 0xfe, 0x07, 0x00,
|
|
|
|
})
|
|
|
|
|
|
|
|
info := SvClientInfo{}
|
2024-06-23 19:18:54 +00:00
|
|
|
err := info.Unpack(&u)
|
|
|
|
require.NoError(t, err)
|
2024-06-18 05:08:56 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
want := "standard"
|
2024-06-23 19:18:54 +00:00
|
|
|
got := info.Eyes
|
|
|
|
require.Equal(t, want, got)
|
2024-06-18 05:08:56 +00:00
|
|
|
|
|
|
|
want = ""
|
2024-06-23 19:18:54 +00:00
|
|
|
got = info.Decoration
|
|
|
|
require.Equal(t, want, got)
|
2024-06-18 05:08:56 +00:00
|
|
|
|
|
|
|
want = "duodonny"
|
2024-06-23 19:18:54 +00:00
|
|
|
got = info.Marking
|
|
|
|
require.Equal(t, want, got)
|
2024-06-18 05:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wantedInfo := SvClientInfo{
|
|
|
|
ClientId: 0,
|
|
|
|
Local: true,
|
|
|
|
Team: 0,
|
|
|
|
Name: "gopher",
|
|
|
|
Clan: "",
|
|
|
|
Country: -1,
|
|
|
|
Body: "greensward",
|
|
|
|
Marking: "duodonny",
|
|
|
|
Decoration: "",
|
|
|
|
Hands: "standard",
|
|
|
|
Feet: "standard",
|
|
|
|
Eyes: "standard",
|
|
|
|
CustomColorBody: true,
|
|
|
|
CustomColorMarking: true,
|
|
|
|
CustomColorDecoration: false,
|
|
|
|
CustomColorHands: false,
|
|
|
|
CustomColorFeet: false,
|
|
|
|
CustomColorEyes: false,
|
|
|
|
ColorBody: 5635840,
|
|
|
|
ColorMarking: -11141356,
|
|
|
|
ColorHands: 65408,
|
|
|
|
ColorFeet: 65408,
|
|
|
|
ColorEyes: 65408,
|
|
|
|
Silent: true,
|
|
|
|
}
|
2024-06-23 19:18:54 +00:00
|
|
|
require.Equal(t, wantedInfo, info)
|
2024-06-18 05:08:56 +00:00
|
|
|
}
|