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
6 #include "rocksdb/iostats_context.h"
7 #include "test_util/testharness.h"
8
9 namespace ROCKSDB_NAMESPACE {
10
TEST(IOStatsContextTest,ToString)11 TEST(IOStatsContextTest, ToString) {
12 get_iostats_context()->Reset();
13 get_iostats_context()->bytes_read = 12345;
14
15 std::string zero_included = get_iostats_context()->ToString();
16 ASSERT_NE(std::string::npos, zero_included.find("= 0"));
17 ASSERT_NE(std::string::npos, zero_included.find("= 12345"));
18
19 std::string zero_excluded = get_iostats_context()->ToString(true);
20 ASSERT_EQ(std::string::npos, zero_excluded.find("= 0"));
21 ASSERT_NE(std::string::npos, zero_excluded.find("= 12345"));
22 }
23
24 } // namespace ROCKSDB_NAMESPACE
25
main(int argc,char ** argv)26 int main(int argc, char** argv) {
27 ::testing::InitGoogleTest(&argc, argv);
28 return RUN_ALL_TESTS();
29 }
30