summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/tests/sort_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bx/tests/sort_test.cpp')
-rw-r--r--3rdparty/bx/tests/sort_test.cpp62
1 files changed, 23 insertions, 39 deletions
diff --git a/3rdparty/bx/tests/sort_test.cpp b/3rdparty/bx/tests/sort_test.cpp
index c2eef4ae186..4abb76db334 100644
--- a/3rdparty/bx/tests/sort_test.cpp
+++ b/3rdparty/bx/tests/sort_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2023 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx/blob/master/LICENSE
*/
@@ -9,7 +9,7 @@
#include <bx/string.h>
#include <bx/rng.h>
-TEST_CASE("quickSort", "[sort]")
+TEST_CASE("sort-quickSort", "")
{
const char* str[] =
{
@@ -30,40 +30,6 @@ TEST_CASE("quickSort", "[sort]")
REQUIRE(bx::isSorted(str, BX_COUNTOF(str) ) );
- int8_t byte[128];
- bx::RngMwc rng;
- for (uint32_t ii = 0; ii < BX_COUNTOF(byte); ++ii)
- {
- byte[ii] = rng.gen()&0xff;
- }
-
- REQUIRE(!bx::isSorted(byte, BX_COUNTOF(byte) ) );
-
- bx::quickSort(byte, BX_COUNTOF(byte) );
-
- for (uint32_t ii = 1; ii < BX_COUNTOF(byte); ++ii)
- {
- REQUIRE(byte[ii-1] <= byte[ii]);
- }
-
- REQUIRE(bx::isSorted(byte, BX_COUNTOF(byte) ) );
-}
-
-TEST_CASE("binarySearch", "[sort]")
-{
- const char* str[] =
- {
- "jabuka",
- "kruska",
- "malina",
- "jagoda",
- };
-
- REQUIRE(!bx::isSorted(str, BX_COUNTOF(str) ) );
-
- bx::quickSort(str, BX_COUNTOF(str) );
- REQUIRE(bx::isSorted(str, BX_COUNTOF(str) ) );
-
auto bsearchStrCmpFn = [](const void* _lhs, const void* _rhs)
{
const char* lhs = (const char*)_lhs;
@@ -89,9 +55,27 @@ TEST_CASE("binarySearch", "[sort]")
REQUIRE( 3 == bx::lowerBound("malina", str, BX_COUNTOF(str), sizeof(str[0]), bsearchStrCmpFn) );
REQUIRE( 4 == bx::upperBound("malina", str, BX_COUNTOF(str), sizeof(str[0]), bsearchStrCmpFn) );
+
+ int8_t byte[128];
+ bx::RngMwc rng;
+ for (uint32_t ii = 0; ii < BX_COUNTOF(byte); ++ii)
+ {
+ byte[ii] = rng.gen()&0xff;
+ }
+
+ REQUIRE(!bx::isSorted(byte, BX_COUNTOF(byte) ) );
+
+ bx::quickSort(byte, BX_COUNTOF(byte) );
+
+ for (uint32_t ii = 1; ii < BX_COUNTOF(byte); ++ii)
+ {
+ REQUIRE(byte[ii-1] <= byte[ii]);
+ }
+
+ REQUIRE(bx::isSorted(byte, BX_COUNTOF(byte) ) );
}
-TEST_CASE("unique", "[sort]")
+TEST_CASE("sort-unique", "")
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | 14
int32_t test[] = { 100, 101, 101, 101, 103, 104, 105, 105, 105, 106, 106, 107, 108, 109 };
@@ -112,7 +96,7 @@ TEST_CASE("unique", "[sort]")
REQUIRE(9 == bx::unique(test, last) );
}
-TEST_CASE("lowerBound, upperBound int32_t", "[sort]")
+TEST_CASE("sort-lower/upperBound int32_t", "")
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | 14
const int32_t test[] = { 100, 101, 101, 101, 103, 104, 105, 105, 105, 106, 106, 107, 108, 109 };
@@ -166,7 +150,7 @@ void compareTest(const Ty& _min, const Ty& _max)
REQUIRE(-1 == compareDescendingTest<Ty>(_max, _min) );
}
-TEST_CASE("ComparisonFn", "[sort]")
+TEST_CASE("sort-ComparisonFn", "")
{
compareTest< int8_t>( -13, 89);
compareTest<int16_t>(-1389, 1389);