Test mapping of Histograms and HistogramsNameMap (#4720)
Summary: Adding sanity check test for mapping of `Histograms` and `HistogramsNameMap` ``` [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from StatisticsTest [ RUN ] StatisticsTest.SanityTickers [ OK ] StatisticsTest.SanityTickers (0 ms) [ RUN ] StatisticsTest.SanityHistograms [ OK ] StatisticsTest.SanityHistograms (0 ms) [----------] 2 tests from StatisticsTest (0 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (0 ms total) [ PASSED ] 2 tests. ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/4720 Differential Revision: D13217061 Pulled By: ajkr fbshipit-source-id: 6427f4e684c36b2f3c3440808b74fee86a364683
This commit is contained in:
parent
a2dec2ed08
commit
1db4a096d4
@ -414,7 +414,7 @@ enum Histograms : uint32_t {
|
||||
// Time spent flushing memtable to disk
|
||||
FLUSH_TIME,
|
||||
|
||||
HISTOGRAM_ENUM_MAX, // TODO(ldemailly): enforce HistogramsNameMap match
|
||||
HISTOGRAM_ENUM_MAX,
|
||||
};
|
||||
|
||||
extern const std::vector<std::pair<Histograms, std::string>> HistogramsNameMap;
|
||||
|
@ -16,7 +16,7 @@ class StatisticsTest : public testing::Test {};
|
||||
|
||||
// Sanity check to make sure that contents and order of TickersNameMap
|
||||
// match Tickers enum
|
||||
TEST_F(StatisticsTest, Sanity) {
|
||||
TEST_F(StatisticsTest, SanityTickers) {
|
||||
EXPECT_EQ(static_cast<size_t>(Tickers::TICKER_ENUM_MAX),
|
||||
TickersNameMap.size());
|
||||
|
||||
@ -26,6 +26,18 @@ TEST_F(StatisticsTest, Sanity) {
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity check to make sure that contents and order of HistogramsNameMap
|
||||
// match Tickers enum
|
||||
TEST_F(StatisticsTest, SanityHistograms) {
|
||||
EXPECT_EQ(static_cast<size_t>(Histograms::HISTOGRAM_ENUM_MAX),
|
||||
HistogramsNameMap.size());
|
||||
|
||||
for (uint32_t h = 0; h < Histograms::HISTOGRAM_ENUM_MAX; h++) {
|
||||
auto pair = HistogramsNameMap[static_cast<size_t>(h)];
|
||||
ASSERT_EQ(pair.first, h) << "Miss match at " << pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
Loading…
Reference in New Issue
Block a user