mirror of
https://github.com/google/leveldb.git
synced 2025-02-04 07:10:10 +08:00
Simplify issue320_test.
Use std::unique_ptr to simplify issue320_test. PiperOrigin-RevId: 243190799
This commit is contained in:
parent
65e86f75ea
commit
08e771901f
@ -45,7 +45,8 @@ TEST(Issue320, Test) {
|
|||||||
bool delete_before_put = false;
|
bool delete_before_put = false;
|
||||||
bool keep_snapshots = true;
|
bool keep_snapshots = true;
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>*> test_map(10000, nullptr);
|
std::vector<std::unique_ptr<std::pair<std::string, std::string>>> test_map(
|
||||||
|
10000);
|
||||||
std::vector<Snapshot const*> snapshots(100, nullptr);
|
std::vector<Snapshot const*> snapshots(100, nullptr);
|
||||||
|
|
||||||
DB* db;
|
DB* db;
|
||||||
@ -73,7 +74,7 @@ TEST(Issue320, Test) {
|
|||||||
|
|
||||||
if (test_map[index] == nullptr) {
|
if (test_map[index] == nullptr) {
|
||||||
num_items++;
|
num_items++;
|
||||||
test_map[index] = new std::pair<std::string, std::string>(
|
test_map[index] = std::make_unique<std::pair<std::string, std::string>>(
|
||||||
CreateRandomString(index), CreateRandomString(index));
|
CreateRandomString(index), CreateRandomString(index));
|
||||||
batch.Put(test_map[index]->first, test_map[index]->second);
|
batch.Put(test_map[index]->first, test_map[index]->second);
|
||||||
} else {
|
} else {
|
||||||
@ -90,7 +91,6 @@ TEST(Issue320, Test) {
|
|||||||
|
|
||||||
if (num_items >= target_size && GenerateRandomNumber(100) > 30) {
|
if (num_items >= target_size && GenerateRandomNumber(100) > 30) {
|
||||||
batch.Delete(test_map[index]->first);
|
batch.Delete(test_map[index]->first);
|
||||||
delete test_map[index];
|
|
||||||
test_map[index] = nullptr;
|
test_map[index] = nullptr;
|
||||||
--num_items;
|
--num_items;
|
||||||
} else {
|
} else {
|
||||||
@ -117,13 +117,6 @@ TEST(Issue320, Test) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < test_map.size(); ++i) {
|
|
||||||
if (test_map[i] != nullptr) {
|
|
||||||
delete test_map[i];
|
|
||||||
test_map[i] = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete db;
|
delete db;
|
||||||
DestroyDB(dbpath, options);
|
DestroyDB(dbpath, options);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user