AoC code coverage
Current view: top level - aoclib - StringUtils.cpp (source / functions) Coverage Total Hit
Test: master Lines: 100.0 % 13 13
Test Date: 2025-12-11 19:43:23 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #include "StringUtils.h"
       2              : #include "IntegerCast.h"
       3              : 
       4              : #include <libassert/assert.hpp>
       5              : 
       6              : #include <fstream>
       7              : 
       8        34884 : std::string readFileAsString(std::filesystem::path const &path) {
       9        34884 :   ASSERT(exists(path), "File not found!", path.string());
      10        34884 :   std::string result;
      11        34884 :   std::ifstream ifs(path);
      12        34884 :   ifs.seekg(0, std::ios::end);
      13        34884 :   std::size_t size = ifs.tellg();
      14        34884 :   ifs.seekg(0);
      15        34884 :   result.resize_and_overwrite(size, [&ifs](char *buffer, std::size_t size) {
      16        34884 :     ifs.read(buffer, integerCast<std::streamsize>(size));
      17        34884 :     return integerCast<std::size_t>(ifs.gcount());
      18        34884 :   });
      19        34884 :   return result;
      20        34884 : }
        

Generated by: LCOV version 2.0-1