From 4aa69c20b6b6b1e20eb6e6c1dd072ae8d1b02ac5 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Tue, 8 Nov 2016 10:40:14 -0800 Subject: [PATCH] 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 --- folly/test/RangeTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/folly/test/RangeTest.cpp b/folly/test/RangeTest.cpp index dc7e4ff0..49e9a86c 100644 --- a/folly/test/RangeTest.cpp +++ b/folly/test/RangeTest.cpp @@ -946,17 +946,17 @@ TYPED_TEST(NeedleFinderTest, Needles256) { const auto maxValue = std::numeric_limits::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)); } } -- 2.34.1