Quinoa all test code coverage report
Current view: top level - UnitTest - QuietCerr.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 3 6 50.0 %
Date: 2024-04-29 14:59:56 Functions: 1 4 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/UnitTest/QuietCerr.cpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Charm++ nodegroup to quiet std::cerr in a thread-safe fashion
       9                 :            :   \details   Charm++ nodegroup to quiet std::cerr in a thread-safe fashion.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : 
      13                 :            : #include <iostream>
      14                 :            : #include <sstream>
      15                 :            : 
      16                 :            : #include "QuietCerr.hpp"
      17                 :            : 
      18                 :            : namespace tk {
      19                 :            : 
      20                 :            : #if defined(__clang__)
      21                 :            :   #pragma clang diagnostic push
      22                 :            :   #pragma clang diagnostic ignored "-Wmissing-variable-declarations"
      23                 :            : #endif
      24                 :            : 
      25                 :            : //! std::tringstream used to quiet std::cerr's stream by redirecting to it
      26                 :            : static std::stringstream cerr_quiet;
      27                 :            : //! std::streambuf used to store state of std::cerr before redirecting it
      28                 :            : static std::streambuf* cerr_old;
      29                 :            : 
      30                 :            : #if defined(__clang__)
      31                 :            :   #pragma clang diagnostic pop
      32                 :            : #endif
      33                 :            : 
      34                 :            : }
      35                 :            : 
      36                 :            : using tk::QuietCerr;
      37                 :            : 
      38                 :            : void
      39                 :         36 : QuietCerr::quiet()
      40                 :            : // *****************************************************************************
      41                 :            : //!   Section "Initializations at Program Startup" at in the Charm++ manual
      42                 :            : //!   http://charm.cs.illinois.edu/manuals/html/charm++/manual.html. Since it
      43                 :            : //!   is executed once every logical node, it is thread-safe.
      44                 :            : // *****************************************************************************
      45                 :            : {
      46                 :         36 :   tk::cerr_old = std::cerr.rdbuf( tk::cerr_quiet.rdbuf() );
      47                 :         36 : }
      48                 :            : 
      49                 :          0 : QuietCerr::~QuietCerr()
      50                 :            : // *****************************************************************************
      51                 :            : // Destructor: restore std::cerr's stream state
      52                 :            : // *****************************************************************************
      53                 :            : {
      54                 :          0 :   std::cerr.rdbuf( tk::cerr_old );
      55                 :          0 : }
      56                 :            : 
      57                 :            : #include "NoWarning/quietcerr.def.h"

Generated by: LCOV version 1.14