forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
137 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2013 The LevelDB Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
// Test for issue 200: when iterator switches direction from backward | ||
// to forward, the current key can be yielded unexpectedly if a new | ||
// mutation has been added just before the current key. | ||
|
||
#include "leveldb/db.h" | ||
#include "util/testharness.h" | ||
|
||
namespace leveldb { | ||
|
||
class Issue200 { }; | ||
|
||
TEST(Issue200, Test) { | ||
// Get rid of any state from an old run. | ||
std::string dbpath = test::TmpDir() + "/leveldb_issue200_test"; | ||
DestroyDB(dbpath, Options()); | ||
|
||
DB *db; | ||
Options options; | ||
options.create_if_missing = true; | ||
ASSERT_OK(DB::Open(options, dbpath, &db)); | ||
|
||
WriteOptions write_options; | ||
ASSERT_OK(db->Put(write_options, "1", "b")); | ||
ASSERT_OK(db->Put(write_options, "2", "c")); | ||
ASSERT_OK(db->Put(write_options, "3", "d")); | ||
ASSERT_OK(db->Put(write_options, "4", "e")); | ||
ASSERT_OK(db->Put(write_options, "5", "f")); | ||
|
||
ReadOptions read_options; | ||
Iterator *iter = db->NewIterator(read_options); | ||
|
||
// Add an element that should not be reflected in the iterator. | ||
ASSERT_OK(db->Put(write_options, "25", "cd")); | ||
|
||
iter->Seek("5"); | ||
ASSERT_EQ(iter->key().ToString(), "5"); | ||
iter->Prev(); | ||
ASSERT_EQ(iter->key().ToString(), "4"); | ||
iter->Prev(); | ||
ASSERT_EQ(iter->key().ToString(), "3"); | ||
iter->Next(); | ||
ASSERT_EQ(iter->key().ToString(), "4"); | ||
iter->Next(); | ||
ASSERT_EQ(iter->key().ToString(), "5"); | ||
|
||
delete iter; | ||
delete db; | ||
DestroyDB(dbpath, options); | ||
} | ||
|
||
} // namespace leveldb | ||
|
||
int main(int argc, char** argv) { | ||
return leveldb::test::RunAllTests(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters