| 257 | } |
| 258 | } |
| 259 | func TestCharacter_SetUserId(t *testing.T) { |
| 260 | tests := []struct { |
| 261 | name string |
| 262 | userId int |
| 263 | }{ |
| 264 | { |
| 265 | name: "Set positive userId", |
| 266 | userId: 42, |
| 267 | }, |
| 268 | { |
| 269 | name: "Set zero userId", |
| 270 | userId: 0, |
| 271 | }, |
| 272 | { |
| 273 | name: "Set negative userId", |
| 274 | userId: -7, |
| 275 | }, |
| 276 | { |
| 277 | name: "Set large userId", |
| 278 | userId: 999999, |
| 279 | }, |
| 280 | } |
| 281 | |
| 282 | for _, tt := range tests { |
| 283 | t.Run(tt.name, func(t *testing.T) { |
| 284 | c := New() |
| 285 | c.SetUserId(tt.userId) |
| 286 | // userId is unexported, so we need to use reflection to check it |
| 287 | userIdField := reflect.ValueOf(c).Elem().FieldByName("userId") |
| 288 | assert.True(t, userIdField.IsValid(), "userId field should exist") |
| 289 | assert.Equal(t, tt.userId, int(userIdField.Int())) |
| 290 | }) |
| 291 | } |
| 292 | } |
| 293 | func TestCharacter_SetMiscData(t *testing.T) { |
| 294 | tests := []struct { |
| 295 | name string |