Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Maybe:
TEST(SanitizerCommon, InternalBinarySearchVsLowerBound) { std::vector<int> data; auto create_item = [] (size_t i, size_t j) { auto v = i * 10000 + j; return ((v << 6) + (v >> 6) + 0x9e3779b9) % 100; }; for (size_t i = 0; i < 1000; ++i) { data.resize(i); for (size_t j = 0; j < i; ++j) { data[j] = create_item(i, j); } std::sort(data.begin(), data.end()); for (size_t j = 0; j < i; ++j) { int val = create_item(i, j); for (auto to_find : {val - 1, val, val + 1}) { uptr expected = std::lower_bound(data.begin(), data.end(), to_find) - data.begin(); EXPECT_EQ(expected, InternalBinarySearch(data.data(), 0, data.size(), to_find, std::less<int>())); } } } }