Skip to content

Commit b09408c

Browse files
Extend Logs tests caused by formatting changes
Codecov prefers to have patch config to be not lower than the rest of repository. The file has not been formatted properly before so there are changes not related to the censoring Relates-To: NLAM-140 Signed-off-by: Rustam Gamidov <[email protected]>
1 parent ee43740 commit b09408c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

olp-cpp-sdk-core/tests/logging/LogTest.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ TEST(LogTest, Levels) {
4343
EXPECT_TRUE(olp::logging::Log::isEnabled(olp::logging::Level::Info));
4444
EXPECT_FALSE(olp::logging::Log::isEnabled(olp::logging::Level::Debug));
4545

46-
olp::logging::Log::setLevel(olp::logging::Level::Debug, "test1");
46+
olp::logging::Log::setLevel("Debug", "test1");
4747
olp::logging::Log::setLevel(olp::logging::Level::Warning, "test2");
48+
olp::logging::Log::setLevel("WrongLevel", "test1");
4849

4950
EXPECT_EQ(olp::logging::Level::Debug, olp::logging::Log::getLevel("test1"));
5051
EXPECT_EQ(olp::logging::Level::Warning, olp::logging::Log::getLevel("test2"));
@@ -73,6 +74,14 @@ TEST(LogTest, Levels) {
7374
EXPECT_FALSE(
7475
olp::logging::Log::isEnabled(olp::logging::Level::Debug, "test2"));
7576

77+
olp::logging::Log::clearLevel("");
78+
EXPECT_EQ(olp::logging::Level::Debug, olp::logging::Log::getLevel("test1"));
79+
EXPECT_EQ(olp::porting::none, olp::logging::Log::getLevel("test2"));
80+
EXPECT_TRUE(
81+
olp::logging::Log::isEnabled(olp::logging::Level::Warning, "test2"));
82+
EXPECT_FALSE(
83+
olp::logging::Log::isEnabled(olp::logging::Level::Debug, "test2"));
84+
7685
olp::logging::Log::clearLevels();
7786
EXPECT_EQ(olp::porting::none, olp::logging::Log::getLevel("test1"));
7887
EXPECT_EQ(olp::porting::none, olp::logging::Log::getLevel("test2"));
@@ -664,6 +673,22 @@ TEST(LogTest, LogLevelOff) {
664673
++index;
665674
}
666675

676+
TEST(LogTest, IsEnabled_ReturnsFalse_WhenLogLevelOff_) {
677+
auto appender = std::make_shared<testing::MockAppender>();
678+
olp::logging::Configuration configuration;
679+
configuration.addAppender(appender);
680+
EXPECT_TRUE(olp::logging::Log::configure(configuration));
681+
682+
EXPECT_FALSE(olp::logging::Log::isEnabled(olp::logging::Level::Off));
683+
olp::logging::Log::setLevel(olp::logging::Level::Off);
684+
EXPECT_FALSE(olp::logging::Log::isEnabled(olp::logging::Level::Off));
685+
686+
constexpr auto tag = "random tag";
687+
EXPECT_FALSE(olp::logging::Log::isEnabled(olp::logging::Level::Off, tag));
688+
olp::logging::Log::setLevel(olp::logging::Level::Off, tag);
689+
EXPECT_FALSE(olp::logging::Log::isEnabled(olp::logging::Level::Off, tag));
690+
}
691+
667692
TEST(LogTest, ReConfigure) {
668693
auto appender1 = std::make_shared<testing::MockAppender>();
669694
auto appender2 = std::make_shared<testing::MockAppender>();

0 commit comments

Comments
 (0)