aboutsummaryrefslogtreecommitdiff
path: root/EASTL/test/source/TestSort.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'EASTL/test/source/TestSort.cpp')
-rw-r--r--EASTL/test/source/TestSort.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/EASTL/test/source/TestSort.cpp b/EASTL/test/source/TestSort.cpp
index 2d0116f..114a73b 100644
--- a/EASTL/test/source/TestSort.cpp
+++ b/EASTL/test/source/TestSort.cpp
@@ -177,8 +177,22 @@ namespace eastl
return x;
}
};
+
+ struct TestNoLessOperator
+ {
+ int i {};
+ };
} // namespace Internal
+ template <>
+ struct less<Internal::TestNoLessOperator>
+ {
+ bool operator()(const Internal::TestNoLessOperator& lhs, const Internal::TestNoLessOperator& rhs) const noexcept
+ {
+ return lhs.i < rhs.i;
+ }
+ };
+
} // namespace eastl
int TestSort()
@@ -630,6 +644,13 @@ int TestSort()
radix_sort<uint32_t*, identity_extract_radix_key<uint32_t>>(begin(input), end(input), buffer);
EATEST_VERIFY(is_sorted(begin(input), end(input)));
}
+ {
+ // Test case for bug where the last histogram bucket was not being cleared to zero
+ uint32_t input[] = { 0xff00, 0xff };
+ uint32_t buffer[EAArrayCount(input)];
+ radix_sort<uint32_t*, identity_extract_radix_key<uint32_t>>(begin(input), end(input), buffer);
+ EATEST_VERIFY(is_sorted(begin(input), end(input)));
+ }
}
{
@@ -793,7 +814,7 @@ int TestSort()
}
{
- // EATEST_VERIFY deque sorting can compile.
+ // Test checking that deque sorting can compile.
deque<int> intDeque;
vector<int> intVector;
@@ -801,6 +822,25 @@ int TestSort()
stable_sort(intVector.begin(), intVector.end());
}
+ {
+ // Test checking that sorting containers having elements of a type without an operator< compiles correctly
+
+ vector<TestNoLessOperator> noLessVector;
+
+ stable_sort(noLessVector.begin(), noLessVector.end());
+ bubble_sort(noLessVector.begin(), noLessVector.end());
+ shaker_sort(noLessVector.begin(), noLessVector.end());
+ insertion_sort(noLessVector.begin(), noLessVector.end());
+ selection_sort(noLessVector.begin(), noLessVector.end());
+ shell_sort(noLessVector.begin(), noLessVector.end());
+ comb_sort(noLessVector.begin(), noLessVector.end());
+ heap_sort(noLessVector.begin(), noLessVector.end());
+ merge_sort(noLessVector.begin(), noLessVector.end(), *get_default_allocator(nullptr));
+ quick_sort(noLessVector.begin(), noLessVector.end());
+
+ vector<TestNoLessOperator> buffer;
+ tim_sort_buffer(noLessVector.begin(), noLessVector.end(), buffer.data());
+}
{
// Test sorting of a container of pointers to objects as opposed to a container of objects themselves.