Verify that IntervalTree::FindContainingPoint yields the same results as the naive brute-force O(n) algorithm.
| 200 | // Verify that IntervalTree::FindContainingPoint yields the same results as the naive |
| 201 | // brute-force O(n) algorithm. |
| 202 | static void VerifyFindContainingPoint(const vector<IntInterval>& all_intervals, |
| 203 | const IntervalTree<IntTraits>& tree, |
| 204 | int query_point) { |
| 205 | vector<IntInterval> results; |
| 206 | tree.FindContainingPoint(query_point, &results); |
| 207 | std::sort(results.begin(), results.end(), CompareIntervals); |
| 208 | |
| 209 | vector<IntInterval> brute_force; |
| 210 | FindContainingBruteForce(all_intervals, query_point, &brute_force); |
| 211 | std::sort(brute_force.begin(), brute_force.end(), CompareIntervals); |
| 212 | |
| 213 | SCOPED_TRACE(Stringify(all_intervals) + StringPrintf(" {q=%d}", query_point)); |
| 214 | EXPECT_EQ(Stringify(brute_force), Stringify(results)); |
| 215 | } |
| 216 | |
| 217 | // Verify that IntervalTree::FindIntersectingInterval yields the same results as the naive |
| 218 | // brute-force O(n) algorithm. |
no test coverage detected