Browse Source

[3533] Minor changes as a result of review.

Comments have been improved in one file.  The other contains a test
that alters logging, so a test fixture has been added that ressets
the logging back to the default in its destructor.
Stephen Morris 10 years ago
parent
commit
a3bcf292f8

+ 23 - 3
src/lib/dhcpsrv/tests/daemon_unittest.cc

@@ -13,10 +13,13 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <config.h>
+
 #include <exceptions/exceptions.h>
+#include <cc/data.h>
 #include <dhcpsrv/daemon.h>
 #include <dhcpsrv/logging.h>
-#include <cc/data.h>
+#include <log/logger_unittest_support.h>
+
 #include <gtest/gtest.h>
 
 using namespace isc;
@@ -33,10 +36,27 @@ std::string isc::dhcp::Daemon::getVersion(bool extended) {
 
 namespace {
 
+/// @brief Daemon Test test fixture class
+class DaemonTest : public ::testing::Test {
+public:
+    /// @brief Constructor
+    DaemonTest() {
+    }
+
+    /// @brief Destructor
+    ///
+    /// As some of the tests have the side-effect of altering the logging
+    /// settings (when configureLogger is called), the logging is reset to
+    /// the default after each test completes.
+    ~DaemonTest() {
+        isc::log::resetUnitTestRootLogger();
+    }
+};
+
 
 // Very simple test. Checks whether Daemon can be instantiated and its
 // default parameters are sane
-TEST(DaemonTest, constructor) {
+TEST_F(DaemonTest, constructor) {
     EXPECT_NO_THROW(Daemon instance1);
 
     // Check that the verbose mode is not set by default.
@@ -47,7 +67,7 @@ TEST(DaemonTest, constructor) {
 // Checks that configureLogger method is behaving properly.
 // More dedicated tests are availablef for LogConfigParser class.
 // See logger_unittest.cc
-TEST(DaemonTest, parsingConsoleOutput) {
+TEST_F(DaemonTest, parsingConsoleOutput) {
 
     // Storage - parsed configuration will be stored here
     ConfigurationPtr storage(new Configuration());

+ 8 - 3
src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -14,13 +14,14 @@
 
 #include <config.h>
 
+#include <config/ccsession.h>
 #include <dhcpsrv/dbaccess_parser.h>
 #include <dhcpsrv/dhcp_parsers.h>
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <config/ccsession.h>
-#include <gtest/gtest.h>
 #include <log/logger_unittest_support.h>
 
+#include <gtest/gtest.h>
+
 #include <map>
 #include <string>
 
@@ -46,6 +47,10 @@ public:
     ///
     /// Just make sure that the lease database is closed after every test
     /// (the last in particular).
+    ///
+    /// As some of the tests have the side-effect of altering the logging
+    /// settings (when the parser's "build" method is called), ensure that
+    /// the logging is reset to the default after each test completes.
     ~DbAccessParserTest() {
         LeaseMgrFactory::destroy();
         isc::log::resetUnitTestRootLogger();