• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2010 Tim Blechmann
3 
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 =============================================================================*/
8 
9 #define BOOST_TEST_MAIN
10 #include <boost/test/unit_test.hpp>
11 
12 #include <algorithm>
13 
14 #include <boost/heap/binomial_heap.hpp>
15 
16 #include "common_heap_tests.hpp"
17 #include "stable_heap_tests.hpp"
18 #include "mutable_heap_tests.hpp"
19 #include "merge_heap_tests.hpp"
20 
21 template <bool stable, bool constant_time_size>
run_binomial_heap_test(void)22 void run_binomial_heap_test(void)
23 {
24     typedef boost::heap::binomial_heap<int, boost::heap::stable<stable>,
25                                             boost::heap::compare<std::less<int> >,
26                                             boost::heap::allocator<std::allocator<int> >,
27                                             boost::heap::constant_time_size<constant_time_size> > pri_queue;
28 
29     BOOST_CONCEPT_ASSERT((boost::heap::MutablePriorityQueue<pri_queue>));
30     BOOST_CONCEPT_ASSERT((boost::heap::MergablePriorityQueue<pri_queue>));
31 
32     run_common_heap_tests<pri_queue>();
33     run_iterator_heap_tests<pri_queue>();
34     run_copyable_heap_tests<pri_queue>();
35     run_moveable_heap_tests<pri_queue>();
36 
37     run_merge_tests<pri_queue>();
38 
39     run_mutable_heap_tests<pri_queue >();
40     run_ordered_iterator_tests<pri_queue>();
41 
42     if (stable) {
43         typedef boost::heap::binomial_heap<q_tester, boost::heap::stable<stable>,
44                                                      boost::heap::constant_time_size<constant_time_size> > stable_pri_queue;
45 
46         run_stable_heap_tests<stable_pri_queue>();
47     }
48 }
49 
BOOST_AUTO_TEST_CASE(binomial_heap_test)50 BOOST_AUTO_TEST_CASE( binomial_heap_test )
51 {
52     run_binomial_heap_test<false, false>();
53     run_binomial_heap_test<false, true>();
54     run_binomial_heap_test<true, false>();
55     run_binomial_heap_test<true, true>();
56 
57     RUN_EMPLACE_TEST(binomial_heap);
58 }
59 
BOOST_AUTO_TEST_CASE(binomial_heap_compare_lookup_test)60 BOOST_AUTO_TEST_CASE( binomial_heap_compare_lookup_test )
61 {
62     typedef boost::heap::binomial_heap<int,
63                                        boost::heap::compare<less_with_T>,
64                                        boost::heap::allocator<std::allocator<int> > > pri_queue;
65     run_common_heap_tests<pri_queue>();
66 }
67 
BOOST_AUTO_TEST_CASE(binomial_heap_leak_test)68 BOOST_AUTO_TEST_CASE( binomial_heap_leak_test )
69 {
70     typedef boost::heap::binomial_heap<boost::shared_ptr<int> > pri_queue;
71     run_leak_check_test<pri_queue>();
72 }
73