Parcourir la source

[2974] Added missing ServerHooks test

Added test for the getCount() method, and tidied up the documentation
for the ServerHooks class.
Stephen Morris il y a 12 ans
Parent
commit
63e17482bd
2 fichiers modifiés avec 19 ajouts et 4 suppressions
  1. 4 4
      src/lib/util/hooks/server_hooks.h
  2. 15 0
      src/lib/util/tests/server_hooks_unittest.cc

+ 4 - 4
src/lib/util/hooks/server_hooks.h

@@ -65,7 +65,7 @@ public:
     ///         fails in some way.
     ///         fails in some way.
     ServerHooks();
     ServerHooks();
 
 
-    /// @brief Register a Hook
+    /// @brief Register a hook
     ///
     ///
     /// Registers a hook and returns the hook index.
     /// Registers a hook and returns the hook index.
     ///
     ///
@@ -78,7 +78,7 @@ public:
     ///         registered.
     ///         registered.
     int registerHook(const std::string& name);
     int registerHook(const std::string& name);
 
 
-    /// @brief Get Hook Index
+    /// @brief Get hook index
     ///
     ///
     /// Returns the index of a hook.
     /// Returns the index of a hook.
     ///
     ///
@@ -88,7 +88,7 @@ public:
     ///         -1 is returned if no hook of the given name is found.
     ///         -1 is returned if no hook of the given name is found.
     int getIndex(const std::string& name) const;
     int getIndex(const std::string& name) const;
 
 
-    /// @brief Return Number of Hooks
+    /// @brief Return number of hooks
     ///
     ///
     /// Returns the total number of hooks registered.
     /// Returns the total number of hooks registered.
     ///
     ///
@@ -97,7 +97,7 @@ public:
         return (hooks_.size());
         return (hooks_.size());
     }
     }
 
 
-    /// @brief Hook Names
+    /// @brief Get hook names
     ///
     ///
     /// Return list of hooks registered in the object.
     /// Return list of hooks registered in the object.
     ///
     ///

+ 15 - 0
src/lib/util/tests/server_hooks_unittest.cc

@@ -94,4 +94,19 @@ TEST(ServerHooksTest, GetHookNames) {
     EXPECT_TRUE(expected_names == actual_names);
     EXPECT_TRUE(expected_names == actual_names);
 }
 }
 
 
+// Check that the count of hooks is correct.
+
+TEST(ServerHooksTest, HookCount) {
+    ServerHooks hooks;
+
+    // Insert the names into the hooks object
+    hooks.registerHook("alpha");
+    hooks.registerHook("betha");
+    hooks.registerHook("gamma");
+    hooks.registerHook("delta");
+
+    // Should be two more hooks that the number we have registered.
+    EXPECT_EQ(6, hooks.getCount());
+}
+
 } // Anonymous namespace
 } // Anonymous namespace