MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/prevector_tests.cpp:217–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215};
216
217BOOST_AUTO_TEST_CASE(PrevectorTestInt)
218{
219 for (int j = 0; j < 64; j++) {
220 prevector_tester<8, int> test;
221 for (int i = 0; i < 2048; i++) {
222 if (InsecureRandBits(2) == 0) {
223 test.insert(InsecureRandRange(test.size() + 1), int(InsecureRand32()));
224 }
225 if (test.size() > 0 && InsecureRandBits(2) == 1) {
226 test.erase(InsecureRandRange(test.size()));
227 }
228 if (InsecureRandBits(3) == 2) {
229 int new_size = std::max(0, std::min(30, (int)test.size() + (int)InsecureRandRange(5) - 2));
230 test.resize(new_size);
231 }
232 if (InsecureRandBits(3) == 3) {
233 test.insert(InsecureRandRange(test.size() + 1), 1 + InsecureRandBool(), int(InsecureRand32()));
234 }
235 if (InsecureRandBits(3) == 4) {
236 int del = std::min<int>(test.size(), 1 + (InsecureRandBool()));
237 int beg = InsecureRandRange(test.size() + 1 - del);
238 test.erase(beg, beg + del);
239 }
240 if (InsecureRandBits(4) == 5) {
241 test.push_back(int(InsecureRand32()));
242 }
243 if (test.size() > 0 && InsecureRandBits(4) == 6) {
244 test.pop_back();
245 }
246 if (InsecureRandBits(5) == 7) {
247 int values[4];
248 int num = 1 + (InsecureRandBits(2));
249 for (int k = 0; k < num; k++) {
250 values[k] = int(InsecureRand32());
251 }
252 test.insert_range(InsecureRandRange(test.size() + 1), values, values + num);
253 }
254 if (InsecureRandBits(5) == 8) {
255 int del = std::min<int>(test.size(), 1 + (InsecureRandBits(2)));
256 int beg = InsecureRandRange(test.size() + 1 - del);
257 test.erase(beg, beg + del);
258 }
259 if (InsecureRandBits(5) == 9) {
260 test.reserve(InsecureRandBits(5));
261 }
262 if (InsecureRandBits(6) == 10) {
263 test.shrink_to_fit();
264 }
265 if (test.size() > 0) {
266 test.update(InsecureRandRange(test.size()), int(InsecureRand32()));
267 }
268 if (InsecureRandBits(10) == 11) {
269 test.clear();
270 }
271 if (InsecureRandBits(9) == 12) {
272 test.assign(InsecureRandBits(5), int(InsecureRand32()));
273 }
274 if (InsecureRandBits(3) == 3) {

Callers

nothing calls this directly

Calls 15

InsecureRandBitsFunction · 0.85
InsecureRandRangeFunction · 0.85
InsecureRand32Function · 0.85
InsecureRandBoolFunction · 0.85
insertMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
resizeMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45
insert_rangeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected