LCOV - code coverage report
Current view: top level - src/utils - MooseUnitUtils.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 16 16 100.0 %
Date: 2026-05-29 20:35:17 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "MooseUnitUtils.h"
      11             : 
      12             : #include <random>
      13             : 
      14             : namespace Moose::UnitUtils
      15             : {
      16          14 : TempFile::TempFile() : _path(generatePath()) {}
      17             : 
      18          28 : TempFile::~TempFile()
      19             : {
      20          14 :   std::error_code ec;
      21          14 :   std::filesystem::remove(path(), ec);
      22          14 : }
      23             : 
      24             : std::filesystem::path
      25          14 : TempFile::generatePath()
      26             : {
      27          18 :   static const std::string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
      28          14 :   static thread_local std::mt19937 generator{std::random_device{}()};
      29          14 :   std::uniform_int_distribution<std::size_t> distribution(0, chars.size() - 1);
      30          14 :   std::string result;
      31          14 :   const std::size_t len = 10;
      32          14 :   result.reserve(len);
      33         154 :   for (std::size_t i = 0; i < len; ++i)
      34         140 :     result += chars[distribution(generator)];
      35          28 :   return std::filesystem::temp_directory_path() / std::filesystem::path("mooseunit." + result);
      36          14 : }
      37             : 
      38             : }

Generated by: LCOV version 1.14