@@ -17,6 +17,7 @@ class SlickLoggerTest : public ::testing::Test {
1717 std::filesystem::remove (" test_mixed.log" );
1818 std::filesystem::remove (" test_char_array.log" );
1919 std::filesystem::remove (" test_single_string.log" );
20+ std::filesystem::remove (" test_empty_string.log" );
2021 }
2122};
2223
@@ -347,6 +348,28 @@ TEST_F(SlickLoggerTest, CharArrayLogging) {
347348 EXPECT_TRUE (file_contents.find (" Log char array: test char array" ) != std::string::npos);
348349}
349350
351+ TEST_F (SlickLoggerTest, EmptyStringView) {
352+ std::filesystem::remove (" test_empty_string.log" );
353+
354+ slick::logger::Logger::instance ().init (" test_empty_string.log" , 8 );
355+
356+ std::string_view s;
357+
358+ LOG_INFO (" Log empty string: {}" , s);
359+
360+ slick::logger::Logger::instance ().shutdown ();
361+
362+ ASSERT_TRUE (std::filesystem::exists (" test_empty_string.log" ));
363+
364+ std::ifstream log_file (" test_empty_string.log" );
365+ std::string line;
366+ std::getline (log_file, line); // first line is the logger's version
367+ EXPECT_TRUE (std::getline (log_file, line));
368+ // Check valid formats work
369+ EXPECT_EQ (line.size (), 52 );
370+ EXPECT_EQ (line.find (" [INFO] Log empty string: " ), 26 );
371+ }
372+
350373int main (int argc, char **argv) {
351374 testing::InitGoogleTest (&argc, argv);
352375 return RUN_ALL_TESTS ();
0 commit comments