Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
-1 should allow unlimited image rewrites. (#1391)
  • Loading branch information
hillsp committed Sep 13, 2016
1 parent 3f47828 commit 18d5549
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pagespeed/kernel/util/statistics_work_bound.cc
Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions pagespeed/kernel/util/statistics_work_bound_test.cc
Expand Up @@ -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));
Expand Down

0 comments on commit 18d5549

Please sign in to comment.