(t *testing.T)
| 291 | } |
| 292 | } |
| 293 | func TestCharacter_SetMiscData(t *testing.T) { |
| 294 | tests := []struct { |
| 295 | name string |
| 296 | initialData map[string]any |
| 297 | key string |
| 298 | value any |
| 299 | expectExists bool |
| 300 | expectValue any |
| 301 | }{ |
| 302 | { |
| 303 | name: "Set new key-value pair", |
| 304 | initialData: nil, |
| 305 | key: "foo", |
| 306 | value: 123, |
| 307 | expectExists: true, |
| 308 | expectValue: 123, |
| 309 | }, |
| 310 | { |
| 311 | name: "Overwrite existing key", |
| 312 | initialData: map[string]any{"bar": "baz"}, |
| 313 | key: "bar", |
| 314 | value: "qux", |
| 315 | expectExists: true, |
| 316 | expectValue: "qux", |
| 317 | }, |
| 318 | { |
| 319 | name: "Delete existing key by setting value to nil", |
| 320 | initialData: map[string]any{"del": 42}, |
| 321 | key: "del", |
| 322 | value: nil, |
| 323 | expectExists: false, |
| 324 | expectValue: nil, |
| 325 | }, |
| 326 | { |
| 327 | name: "Delete non-existing key by setting value to nil", |
| 328 | initialData: map[string]any{"other": 1}, |
| 329 | key: "missing", |
| 330 | value: nil, |
| 331 | expectExists: false, |
| 332 | expectValue: nil, |
| 333 | }, |
| 334 | { |
| 335 | name: "Set key with value zero", |
| 336 | initialData: nil, |
| 337 | key: "zero", |
| 338 | value: 0, |
| 339 | expectExists: true, |
| 340 | expectValue: 0, |
| 341 | }, |
| 342 | } |
| 343 | |
| 344 | for _, tt := range tests { |
| 345 | t.Run(tt.name, func(t *testing.T) { |
| 346 | c := New() |
| 347 | if tt.initialData != nil { |
| 348 | c.MiscData = make(map[string]any) |
| 349 | for k, v := range tt.initialData { |
| 350 | c.MiscData[k] = v |
nothing calls this directly
no test coverage detected