Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vvromanov committed Dec 8, 2024
1 parent e352043 commit 4f51c2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/HistoryCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ bool HistoryCountersClear() {
if (counters_suffix) {
STRNCAT(name, counters_suffix);
}
if (!remove_test_file(name)) {
return false;
}
return true;
return remove_test_file(name);
}

HistoryCounterData *HistoryCounters::GetCounterPtr(const char *name) {
Expand Down
18 changes: 16 additions & 2 deletions tests/TestHistoryCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ TEST_F(TestHistoryCounters, Open) {

TEST_F(TestHistoryCounters, GetIndex) {
EXPECT_TRUE(HistoryCountersClear());
EXPECT_EQ(0, GetHistoryCounters().GetCounterIndex(TEST_COUNTER ".c1"));
EXPECT_EQ(1, GetHistoryCounters().GetCounterIndex(TEST_COUNTER ".c2"));
for (int i = 0; i < COUNTER_MAX_AMOUNT_HISTORY; i++) {
char cn[100];
snprintf(cn, sizeof(cn), TEST_COUNTER ".%05d", i);
EXPECT_EQ(i, GetHistoryCounters().GetCounterIndex(cn));
}
EXPECT_EQ(DICTIONARY_INVALID_INDEX, GetHistoryCounters().GetCounterIndex("xxx"));
}

TEST_F(TestHistoryCounters, GetCounterPtr) {
EXPECT_TRUE(HistoryCountersClear());
for (int i = 0; i < COUNTER_MAX_AMOUNT_HISTORY; i++) {
char cn[100];
snprintf(cn, sizeof(cn), TEST_COUNTER ".%05d", i);
EXPECT_NE(nullptr, GetHistoryCounters().GetCounterPtr(cn));
}
EXPECT_EQ(nullptr, GetHistoryCounters().GetCounterPtr("xxx"));
}

static void FillTestData(ClockOverride& co, HistoryCounter& c1, HistoryCounter& c2, HistoryCounter& c3) {
Expand Down

0 comments on commit 4f51c2d

Please sign in to comment.