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 
7 #include "port/stack_trace.h"
8 #include "test_util/testharness.h"
9 #include "test_util/testutil.h"
10 
11 #include "rocksdb/statistics.h"
12 
13 namespace ROCKSDB_NAMESPACE {
14 
15 class StatisticsTest : public testing::Test {};
16 
17 // Sanity check to make sure that contents and order of TickersNameMap
18 // match Tickers enum
TEST_F(StatisticsTest,SanityTickers)19 TEST_F(StatisticsTest, SanityTickers) {
20   EXPECT_EQ(static_cast<size_t>(Tickers::TICKER_ENUM_MAX),
21             TickersNameMap.size());
22 
23   for (uint32_t t = 0; t < Tickers::TICKER_ENUM_MAX; t++) {
24     auto pair = TickersNameMap[static_cast<size_t>(t)];
25     ASSERT_EQ(pair.first, t) << "Miss match at " << pair.second;
26   }
27 }
28 
29 // Sanity check to make sure that contents and order of HistogramsNameMap
30 // match Tickers enum
TEST_F(StatisticsTest,SanityHistograms)31 TEST_F(StatisticsTest, SanityHistograms) {
32   EXPECT_EQ(static_cast<size_t>(Histograms::HISTOGRAM_ENUM_MAX),
33             HistogramsNameMap.size());
34 
35   for (uint32_t h = 0; h < Histograms::HISTOGRAM_ENUM_MAX; h++) {
36     auto pair = HistogramsNameMap[static_cast<size_t>(h)];
37     ASSERT_EQ(pair.first, h) << "Miss match at " << pair.second;
38   }
39 }
40 
41 }  // namespace ROCKSDB_NAMESPACE
42 
main(int argc,char ** argv)43 int main(int argc, char** argv) {
44   ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
45   ::testing::InitGoogleTest(&argc, argv);
46   return RUN_ALL_TESTS();
47 }
48