statistics_test.cc 1.5 KB

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