MCPcopy Create free account
hub / github.com/ElementsProject/elements / TEST

Function TEST

src/leveldb/issues/issue200_test.cc:16–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14class Issue200 {};
15
16TEST(Issue200, Test) {
17 // Get rid of any state from an old run.
18 std::string dbpath = test::TmpDir() + "/leveldb_issue200_test";
19 DestroyDB(dbpath, Options());
20
21 DB* db;
22 Options options;
23 options.create_if_missing = true;
24 ASSERT_OK(DB::Open(options, dbpath, &db));
25
26 WriteOptions write_options;
27 ASSERT_OK(db->Put(write_options, "1", "b"));
28 ASSERT_OK(db->Put(write_options, "2", "c"));
29 ASSERT_OK(db->Put(write_options, "3", "d"));
30 ASSERT_OK(db->Put(write_options, "4", "e"));
31 ASSERT_OK(db->Put(write_options, "5", "f"));
32
33 ReadOptions read_options;
34 Iterator* iter = db->NewIterator(read_options);
35
36 // Add an element that should not be reflected in the iterator.
37 ASSERT_OK(db->Put(write_options, "25", "cd"));
38
39 iter->Seek("5");
40 ASSERT_EQ(iter->key().ToString(), "5");
41 iter->Prev();
42 ASSERT_EQ(iter->key().ToString(), "4");
43 iter->Prev();
44 ASSERT_EQ(iter->key().ToString(), "3");
45 iter->Next();
46 ASSERT_EQ(iter->key().ToString(), "4");
47 iter->Next();
48 ASSERT_EQ(iter->key().ToString(), "5");
49
50 delete iter;
51 delete db;
52 DestroyDB(dbpath, options);
53}
54
55} // namespace leveldb
56

Callers

nothing calls this directly

Calls 10

TmpDirFunction · 0.85
DestroyDBFunction · 0.85
OptionsClass · 0.50
PutMethod · 0.45
NewIteratorMethod · 0.45
SeekMethod · 0.45
ToStringMethod · 0.45
keyMethod · 0.45
PrevMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected