It seems that something wrong with time.Now() on Windows, not sure whether it is a bug on Windows, so exclude this test from Windows platform temporarily.
(t *testing.T)
| 71 | // It seems that something wrong with time.Now() on Windows, not sure whether it is a bug on Windows, |
| 72 | // so exclude this test from Windows platform temporarily. |
| 73 | func TestSearch(t *testing.T) { |
| 74 | q := newWorkerStack(0) |
| 75 | |
| 76 | currTime := time.Now().UnixNano() |
| 77 | |
| 78 | // 1 |
| 79 | expiry1 := currTime |
| 80 | currTime++ |
| 81 | _ = q.insert(&goWorker{lastUsed: currTime}) |
| 82 | |
| 83 | require.EqualValues(t, 0, q.binarySearch(0, q.len()-1, currTime), "index should be 0") |
| 84 | require.EqualValues(t, -1, q.binarySearch(0, q.len()-1, expiry1), "index should be -1") |
| 85 | |
| 86 | // 2 |
| 87 | currTime++ |
| 88 | expiry2 := currTime |
| 89 | currTime++ |
| 90 | _ = q.insert(&goWorker{lastUsed: currTime}) |
| 91 | |
| 92 | require.EqualValues(t, -1, q.binarySearch(0, q.len()-1, expiry1), "index should be -1") |
| 93 | |
| 94 | require.EqualValues(t, 0, q.binarySearch(0, q.len()-1, expiry2), "index should be 0") |
| 95 | |
| 96 | require.EqualValues(t, 1, q.binarySearch(0, q.len()-1, currTime), "index should be 1") |
| 97 | |
| 98 | // more |
| 99 | for i := 0; i < 5; i++ { |
| 100 | currTime++ |
| 101 | _ = q.insert(&goWorker{lastUsed: currTime}) |
| 102 | } |
| 103 | |
| 104 | currTime++ |
| 105 | expiry3 := currTime |
| 106 | |
| 107 | _ = q.insert(&goWorker{lastUsed: expiry3}) |
| 108 | |
| 109 | for i := 0; i < 10; i++ { |
| 110 | currTime++ |
| 111 | _ = q.insert(&goWorker{lastUsed: currTime}) |
| 112 | } |
| 113 | |
| 114 | require.EqualValues(t, 7, q.binarySearch(0, q.len()-1, expiry3), "index should be 7") |
| 115 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…