Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

50 строки
1.5 KiB

  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. #include "db/version_edit.h"
  5. #include "util/testharness.h"
  6. namespace leveldb {
  7. static void TestEncodeDecode(const VersionEdit& edit) {
  8. std::string encoded, encoded2;
  9. edit.EncodeTo(&encoded);
  10. VersionEdit parsed;
  11. Status s = parsed.DecodeFrom(encoded);
  12. ASSERT_TRUE(s.ok()) << s.ToString();
  13. parsed.EncodeTo(&encoded2);
  14. ASSERT_EQ(encoded, encoded2);
  15. }
  16. class VersionEditTest { };
  17. TEST(VersionEditTest, EncodeDecode) {
  18. static const uint64_t kBig = 1ull << 50;
  19. VersionEdit edit;
  20. for (int i = 0; i < 4; i++) {
  21. TestEncodeDecode(edit);
  22. edit.AddFile(3, kBig + 300 + i, kBig + 400 + i,
  23. InternalKey("foo", kBig + 500 + i, kTypeLargeValueRef),
  24. InternalKey("zoo", kBig + 600 + i, kTypeDeletion));
  25. edit.DeleteFile(4, kBig + 700 + i);
  26. edit.AddLargeValueRef(LargeValueRef::Make("big", kNoCompression),
  27. kBig + 800 + i, "foobar");
  28. edit.AddLargeValueRef(LargeValueRef::Make("big2", kSnappyCompression),
  29. kBig + 801 + i, "baz");
  30. edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue));
  31. }
  32. edit.SetComparatorName("foo");
  33. edit.SetLogNumber(kBig + 100);
  34. edit.SetNextFile(kBig + 200);
  35. edit.SetLastSequence(kBig + 1000);
  36. TestEncodeDecode(edit);
  37. }
  38. }
  39. int main(int argc, char** argv) {
  40. return leveldb::test::RunAllTests();
  41. }