Permalink
Browse files

-1 should allow unlimited image rewrites. (#1391)

  • Loading branch information...
hillsp committed Sep 13, 2016
1 parent 3f47828 commit 18d5549d7be6f857e2deb3285a67f6f3cd3f40ef
@@ -24,7 +24,7 @@
namespace net_instaweb {

StatisticsWorkBound::StatisticsWorkBound(UpDownCounter* counter, int bound)
: counter_((bound == 0) ? NULL : counter), bound_(bound) { }
: counter_((bound <= 0) ? NULL : counter), bound_(bound) { }
StatisticsWorkBound::~StatisticsWorkBound() { }

bool StatisticsWorkBound::TryToWork() {
@@ -100,6 +100,16 @@ TEST_F(StatisticsWorkBoundTest, TestZeroBound) {
}
}

// Test that a bound of -1 allows large # of tries.
TEST_F(StatisticsWorkBoundTest, TestNegativeBound) {
scoped_ptr<StatisticsWorkBound> bound1(MakeBound(var1_, -1));
scoped_ptr<StatisticsWorkBound> bound2(MakeBound(var1_, -1));
for (int i = 0; i < 1000; ++i) {
EXPECT_TRUE(bound1->TryToWork());
EXPECT_TRUE(bound2->TryToWork());
}
}

// Test that absent variable allows large # of tries.
TEST_F(StatisticsWorkBoundTest, TestNullVar) {
scoped_ptr<StatisticsWorkBound> bound1(MakeBound(NULL, 2));

0 comments on commit 18d5549

Please sign in to comment.