TestWantConnQueue_len tests the len() method.
(t *testing.T)
| 842 | |
| 843 | // TestWantConnQueue_len tests the len() method. |
| 844 | func TestWantConnQueue_len(t *testing.T) { |
| 845 | q := newWantConnQueue() |
| 846 | |
| 847 | // Test empty queue |
| 848 | if length := q.len(); length != 0 { |
| 849 | t.Errorf("empty queue len() = %d, want 0", length) |
| 850 | } |
| 851 | |
| 852 | // Add elements and verify length |
| 853 | for i := 1; i <= 5; i++ { |
| 854 | w := &wantConn{ |
| 855 | ctx: context.Background(), |
| 856 | result: make(chan wantConnResult, 1), |
| 857 | } |
| 858 | q.enqueue(w) |
| 859 | |
| 860 | if length := q.len(); length != i { |
| 861 | t.Errorf("queue len() after %d enqueues = %d, want %d", i, length, i) |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | // Remove elements and verify length |
| 866 | for i := 4; i >= 0; i-- { |
| 867 | q.dequeue() |
| 868 | if length := q.len(); length != i { |
| 869 | t.Errorf("queue len() after dequeue = %d, want %d", length, i) |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | // TestWantConnQueue_len_Concurrent tests len() thread safety. |
| 875 | func TestWantConnQueue_len_Concurrent(t *testing.T) { |
nothing calls this directly
no test coverage detected