text: 
  //此源码被清华学神尹成大魔王专业翻译分析并修改
  //尹成QQ77025077
  //尹成微信18510341407
  //尹成所在QQ群721929980
  //尹成邮箱 yinc13@mails.tsinghua.edu.cn
  //尹成毕业于清华大学,微软区块链领域全球最有价值专家
  //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
  //版权所有（c）2011 LevelDB作者。版权所有。
  //此源代码的使用受可以
  //在许可证文件中找到。有关参与者的名称，请参阅作者文件。
  
  #include "env/mock_env.h"
  
  #include <memory>
  #include <string>
  
  #include "rocksdb/env.h"
  #include "util/testharness.h"
  
  namespace rocksdb {
  
  class MockEnvTest : public testing::Test {
   public:
    MockEnv* env_;
    const EnvOptions soptions_;
  
    MockEnvTest()
        : env_(new MockEnv(Env::Default())) {
    }
    ~MockEnvTest() {
      delete env_;
    }
  };
  
  TEST_F(MockEnvTest, Corrupt) {
    const std::string kGood = "this is a good string, synced to disk";
    const std::string kCorrupted = "this part may be corrupted";
    const std::string kFileName = "/dir/f";
    unique_ptr<WritableFile> writable_file;
    ASSERT_OK(env_->NewWritableFile(kFileName, &writable_file, soptions_));
    ASSERT_OK(writable_file->Append(kGood));
    ASSERT_TRUE(writable_file->GetFileSize() == kGood.size());
  
    std::string scratch;
    scratch.resize(kGood.size() + kCorrupted.size() + 16);
    Slice result;
    unique_ptr<RandomAccessFile> rand_file;
    ASSERT_OK(env_->NewRandomAccessFile(kFileName, &rand_file, soptions_));
    ASSERT_OK(rand_file->Read(0, kGood.size(), &result, &(scratch[0])));
    ASSERT_EQ(result.compare(kGood), 0);
  
  //同步+损坏=>无更改
    ASSERT_OK(writable_file->Fsync());
    ASSERT_OK(dynamic_cast<MockEnv*>(env_)->CorruptBuffer(kFileName));
    result.clear();
    ASSERT_OK(rand_file->Read(0, kGood.size(), &result, &(scratch[0])));
    ASSERT_EQ(result.compare(kGood), 0);
  
  //添加新数据并损坏它
    ASSERT_OK(writable_file->Append(kCorrupted));
    ASSERT_TRUE(writable_file->GetFileSize() == kGood.size() + kCorrupted.size());
    result.clear();
    ASSERT_OK(rand_file->Read(kGood.size(), kCorrupted.size(),
              &result, &(scratch[0])));
    ASSERT_EQ(result.compare(kCorrupted), 0);
  //腐败的
    ASSERT_OK(dynamic_cast<MockEnv*>(env_)->CorruptBuffer(kFileName));
    result.clear();
    ASSERT_OK(rand_file->Read(kGood.size(), kCorrupted.size(),
              &result, &(scratch[0])));
    ASSERT_NE(result.compare(kCorrupted), 0);
  }
  
  TEST_F(MockEnvTest, FakeSleeping) {
    int64_t now = 0;
    auto s = env_->GetCurrentTime(&now);
    ASSERT_OK(s);
    env_->FakeSleepForMicroseconds(3 * 1000 * 1000);
    int64_t after_sleep = 0;
    s = env_->GetCurrentTime(&after_sleep);
    ASSERT_OK(s);
    auto delta = after_sleep - now;
  //除非测试运行2秒，否则为真。
    ASSERT_TRUE(delta == 3 || delta == 4);
  }
  
  }  //命名空间rocksdb
  
  int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
  }
  