unit-test: Introduce unit tests to phosphor-objmgr
Move a function to make more testable and add a test case for it
Testing: Verified 100% test coverage in processing.cpp
Change-Id: I0a888009cfeb57bbc8ad295681bea00b79f2a23d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/src/processing.cpp b/src/processing.cpp
new file mode 100644
index 0000000..923e147
--- /dev/null
+++ b/src/processing.cpp
@@ -0,0 +1,23 @@
+#include "processing.hpp"
+
+#include <boost/algorithm/string/predicate.hpp>
+
+bool getWellKnown(
+ const boost::container::flat_map<std::string, std::string>& owners,
+ const std::string& request, std::string& wellKnown)
+{
+ // If it's already a well known name, just return
+ if (!boost::starts_with(request, ":"))
+ {
+ wellKnown = request;
+ return true;
+ }
+
+ auto it = owners.find(request);
+ if (it == owners.end())
+ {
+ return false;
+ }
+ wellKnown = it->second;
+ return true;
+}