[btree_damage_visitor] Make sure the path for a value includes it's key.

This commit is contained in:
Joe Thornber 2013-05-23 14:37:24 +01:00
parent 25a090279f
commit 12d6b8a2a7
2 changed files with 15 additions and 6 deletions

View File

@ -55,7 +55,7 @@ namespace persistent_data {
return r; return r;
} }
// remembe 'end' is the one-past-the-end value, so // remember 'end' is the one-past-the-end value, so
// take the last key in the leaf and add one. // take the last key in the leaf and add one.
maybe_range64 good_leaf(block_address begin, block_address end) { maybe_range64 good_leaf(block_address begin, block_address end) {
maybe_range64 r; maybe_range64 r;
@ -192,8 +192,11 @@ namespace persistent_data {
void visit_values(btree_path const &path, void visit_values(btree_path const &path,
node_ref<ValueTraits> const &n) { node_ref<ValueTraits> const &n) {
unsigned nr = n.get_nr_entries(); unsigned nr = n.get_nr_entries();
for (unsigned i = 0; i < nr; i++) for (unsigned i = 0; i < nr; i++) {
value_visitor_.visit(path, n.value_at(i)); btree_path p2(path);
p2.push_back(n.key_at(i));
value_visitor_.visit(p2, n.value_at(i));
}
} }
bool check_internal(node_location const &loc, bool check_internal(node_location const &loc,

View File

@ -351,7 +351,9 @@ namespace {
void expect_value_range(uint64_t begin, uint64_t end) { void expect_value_range(uint64_t begin, uint64_t end) {
while (begin < end) { while (begin < end) {
EXPECT_CALL(value_visitor_, visit(EmptyPath(), Eq(thing(begin, begin + 1234)))).Times(1); btree_path path;
path.push_back(begin);
EXPECT_CALL(value_visitor_, visit(Eq(path), Eq(thing(begin, begin + 1234)))).Times(1);
begin++; begin++;
} }
} }
@ -360,8 +362,10 @@ namespace {
expect_value_range(0, nr); expect_value_range(0, nr);
} }
void expect_value(unsigned n) { void expect_value(uint64_t n) {
EXPECT_CALL(value_visitor_, visit(EmptyPath(), Eq(thing(n, n + 1234)))).Times(1); btree_path path;
path.push_back(n);
EXPECT_CALL(value_visitor_, visit(Eq(path), Eq(thing(n, n + 1234)))).Times(1);
} }
void expect_damage(range<uint64_t> keys) { void expect_damage(range<uint64_t> keys) {
@ -415,6 +419,7 @@ namespace {
uint64_t key[2] = {sub_tree, i}; uint64_t key[2] = {sub_tree, i};
btree_path path; btree_path path;
path.push_back(sub_tree); path.push_back(sub_tree);
path.push_back(i);
EXPECT_CALL(value_visitor_, visit(Eq(path), EXPECT_CALL(value_visitor_, visit(Eq(path),
Eq(key_to_value(key)))); Eq(key_to_value(key))));
} }
@ -436,6 +441,7 @@ namespace {
btree_path p2; btree_path p2;
p2.push_back(sub_tree); p2.push_back(sub_tree);
p2.push_back(i);
EXPECT_CALL(value_visitor_, visit(Eq(p2), Eq(key_to_value(key)))); EXPECT_CALL(value_visitor_, visit(Eq(p2), Eq(key_to_value(key))));
} }
} }