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/skew_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, bool store_parent_pointer> |
22 | void run_skew_heap_test(void) |
23 | { |
24 | typedef boost::heap::skew_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>, |
28 | boost::heap::store_parent_pointer<store_parent_pointer> |
29 | > pri_queue; |
30 | |
31 | BOOST_CONCEPT_ASSERT((boost::heap::PriorityQueue<pri_queue>)); |
32 | BOOST_CONCEPT_ASSERT((boost::heap::MergablePriorityQueue<pri_queue>)); |
33 | |
34 | run_common_heap_tests<pri_queue>(); |
35 | run_iterator_heap_tests<pri_queue>(); |
36 | run_copyable_heap_tests<pri_queue>(); |
37 | run_moveable_heap_tests<pri_queue>(); |
38 | |
39 | run_merge_tests<pri_queue>(); |
40 | |
41 | pri_queue_test_ordered_iterators<pri_queue>(); |
42 | |
43 | if (stable) { |
44 | typedef boost::heap::skew_heap<q_tester, boost::heap::stable<stable>, |
45 | boost::heap::constant_time_size<constant_time_size>, |
46 | boost::heap::store_parent_pointer<store_parent_pointer> |
47 | > stable_pri_queue; |
48 | run_stable_heap_tests<stable_pri_queue>(); |
49 | } |
50 | } |
51 | |
52 | template <bool stable, bool constant_time_size> |
53 | void run_skew_heap_mutable_test(void) |
54 | { |
55 | typedef boost::heap::skew_heap<int, boost::heap::stable<stable>, boost::heap::mutable_<true>, |
56 | boost::heap::compare<std::less<int> >, |
57 | boost::heap::allocator<std::allocator<int> >, |
58 | boost::heap::constant_time_size<constant_time_size> |
59 | > pri_queue; |
60 | |
61 | BOOST_CONCEPT_ASSERT((boost::heap::MutablePriorityQueue<pri_queue>)); |
62 | BOOST_CONCEPT_ASSERT((boost::heap::MergablePriorityQueue<pri_queue>)); |
63 | |
64 | run_common_heap_tests<pri_queue>(); |
65 | run_iterator_heap_tests<pri_queue>(); |
66 | run_copyable_heap_tests<pri_queue>(); |
67 | run_moveable_heap_tests<pri_queue>(); |
68 | |
69 | run_merge_tests<pri_queue>(); |
70 | |
71 | run_mutable_heap_tests<pri_queue >(); |
72 | |
73 | run_ordered_iterator_tests<pri_queue>(); |
74 | |
75 | if (stable) { |
76 | typedef boost::heap::skew_heap<q_tester, boost::heap::stable<stable>, boost::heap::mutable_<true>, |
77 | boost::heap::constant_time_size<constant_time_size> |
78 | > stable_pri_queue; |
79 | run_stable_heap_tests<stable_pri_queue>(); |
80 | } |
81 | } |
82 | |
83 | |
84 | BOOST_AUTO_TEST_CASE( skew_heap_test ) |
85 | { |
86 | run_skew_heap_test<false, false, true>(); |
87 | run_skew_heap_test<false, true, true>(); |
88 | run_skew_heap_test<true, false, true>(); |
89 | run_skew_heap_test<true, true, true>(); |
90 | |
91 | run_skew_heap_test<false, false, false>(); |
92 | run_skew_heap_test<false, true, false>(); |
93 | run_skew_heap_test<true, false, false>(); |
94 | run_skew_heap_test<true, true, false>(); |
95 | |
96 | RUN_EMPLACE_TEST(skew_heap); |
97 | } |
98 | |
99 | BOOST_AUTO_TEST_CASE( skew_heap_mutable_test ) |
100 | { |
101 | run_skew_heap_mutable_test<false, false>(); |
102 | run_skew_heap_mutable_test<false, true>(); |
103 | run_skew_heap_mutable_test<true, false>(); |
104 | run_skew_heap_mutable_test<true, true>(); |
105 | } |
106 | |
107 | BOOST_AUTO_TEST_CASE( skew_heap_compare_lookup_test ) |
108 | { |
109 | typedef boost::heap::skew_heap<int, |
110 | boost::heap::compare<less_with_T>, |
111 | boost::heap::allocator<std::allocator<int> > > pri_queue; |
112 | run_common_heap_tests<pri_queue>(); |
113 | } |
114 | |
115 | |
116 | BOOST_AUTO_TEST_CASE( skew_heap_leak_test ) |
117 | { |
118 | typedef boost::heap::skew_heap<boost::shared_ptr<int> > pri_queue; |
119 | run_leak_check_test<pri_queue>(); |
120 | } |
121 | |