This test case checks that the CCheckQueue works properly * with each specified size_t Checks pushed. */
| 158 | * with each specified size_t Checks pushed. |
| 159 | */ |
| 160 | static void Correct_Queue_range(std::vector<size_t> range) |
| 161 | { |
| 162 | auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE); |
| 163 | small_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS); |
| 164 | // Make vChecks here to save on malloc (this test can be slow...) |
| 165 | std::vector<FakeCheckCheckCompletion*> vChecks; |
| 166 | for (const size_t i : range) { |
| 167 | size_t total = i; |
| 168 | FakeCheckCheckCompletion::n_calls = 0; |
| 169 | CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get()); |
| 170 | while (total) { |
| 171 | vChecks.resize(std::min(total, (size_t) InsecureRandRange(10))); |
| 172 | for (size_t i = 0; i < vChecks.size(); ++i) { |
| 173 | vChecks[i] = new FakeCheckCheckCompletion(); |
| 174 | } |
| 175 | total -= vChecks.size(); |
| 176 | control.Add(vChecks); |
| 177 | } |
| 178 | BOOST_REQUIRE(control.Wait()); |
| 179 | if (FakeCheckCheckCompletion::n_calls != i) { |
| 180 | BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i); |
| 181 | } |
| 182 | } |
| 183 | small_queue->StopWorkerThreads(); |
| 184 | } |
| 185 | |
| 186 | /** Test that 0 checks is correct |
| 187 | */ |
no test coverage detected