clang-tidy: Enable bugprone-narrowing-conversions check

This check indicates instances where there's a potential loss of
data during type conversions, particularly when converting from
a wider type to a narrower type.

Change-Id: I43f3d9ff4a6d672f51c7b2d3eccca90f262fa852
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/test/utest.cpp b/test/utest.cpp
index d436179..8f400ff 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -19,6 +19,8 @@
 using namespace phosphor::software::manager;
 using namespace phosphor::software::image;
 
+namespace fs = std::filesystem;
+
 class VersionTest : public testing::Test
 {
   protected:
@@ -355,8 +357,13 @@
     std::string readFile(fs::path path)
     {
         std::ifstream f(path, std::ios::in);
-        const auto sz = fs::file_size(path);
-        std::string result(sz, '\0');
+        if (!f.is_open())
+        {
+            throw "Failed to open file";
+        }
+
+        auto sz = static_cast<std::streamsize>(fs::file_size(path));
+        std::string result(static_cast<size_t>(sz), '\0');
         f.read(result.data(), sz);
 
         return result;