Add Unit Test for TemplateCharReplace
We keep finding issues in this function, add some tests.
Tested: The tests pass, this is mostly just moving the
code into a header. One test didn't work, but it didn't
work before either. It will be fixed later
Change-Id: I3eb60960104e861b0a0313580dc90bfb12051829
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/Utils.hpp b/include/Utils.hpp
index e57d146..7f8076c 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -15,6 +15,7 @@
*/
#pragma once
+
#include <boost/container/flat_map.hpp>
#include <filesystem>
#include <fstream>
@@ -27,6 +28,19 @@
constexpr const char* versionHashFile = "/var/configuration/version";
constexpr const char* versionFile = "/etc/os-release";
+using BasicVariantType =
+ std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
+ int16_t, uint16_t, uint8_t, bool>;
+
+enum class TemplateOperation
+{
+ addition,
+ division,
+ multiplication,
+ subtraction,
+ modulo,
+};
+
bool findFiles(const std::filesystem::path& dirPath,
const std::string& matchString,
std::vector<std::filesystem::path>& foundPaths);
@@ -94,4 +108,10 @@
std::ofstream output(versionHashFile);
output << expectedHash;
return false;
-}
\ No newline at end of file
+}
+
+void templateCharReplace(
+ nlohmann::json::iterator& keyPair,
+ const boost::container::flat_map<std::string, BasicVariantType>&
+ foundDevice,
+ const size_t foundDeviceIdx);