Commit 4aa69c20 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Make NeedleFinderTest::Needles256 actually do things

Summary:
The min value of a `char` is `-128`, but we're initializing our `size_t` i's with it, so, as MSVC quite rightly warns (as C6294) the condition is never true and the loop never loops.
Fix it by signing our i's.

Reviewed By: yfeldblum

Differential Revision: D4145419

fbshipit-source-id: 87591d0f84c54472b1b5847e025d091de3f98bca
parent 5eb31cb3
......@@ -946,17 +946,17 @@ TYPED_TEST(NeedleFinderTest, Needles256) {
const auto maxValue = std::numeric_limits<StringPiece::value_type>::max();
// make the size ~big to avoid any edge-case branches for tiny haystacks
const int haystackSize = 50;
for (size_t i = minValue; i <= maxValue; i++) { // <=
for (int i = minValue; i <= maxValue; i++) { // <=
needles.push_back(i);
}
EXPECT_EQ(StringPiece::npos, this->find_first_byte_of("", needles));
for (size_t i = minValue; i <= maxValue; i++) {
for (int i = minValue; i <= maxValue; i++) {
EXPECT_EQ(0, this->find_first_byte_of(string(haystackSize, i), needles));
}
needles.append("these are redundant characters");
EXPECT_EQ(StringPiece::npos, this->find_first_byte_of("", needles));
for (size_t i = minValue; i <= maxValue; i++) {
for (int i = minValue; i <= maxValue; i++) {
EXPECT_EQ(0, this->find_first_byte_of(string(haystackSize, i), needles));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment