This test case checks that the CCheckQueue works properly * with each specified size_t Checks pushed. */
| 157 | * with each specified size_t Checks pushed. |
| 158 | */ |
| 159 | void CheckQueueTest::Correct_Queue_range(std::vector<size_t> range) |
| 160 | { |
| 161 | auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS); |
| 162 | // Make vChecks here to save on malloc (this test can be slow...) |
| 163 | std::vector<FakeCheckCheckCompletion> vChecks; |
| 164 | vChecks.reserve(9); |
| 165 | for (const size_t i : range) { |
| 166 | size_t total = i; |
| 167 | FakeCheckCheckCompletion::n_calls = 0; |
| 168 | CCheckQueueControl<FakeCheckCheckCompletion> control(*small_queue); |
| 169 | while (total) { |
| 170 | vChecks.clear(); |
| 171 | vChecks.resize(std::min<size_t>(total, m_rng.randrange(10))); |
| 172 | total -= vChecks.size(); |
| 173 | control.Add(std::move(vChecks)); |
| 174 | } |
| 175 | BOOST_REQUIRE(!control.Complete().has_value()); |
| 176 | BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | BOOST_FIXTURE_TEST_SUITE(checkqueue_tests, CheckQueueTest) |
| 181 |