Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Dec 11, 2018
1 parent d60cae1 commit 71409ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/entt/core/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ struct insertion_sort final {
*/
template<typename It, typename Compare = std::less<>>
void operator()(It first, It last, Compare compare = Compare{}) const {
if(first != last)
{
if(first != last) {
auto it = first + 1;

while(it != last) {
Expand Down
7 changes: 7 additions & 0 deletions test/entt/core/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ TEST(Algorithm, InsertionSort) {
ASSERT_LT(arr[i], arr[i+1]);
}
}

TEST(Algorithm, InsertionSortEmptyContainer) {
std::vector<int> vec{};
entt::insertion_sort sort;
// this should crash with asan enabled if we break the constraint
sort(vec.begin(), vec.end());
}

0 comments on commit 71409ad

Please sign in to comment.