package huya import ( "encoding/hex" "testing" "huya-go/internal/wup" ) var sampleBindRespHex = "000000be10032c3c4001560877656241637455496618636865636b5573657242696e6447616d654163636f756e747d0001008408000206001d0000010c0604745273701d0000700a0100c816002a0001100120013a0600160026027171360046085151e794a8e688b7560066000b4a0600160fe5bfa7e98381e5988ee5b7b4e8b1862604e6898b51360fe5ae89e58d9328616e64726f696429460056000b526a4fc5800b360ce5928ce5b9b3e7b2bee88bb1460050070b811388980ca80c" func TestDecodeCheckUserBindGameAccountResp(t *testing.T) { respBytes, err := hex.DecodeString(sampleBindRespHex) if err != nil { t.Fatalf("decode hex: %v", err) } var wResp wup.Response if err := wResp.Decode(respBytes); err != nil { t.Fatalf("wup decode: %v", err) } var resp CheckUserBindGameAccountResp ok, err := wResp.ReadStruct("tRsp", &resp) if err != nil { t.Fatalf("readStruct tRsp: %v", err) } if !ok { t.Fatalf("tRsp not found in response") } t.Logf("Status: %d, Msg: %s, GameName: %s", resp.Status, resp.Msg, resp.GameName) t.Logf("RoleName: %s, AreaName: %s, PlatName: %s", resp.AccountData.GameRole.RoleName, resp.AccountData.GameRole.AreaName, resp.AccountData.GameRole.PlatName) t.Logf("DisplayName: %s", resp.RoleDisplayName()) if resp.Status != 200 { t.Errorf("expected status 200, got %d", resp.Status) } if resp.AccountData.GameRole.RoleName != "忧郁嘎巴豆" { t.Errorf("expected roleName 忧郁嘎巴豆, got %s", resp.AccountData.GameRole.RoleName) } if resp.AccountData.GameRole.AreaName != "手Q" { t.Errorf("expected areaName 手Q, got %s", resp.AccountData.GameRole.AreaName) } if resp.AccountData.GameRole.PlatName != "安卓(android)" { t.Errorf("expected platName 安卓(android), got %s", resp.AccountData.GameRole.PlatName) } if resp.RoleDisplayName() != "忧郁嘎巴豆 [手Q-安卓]" { t.Errorf("expected roleDisplayName 忧郁嘎巴豆 [手Q-安卓], got %s", resp.RoleDisplayName()) } }