MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / testIterators

Method testIterators

test/tests/containers/TestArray.h:372–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370 }
371
372 void testIterators() {
373
374 Array<int> array1(mAllocator);
375
376 rp3d_test(array1.begin() == array1.end());
377
378 array1.add(5);
379 array1.add(6);
380 array1.add(8);
381 array1.add(-1);
382
383 Array<int>::Iterator itBegin = array1.begin();
384 Array<int>::Iterator itEnd = array1.end();
385 Array<int>::Iterator it = array1.begin();
386
387 rp3d_test(itBegin < itEnd);
388 rp3d_test(itBegin <= itEnd);
389 rp3d_test(itEnd > itBegin);
390 rp3d_test(itEnd >= itBegin);
391
392 rp3d_test(itBegin == it);
393 rp3d_test(*it == 5);
394 rp3d_test(*(it++) == 5);
395 rp3d_test(*it == 6);
396 rp3d_test(*(it--) == 6);
397 rp3d_test(*it == 5);
398 rp3d_test(*(++it) == 6);
399 rp3d_test(*it == 6);
400 rp3d_test(*(--it) == 5);
401 rp3d_test(*it == 5);
402 rp3d_test(it == itBegin);
403
404 it = array1.end();
405 rp3d_test(it == itEnd);
406 it--;
407 rp3d_test(*it == -1);
408 it++;
409 rp3d_test(it == itEnd);
410
411 Array<int> array2(mAllocator);
412 for (auto it = array1.begin(); it != array1.end(); ++it) {
413 array2.add(*it);
414 }
415
416 rp3d_test(array1 == array2);
417
418 it = itBegin;
419 rp3d_test(*(it + 2) == 8);
420 it += 2;
421 rp3d_test(*it == 8);
422 rp3d_test(*(it - 2) == 5);
423 it -= 2;
424 rp3d_test(*it == 5);
425 rp3d_test((itEnd - itBegin) == 4);
426
427 it = itBegin;
428 *it = 19;
429 rp3d_test(*it == 19);

Callers

nothing calls this directly

Calls 3

beginMethod · 0.45
endMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected