iostats_context_test.cc 1004 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #include "rocksdb/iostats_context.h"
  6. #include "test_util/testharness.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. TEST(IOStatsContextTest, ToString) {
  9. get_iostats_context()->Reset();
  10. get_iostats_context()->bytes_read = 12345;
  11. std::string zero_included = get_iostats_context()->ToString();
  12. ASSERT_NE(std::string::npos, zero_included.find("= 0"));
  13. ASSERT_NE(std::string::npos, zero_included.find("= 12345"));
  14. std::string zero_excluded = get_iostats_context()->ToString(true);
  15. ASSERT_EQ(std::string::npos, zero_excluded.find("= 0"));
  16. ASSERT_NE(std::string::npos, zero_excluded.find("= 12345"));
  17. }
  18. } // namespace ROCKSDB_NAMESPACE
  19. int main(int argc, char** argv) {
  20. ::testing::InitGoogleTest(&argc, argv);
  21. return RUN_ALL_TESTS();
  22. }