TemplateCharReplace: fix failing testcase and add more

This fix the failing test and adds a couple more
tests.

Tested:
Test cases pass

Change-Id: I39435c7f938da007826682d17a670609ccc4704d
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 4662c2a..010a55a 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -174,7 +174,11 @@
             boost::ifind_first(*strPtr, templateName);
         if (find)
         {
+            constexpr const std::array<char, 5> mathChars = {'+', '-', '%', '*',
+                                                             '/'};
             size_t start = find.begin() - strPtr->begin();
+            size_t nextItemIdx = start + templateName.size() + 1;
+
             // check for additional operations
             if (!start && find.end() == strPtr->end())
             {
@@ -182,20 +186,22 @@
                            foundDevicePair.second);
                 return;
             }
-            else if (find.end() == strPtr->end())
+            else if (nextItemIdx > strPtr->size() ||
+                     std::find(mathChars.begin(), mathChars.end(),
+                               strPtr->at(nextItemIdx)) == mathChars.end())
             {
                 std::string val = std::visit(VariantToStringVisitor(),
                                              foundDevicePair.second);
                 boost::replace_all(*strPtr,
                                    templateChar + foundDevicePair.first, val);
-                return;
+                continue;
             }
 
             // save the prefix
             std::string prefix = strPtr->substr(0, start);
 
-            // operate on the rest (+1 for trailing space)
-            std::string end = strPtr->substr(start + templateName.size() + 1);
+            // operate on the rest
+            std::string end = strPtr->substr(nextItemIdx);
 
             std::vector<std::string> split;
             boost::split(split, end, boost::is_any_of(" "));