(t *testing.T)
| 593 | } |
| 594 | |
| 595 | func TestConn_UsedMethods(t *testing.T) { |
| 596 | cn := NewConn(nil) |
| 597 | |
| 598 | // Initialize connection to IDLE state |
| 599 | cn.stateMachine.Transition(StateInitializing) |
| 600 | cn.stateMachine.Transition(StateIdle) |
| 601 | |
| 602 | // Test IsUsed - should be false when IDLE |
| 603 | if cn.IsUsed() { |
| 604 | t.Error("expected IsUsed to be false for IDLE connection") |
| 605 | } |
| 606 | |
| 607 | // Test CompareAndSwapUsed - acquire connection |
| 608 | if !cn.CompareAndSwapUsed(false, true) { |
| 609 | t.Error("failed to acquire connection with CompareAndSwapUsed") |
| 610 | } |
| 611 | |
| 612 | // Test IsUsed - should be true when IN_USE |
| 613 | if !cn.IsUsed() { |
| 614 | t.Error("expected IsUsed to be true for IN_USE connection") |
| 615 | } |
| 616 | |
| 617 | // Test CompareAndSwapUsed - release connection |
| 618 | if !cn.CompareAndSwapUsed(true, false) { |
| 619 | t.Error("failed to release connection with CompareAndSwapUsed") |
| 620 | } |
| 621 | |
| 622 | // Test IsUsed - should be false again |
| 623 | if cn.IsUsed() { |
| 624 | t.Error("expected IsUsed to be false after release") |
| 625 | } |
| 626 | |
| 627 | // Test SetUsed |
| 628 | cn.SetUsed(true) |
| 629 | if !cn.IsUsed() { |
| 630 | t.Error("expected IsUsed to be true after SetUsed(true)") |
| 631 | } |
| 632 | |
| 633 | cn.SetUsed(false) |
| 634 | if cn.IsUsed() { |
| 635 | t.Error("expected IsUsed to be false after SetUsed(false)") |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | func TestConnStateMachine_UnusableState(t *testing.T) { |
| 640 | sm := NewConnStateMachine() |
nothing calls this directly
no test coverage detected