[damage_tracker] Reset the tracker in the end() method so we can reuse it.
The *_check tools already reuse trackers. Patch from Ming-Hung Tsai.
This commit is contained in:
parent
85d1701ba1
commit
880785a9bf
@ -70,10 +70,17 @@ namespace persistent_data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maybe_run64 end() {
|
maybe_run64 end() {
|
||||||
|
maybe_run64 r;
|
||||||
|
|
||||||
if (damaged_)
|
if (damaged_)
|
||||||
return maybe_run64(damage_begin_);
|
r = maybe_run64(damage_begin_);
|
||||||
else
|
else
|
||||||
return maybe_run64();
|
r = maybe_run64();
|
||||||
|
|
||||||
|
damaged_ = false;
|
||||||
|
damage_begin_ = 0;
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -98,4 +98,15 @@ TEST_F(DamageTrackerTests, gi_bi_gi_bl_gl)
|
|||||||
assert_damage(dt.good_leaf(15, 20), run64(10ull, 15ull));
|
assert_damage(dt.good_leaf(15, 20), run64(10ull, 15ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DamageTrackerTests, end_resets_tracker)
|
||||||
|
{
|
||||||
|
dt.good_internal(0);
|
||||||
|
dt.good_leaf(0, 10);
|
||||||
|
dt.bad_node();
|
||||||
|
assert_damage(dt.end(), run64(10ull));
|
||||||
|
|
||||||
|
assert_no_damage(dt.good_leaf(20, 30));
|
||||||
|
assert_no_damage(dt.end());
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user