(t *testing.T)
| 459 | } |
| 460 | |
| 461 | func TestUInt64(t *testing.T) { |
| 462 | tests := []struct { |
| 463 | name string |
| 464 | key string |
| 465 | value uint64 |
| 466 | expected map[string]any |
| 467 | }{ |
| 468 | { |
| 469 | name: "positive uint64", |
| 470 | key: "count", |
| 471 | value: 18446744073709551615, |
| 472 | expected: map[string]any{ |
| 473 | "count": 18446744073709551615.0, |
| 474 | }, |
| 475 | }, |
| 476 | { |
| 477 | name: "zero uint64", |
| 478 | key: "zero", |
| 479 | value: 0, |
| 480 | expected: map[string]any{ |
| 481 | "zero": 0.0, |
| 482 | }, |
| 483 | }, |
| 484 | { |
| 485 | name: "large uint64", |
| 486 | key: "large", |
| 487 | value: 1234567890123456789, |
| 488 | expected: map[string]any{ |
| 489 | "large": 1234567890123456789.0, |
| 490 | }, |
| 491 | }, |
| 492 | } |
| 493 | |
| 494 | for _, tt := range tests { |
| 495 | t.Run(tt.name, func(t *testing.T) { |
| 496 | // Test memory allocations |
| 497 | allocs := testing.AllocsPerRun(100, func() { |
| 498 | _ = UInt64(tt.key, tt.value) |
| 499 | }) |
| 500 | require.Equal(t, float64(0), allocs, "UInt64() should not allocate memory") |
| 501 | |
| 502 | // Test output format |
| 503 | param := UInt64(tt.key, tt.value) |
| 504 | |
| 505 | jw := contentlog.NewJSONWriter() |
| 506 | defer jw.Release() |
| 507 | |
| 508 | jw.BeginObject() |
| 509 | param.WriteValueTo(jw) |
| 510 | jw.EndObject() |
| 511 | |
| 512 | var result map[string]any |
| 513 | |
| 514 | require.NoError(t, json.Unmarshal(jw.GetBufferForTesting(), &result)) |
| 515 | require.Equal(t, tt.expected, result) |
| 516 | }) |
| 517 | } |
| 518 | } |
nothing calls this directly
no test coverage detected