MCPcopy Create free account
hub / github.com/Chemiculs/qengine / testSorting

Function testSorting

src/qengine/extern/asmjit/core/support.cpp:432–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432static void testSorting() noexcept {
433 INFO("Support::qSort() - Testing qsort and isort of predefined arrays");
434 {
435 constexpr size_t kArraySize = 11;
436
437 int ref_[kArraySize] = { -4, -2, -1, 0, 1, 9, 12, 13, 14, 19, 22 };
438 int arr1[kArraySize] = { 0, 1, -1, 19, 22, 14, -4, 9, 12, 13, -2 };
439 int arr2[kArraySize];
440
441 memcpy(arr2, arr1, kArraySize * sizeof(int));
442
443 Support::iSort(arr1, kArraySize);
444 Support::qSort(arr2, kArraySize);
445 testArrays(arr1, ref_, kArraySize);
446 testArrays(arr2, ref_, kArraySize);
447 }
448
449 INFO("Support::qSort() - Testing qsort and isort of artificial arrays");
450 {
451 constexpr size_t kArraySize = 200;
452
453 int arr1[kArraySize];
454 int arr2[kArraySize];
455 int ref_[kArraySize];
456
457 for (size_t size = 2; size < kArraySize; size++) {
458 for (size_t i = 0; i < size; i++) {
459 arr1[i] = int(size - 1 - i);
460 arr2[i] = int(size - 1 - i);
461 ref_[i] = int(i);
462 }
463
464 Support::iSort(arr1, size);
465 Support::qSort(arr2, size);
466 testArrays(arr1, ref_, size);
467 testArrays(arr2, ref_, size);
468 }
469 }
470
471 INFO("Support::qSort() - Testing qsort and isort with an unstable compare function");
472 {
473 constexpr size_t kArraySize = 5;
474
475 float arr1[kArraySize] = { 1.0f, 0.0f, 3.0f, -1.0f, std::numeric_limits<float>::quiet_NaN() };
476 float arr2[kArraySize] = { };
477
478 memcpy(arr2, arr1, kArraySize * sizeof(float));
479
480 // We don't test as it's undefined where the NaN would be.
481 Support::iSort(arr1, kArraySize);
482 Support::qSort(arr2, kArraySize);
483 }
484}
485
486UNIT(support) {
487 testAlignment();

Callers 1

UNITFunction · 0.85

Calls 3

iSortFunction · 0.85
qSortFunction · 0.85
testArraysFunction · 0.85

Tested by

no test coverage detected