File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,6 +270,11 @@ TEST_F(LoggerTest, MultiThreadedLogging) {
270270
271271// Test 9: Error handling
272272TEST_F (LoggerTest, ErrorHandling) {
273+ // Redirect stderr to suppress warning messages during this test
274+ std::stringstream buffer;
275+ std::streambuf* old_stderr = std::cerr.rdbuf ();
276+ std::cerr.rdbuf (buffer.rdbuf ());
277+
273278 Logger::Config config;
274279 config.logFilePath = " /invalid/path/test.log" ; // Geçersiz path
275280 config.consoleOutput = true ;
@@ -279,6 +284,13 @@ TEST_F(LoggerTest, ErrorHandling) {
279284 Logger logger (config);
280285 logger.info (" Test message" );
281286 });
287+
288+ // Restore stderr
289+ std::cerr.rdbuf (old_stderr);
290+
291+ // Verify that warning was captured (optional verification)
292+ std::string captured = buffer.str ();
293+ EXPECT_TRUE (captured.find (" Warning: Could not create log file" ) != std::string::npos);
282294}
283295
284296// Test 10: Flush functionality (simplified)
You can’t perform that action at this time.
0 commit comments