Check parent pointers
This commit is contained in:
@@ -349,6 +349,19 @@ void rotate(Node **node, bool dir) {
|
|||||||
updateMaxVersion(l);
|
updateMaxVersion(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkParentPointers(Node *node, bool &success) {
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
if (node->child[i] != nullptr) {
|
||||||
|
if (node->child[i]->parent != node) {
|
||||||
|
fprintf(stderr, "%.*s child %d has parent pointer %p. Expected %p\n",
|
||||||
|
node->len, (const char *)(node + 1), i,
|
||||||
|
(void *)node->child[i]->parent, (void *)node);
|
||||||
|
}
|
||||||
|
checkParentPointers(node->child[i], success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int64_t checkMaxVersion(Node *node, bool &success) {
|
int64_t checkMaxVersion(Node *node, bool &success) {
|
||||||
int64_t expected = std::max(node->pointVersion, node->rangeVersion);
|
int64_t expected = std::max(node->pointVersion, node->rangeVersion);
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
@@ -385,6 +398,7 @@ bool checkInvariants(Node *node) {
|
|||||||
assert(std::is_sorted(keys.begin(), keys.end()));
|
assert(std::is_sorted(keys.begin(), keys.end()));
|
||||||
|
|
||||||
checkMaxVersion(node, success);
|
checkMaxVersion(node, success);
|
||||||
|
checkParentPointers(node, success);
|
||||||
|
|
||||||
// TODO Compare logical contents of map with
|
// TODO Compare logical contents of map with
|
||||||
// reference implementation
|
// reference implementation
|
||||||
|
Reference in New Issue
Block a user