Make NeedleFinderTest::Needles256 actually do things
authorChristopher Dykes <cdykes@fb.com>
Tue, 8 Nov 2016 18:40:14 +0000 (10:40 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Tue, 8 Nov 2016 18:53:28 +0000 (10:53 -0800)
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

folly/test/RangeTest.cpp

index dc7e4ff0842b5470d9eaf77aa85099685e4c5612..49e9a86c906058b736d0cc9367b05847de493dd0 100644 (file)
@@ -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));
   }
 }