Skip to content

Commit

Permalink
Added unittests for timed logging with floating point periods
Browse files Browse the repository at this point in the history
  • Loading branch information
4c3y committed Apr 5, 2024
1 parent 6565686 commit 169bd7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/default/test_default_timed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ std::vector<AsyncTest> generateTests() {
};
}

TEST(default_timed, lpp_syntax_floating_point_time) {
for (int i = 0; i < 5; i++) {

std::string output = LPP_CAPTURE_STDOUT(LOG_TIMED(I, 0.1, "Test" << 123));
if (i % 2 == 0) {
ASSERT_TRUE(isSubstring(output, "I"));
ASSERT_TRUE(isSubstring(output, "Test123"));
}
//sleep 0.1s
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}

TEST(default_timed, lpp_syntax_severity_debug) {
ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
}
Expand Down
13 changes: 13 additions & 0 deletions test/glog/test_glog_timed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ std::vector<AsyncTest> generateTests() {
};
}

TEST(glog_timed, lpp_syntax_floating_point_time) {
for (int i = 0; i < 5; i++) {

std::string output = LPP_CAPTURE_STDOUT(LOG_TIMED(I, 0.1, "Test" << 123));
if (i % 2 == 0) {
ASSERT_TRUE(isSubstring(output, "I"));
ASSERT_TRUE(isSubstring(output, "Test123"));
}
//sleep 0.1s
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}

TEST(glog_timed, lpp_syntax_severity_debug) {
ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
}
Expand Down

0 comments on commit 169bd7e

Please sign in to comment.