MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / TestCharacter_SetUserId

Function TestCharacter_SetUserId

internal/characters/character_test.go:259–292  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

257 }
258}
259func 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}
293func TestCharacter_SetMiscData(t *testing.T) {
294 tests := []struct {
295 name string

Callers

nothing calls this directly

Calls 3

SetUserIdMethod · 0.80
NewFunction · 0.70
IsValidMethod · 0.45

Tested by

no test coverage detected