1 /*=============================================================================
2 Copyright (c) 2010 Tim Blechmann
4 Use, modification and distribution is subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
9 #include "common_heap_tests.hpp"
10 #include <boost/heap/heap_merge.hpp>
12 #define GENERATE_TEST_DATA(INDEX) \
13 test_data data = make_test_data(test_size, 0, 1); \
14 std::random_shuffle(data.begin(), data.end()); \
16 test_data data_q (data.begin(), data.begin() + INDEX); \
17 test_data data_r (data.begin() + INDEX, data.end()); \
19 std::stable_sort(data.begin(), data.end());
22 template <typename pri_queue>
23 struct pri_queue_test_merge
27 for (int i = 0; i != test_size; ++i) {
29 GENERATE_TEST_DATA(i);
36 BOOST_REQUIRE(r.empty());
43 template <typename pri_queue1, typename pri_queue2>
44 struct pri_queue_test_heap_merge
46 static void run (void)
48 for (int i = 0; i != test_size; ++i) {
51 GENERATE_TEST_DATA(i);
56 boost::heap::heap_merge(q, r);
58 BOOST_REQUIRE(r.empty());
66 template <typename pri_queue>
67 void run_merge_tests(void)
69 boost::mpl::if_c<pri_queue::is_mergable,
70 pri_queue_test_merge<pri_queue>,
74 pri_queue_test_heap_merge<pri_queue, pri_queue>::run();