Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
version_edit_test.cc
Go to the documentation of this file.
1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
4 
5 #include "db/version_edit.h"
6 #include "util/testharness.h"
7 
8 namespace leveldb {
9 
10 static void TestEncodeDecode(const VersionEdit& edit) {
11  std::string encoded, encoded2;
12  edit.EncodeTo(&encoded);
13  VersionEdit parsed;
14  Status s = parsed.DecodeFrom(encoded);
15  ASSERT_TRUE(s.ok()) << s.ToString();
16  parsed.EncodeTo(&encoded2);
17  ASSERT_EQ(encoded, encoded2);
18 }
19 
20 class VersionEditTest { };
21 
22 TEST(VersionEditTest, EncodeDecode) {
23  static const uint64_t kBig = 1ull << 50;
24 
25  VersionEdit edit;
26  for (int i = 0; i < 4; i++) {
27  TestEncodeDecode(edit);
28  edit.AddFile(3, kBig + 300 + i, kBig + 400 + i,
29  InternalKey("foo", kBig + 500 + i, kTypeValue),
30  InternalKey("zoo", kBig + 600 + i, kTypeDeletion));
31  edit.DeleteFile(4, kBig + 700 + i);
32  edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue));
33  }
34 
35  edit.SetComparatorName("foo");
36  edit.SetLogNumber(kBig + 100);
37  edit.SetNextFile(kBig + 200);
38  edit.SetLastSequence(kBig + 1000);
39  TestEncodeDecode(edit);
40 }
41 
42 } // namespace leveldb
43 
44 int main(int argc, char** argv) {
46 }
void SetCompactPointer(int level, const InternalKey &key)
Definition: version_edit.h:55
void SetLogNumber(uint64_t num)
Definition: version_edit.h:39
void AddFile(int level, uint64_t file, uint64_t file_size, const InternalKey &smallest, const InternalKey &largest)
Definition: version_edit.h:62
int RunAllTests()
Definition: testharness.cc:36
void SetComparatorName(const Slice &name)
Definition: version_edit.h:35
#define ASSERT_EQ(a, b)
Definition: testharness.h:107
unsigned long long uint64_t
Definition: stdint.h:22
TEST(CorruptionTest, Recovery)
void SetLastSequence(SequenceNumber seq)
Definition: version_edit.h:51
#define ASSERT_TRUE(c)
Definition: testharness.h:105
void DeleteFile(int level, uint64_t file)
Definition: version_edit.h:75
void SetNextFile(uint64_t num)
Definition: version_edit.h:47
int main(int argc, char **argv)