diff options
| author | Daniel Burrows <dburrows@debian.org> | 2010-08-26 20:11:34 -0700 |
|---|---|---|
| committer | Daniel Burrows <dburrows@debian.org> | 2010-08-26 20:11:34 -0700 |
| commit | 4c5bb962542aff7b39db8d02e2b79aea616d8b98 (patch) | |
| tree | ad3b217fba79368716c672d5041e00885c234b3f /tests | |
| parent | 5452fe6683668e7503e05e7bc5cc668593922a2c (diff) | |
| download | aptitude-4c5bb962542aff7b39db8d02e2b79aea616d8b98.tar.gz | |
Fix the behavior of OFF_LEVEL in the logging code.
Setting a category to OFF was supposed to mean that nothing in that category
was logged. Instead, it logs everything, and logging a message at OFF disables
it (which is ... sort of useless).
Fixed the behavior, and the tests, to behave correctly. Setting a log category's
level to OFF suppresses all its messages now.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_logging.cc | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/test_logging.cc b/tests/test_logging.cc index b1add525..af4d506a 100644 --- a/tests/test_logging.cc +++ b/tests/test_logging.cc @@ -336,12 +336,12 @@ TEST_F(LoggingTest, testIsEnabledOff) EXPECT_EQ(OFF_LEVEL, root->getEffectiveLevel()); - EXPECT_TRUE( root->isEnabledFor(FATAL_LEVEL) ); - EXPECT_TRUE( root->isEnabledFor(ERROR_LEVEL) ); - EXPECT_TRUE( root->isEnabledFor(WARN_LEVEL) ); - EXPECT_TRUE( root->isEnabledFor(INFO_LEVEL) ); - EXPECT_TRUE( root->isEnabledFor(DEBUG_LEVEL) ); - EXPECT_TRUE( root->isEnabledFor(TRACE_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(FATAL_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(ERROR_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(WARN_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(INFO_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(DEBUG_LEVEL) ); + EXPECT_TRUE( !root->isEnabledFor(TRACE_LEVEL) ); EXPECT_TRUE( !root->isEnabledFor(OFF_LEVEL) ); } @@ -459,6 +459,24 @@ TEST_F(LoggingTest, testConnectMessageLoggedCanBeDisconnected) // that each test uses msg1 for a log that should get through, and // msg2 for a log that shouldn't. +TEST_F(LoggingTest, testOffMeansOff) +{ + LoggerPtr root = getLogger(""); + LoggingReceiver receiver; + + EXPECT_NO_LOGS(receiver); + + connect(receiver, root); + root->setLevel(OFF_LEVEL); + + LOG_TRACE(root, "trace"); + LOG_DEBUG(root, "debug"); + LOG_INFO(root, "info"); + LOG_WARN(root, "warn"); + LOG_ERROR(root, "error"); + LOG_FATAL(root, "fatal"); +} + TEST_F(LoggingTest, testLogTrace) { LoggerPtr root = getLogger(""); |
