| 139 | } |
| 140 | |
| 141 | void adaptors_test::test_priority_queue() |
| 142 | { |
| 143 | auto check1 = {9, 8, 5, 4, 2, 1}; |
| 144 | std::vector<int> data{5, 4, 2, 8, 1}; |
| 145 | std::priority_queue<int> q1{data.begin(), data.end()}; |
| 146 | |
| 147 | test_eq("priority_queue initialized from iterator range not empty", q1.empty(), false); |
| 148 | test_eq("priority_queue initialized from iterator range size", q1.size(), 5U); |
| 149 | |
| 150 | q1.push(9); |
| 151 | test_eq("priority_queue push pt1", q1.size(), 6U); |
| 152 | test_eq("priority_queue push pt2", q1.top(), 9); |
| 153 | |
| 154 | test_eq( |
| 155 | "priority_queue initialized from iterator range ops", |
| 156 | check1.begin(), check1.end(), |
| 157 | aux::priority_queue_iterator<int>{q1}, |
| 158 | aux::priority_queue_iterator<int>{q1, true} |
| 159 | ); |
| 160 | |
| 161 | auto check2 = {1, 2, 3, 4, 5, 8}; |
| 162 | std::priority_queue<int, std::vector<int>, std::greater<int>> q2{std::greater<int>{}, data}; |
| 163 | |
| 164 | test_eq("priority_queue initialized from vector and compare not empty", q2.empty(), false); |
| 165 | test_eq("priority_queue initialized from vector and compare size", q2.size(), 5U); |
| 166 | |
| 167 | q2.push(3); |
| 168 | test_eq("priority_queue push pt1", q2.size(), 6U); |
| 169 | test_eq("priority_queue push pt2", q2.top(), 1); |
| 170 | |
| 171 | test_eq( |
| 172 | "priority_queue initialized from vector and compare ops", |
| 173 | check2.begin(), check2.end(), |
| 174 | aux::priority_queue_iterator<int, std::greater<int>>{q2}, |
| 175 | aux::priority_queue_iterator<int, std::greater<int>>{q2, true} |
| 176 | ); |
| 177 | } |
| 178 | |
| 179 | void adaptors_test::test_stack() |
| 180 | { |