| 73 | } |
| 74 | |
| 75 | void Check(int min_expected, int max_expected) { |
| 76 | int next_expected = 0; |
| 77 | int missed = 0; |
| 78 | int bad_keys = 0; |
| 79 | int bad_values = 0; |
| 80 | int correct = 0; |
| 81 | std::string value_space; |
| 82 | Iterator* iter = db_->NewIterator(ReadOptions()); |
| 83 | for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { |
| 84 | uint64_t key; |
| 85 | Slice in(iter->key()); |
| 86 | if (in == "" || in == "~") { |
| 87 | // Ignore boundary keys. |
| 88 | continue; |
| 89 | } |
| 90 | if (!ConsumeDecimalNumber(&in, &key) || !in.empty() || |
| 91 | key < next_expected) { |
| 92 | bad_keys++; |
| 93 | continue; |
| 94 | } |
| 95 | missed += (key - next_expected); |
| 96 | next_expected = key + 1; |
| 97 | if (iter->value() != Value(key, &value_space)) { |
| 98 | bad_values++; |
| 99 | } else { |
| 100 | correct++; |
| 101 | } |
| 102 | } |
| 103 | delete iter; |
| 104 | |
| 105 | fprintf(stderr, |
| 106 | "expected=%d..%d; got=%d; bad_keys=%d; bad_values=%d; missed=%d\n", |
| 107 | min_expected, max_expected, correct, bad_keys, bad_values, missed); |
| 108 | ASSERT_LE(min_expected, correct); |
| 109 | ASSERT_GE(max_expected, correct); |
| 110 | } |
| 111 | |
| 112 | void Corrupt(FileType filetype, int offset, int bytes_to_corrupt) { |
| 113 | // Pick file to corrupt |
nothing calls this directly
no test coverage detected