mirror of
https://github.com/boostorg/move.git
synced 2025-07-30 20:37:13 +02:00
- Use assertions and invariant checking in release mode testing for sorting/merging
- Disable Wconversion due to iterators using small "difference_type" integers.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
@ -60,6 +60,7 @@
|
||||
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_MOVE_ADAPTIVE_SORT_STATS_LEVEL
|
||||
@ -93,26 +94,12 @@
|
||||
#define BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(L)
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MOVE_ADAPTIVE_SORT_INVARIANTS)
|
||||
#include <boost/move/algo/detail/is_sorted.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace movelib {
|
||||
|
||||
#if defined(BOOST_MOVE_ADAPTIVE_SORT_INVARIANTS)
|
||||
|
||||
bool is_sorted(::order_perf_type *first, ::order_perf_type *last, ::order_type_less)
|
||||
{
|
||||
if (first != last) {
|
||||
const order_perf_type *next = first, *cur(first);
|
||||
while (++next != last) {
|
||||
if (!(cur->key < next->key || (cur->key == next->key && cur->val < next->val)))
|
||||
return false;
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //BOOST_MOVE_ADAPTIVE_SORT_INVARIANTS
|
||||
|
||||
namespace detail_adaptive {
|
||||
|
||||
static const std::size_t AdaptiveSortInsertionSortThreshold = 16;
|
||||
@ -1320,7 +1307,6 @@ void op_merge_blocks_with_buf
|
||||
//swap_and_update_key(key_next, key_range2, key_mid, first2, last2, first_min);
|
||||
buffer_end = buffer_and_update_key(key_next, key_range2, key_mid, first2, last2, first_min, buffer = buf_first, op);
|
||||
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_swp: ", len);
|
||||
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first2, last2, comp));
|
||||
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first_min, last_min, comp));
|
||||
first1 = first2;
|
||||
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first, first1, comp));
|
||||
|
@ -9,6 +9,12 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef NDEBUG
|
||||
#undef NDEBUG
|
||||
#endif
|
||||
|
||||
#define BOOST_MOVE_ADAPTIVE_SORT_INVARIANTS
|
||||
|
||||
#include <cstdlib> //std::srand
|
||||
#include <iostream> //std::cout
|
||||
|
||||
@ -82,7 +88,9 @@ int main()
|
||||
instantiate_smalldiff_iterators();
|
||||
|
||||
const std::size_t NIter = 100;
|
||||
test_random_shuffled<order_move_type>(10001, 3, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 3, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 101, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 874, NIter);
|
||||
test_random_shuffled<order_move_type>(10001, 65, NIter);
|
||||
test_random_shuffled<order_move_type>(10001, 101, NIter);
|
||||
test_random_shuffled<order_move_type>(10001, 1023, NIter);
|
||||
|
@ -9,6 +9,12 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef NDEBUG
|
||||
#undef NDEBUG
|
||||
#endif
|
||||
|
||||
#define BOOST_MOVE_ADAPTIVE_SORT_INVARIANTS
|
||||
|
||||
#include <cstdlib> //std::srand
|
||||
#include <iostream> //std::cout
|
||||
|
||||
@ -74,6 +80,13 @@ int main()
|
||||
instantiate_smalldiff_iterators();
|
||||
|
||||
const std::size_t NIter = 100;
|
||||
|
||||
test_random_shuffled<order_move_type>(1001, 3, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 65, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 101, NIter);
|
||||
test_random_shuffled<order_move_type>(1001, 200, NIter);
|
||||
|
||||
|
||||
//Below absolute minimal unique values
|
||||
test_random_shuffled<order_move_type>(10001, 3, NIter);
|
||||
//Above absolute minimal unique values, below internal buffer
|
||||
|
@ -134,11 +134,34 @@ inline bool is_order_type_ordered(T *elements, std::size_t element_count, bool s
|
||||
|
||||
namespace boost {
|
||||
namespace movelib {
|
||||
namespace detail_adaptive {
|
||||
|
||||
inline bool is_sorted(::order_perf_type *first, ::order_perf_type *last, ::order_type_less)
|
||||
{
|
||||
if (first != last) {
|
||||
const order_perf_type *next = first, *cur(first);
|
||||
while (++next != last) {
|
||||
if (!(cur->key < next->key || (cur->key == next->key && cur->val < next->val)))
|
||||
return false;
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_sorted(::order_move_type* first, ::order_move_type* last, ::order_type_less)
|
||||
{
|
||||
if (first != last) {
|
||||
const order_move_type* next = first, * cur(first);
|
||||
while (++next != last) {
|
||||
if (!(cur->key < next->key || (cur->key == next->key && cur->val < next->val)))
|
||||
return false;
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
||||
}} //boost::movelib
|
||||
|
||||
template<class T>
|
||||
inline bool is_key(T *elements, std::size_t element_count)
|
||||
|
Reference in New Issue
Block a user