LCOV - code coverage report
Current view: top level - src/Utility - PAssert.cpp (source / functions) Coverage Total Hit
Test: report.info Lines: 0.0 % 29 0
Test Date: 2025-05-21 10:57:37 Functions: 0.0 % 6 0
Branches: 0.0 % 26 0

             Branch data     Line data    Source code
       1                 :             : // -*- C++ -*-
       2                 :             : /***************************************************************************
       3                 :             :  *
       4                 :             :  * The IPPL Framework
       5                 :             :  *
       6                 :             :  * This program was prepared by PSI.
       7                 :             :  * All rights in the program are reserved by PSI.
       8                 :             :  * Neither PSI nor the author(s)
       9                 :             :  * makes any warranty, express or implied, or assumes any liability or
      10                 :             :  * responsibility for the use of this software
      11                 :             :  *
      12                 :             :  * Visit www.amas.web.psi for more details
      13                 :             :  *
      14                 :             :  ***************************************************************************/
      15                 :             : 
      16                 :             : // -*- C++ -*-
      17                 :             : /***************************************************************************
      18                 :             :  *
      19                 :             :  * The IPPL Framework
      20                 :             :  *
      21                 :             :  *
      22                 :             :  * Visit http://people.web.psi.ch/adelmann/ for more details
      23                 :             :  *
      24                 :             :  ***************************************************************************/
      25                 :             : 
      26                 :             : //---------------------------------------------------------------------------//
      27                 :             : // Assert.cpp
      28                 :             : // Geoffrey Furnish
      29                 :             : // Fri Jul 25 08:41:38 1997
      30                 :             : //---------------------------------------------------------------------------//
      31                 :             : // @> Helper functions for the Assert facility.
      32                 :             : //---------------------------------------------------------------------------//
      33                 :             : 
      34                 :             : // include files
      35                 :             : #include "Utility/PAssert.h"
      36                 :             : 
      37                 :             : #include <iostream>
      38                 :             : using namespace std;
      39                 :             : #include <cstdio>
      40                 :             : #include <cstdlib>
      41                 :             : #include <cstring>
      42                 :             : 
      43                 :             : //---------------------------------------------------------------------------//
      44                 :             : 
      45                 :           0 : assertion::assertion(const char* cond, const char* file, int line)
      46                 :           0 :     : std::runtime_error(cond) {
      47         [ #  # ]:           0 :     msg = new char[strlen(cond) + strlen(file) + 500];
      48                 :           0 :     sprintf(msg, "Assertion: %s, failed in %s, line %8d.", cond, file, line);
      49                 :           0 : }
      50                 :             : 
      51                 :           0 : assertion::assertion(const char* m)
      52                 :           0 :     : std::runtime_error(m) {
      53         [ #  # ]:           0 :     msg = new char[strlen(m) + 1];
      54                 :           0 :     strcpy(msg, m);
      55                 :           0 : }
      56                 :             : 
      57                 :           0 : assertion::assertion(const assertion& a)
      58                 :           0 :     : std::runtime_error(a.msg) {
      59         [ #  # ]:           0 :     msg = new char[strlen(a.msg) + 1];
      60                 :           0 :     strcpy(msg, a.msg);
      61                 :           0 : }
      62                 :             : 
      63                 :           0 : assertion& assertion::operator=(const assertion& a) {
      64                 :           0 :     msg = new char[strlen(a.msg) + 1];
      65                 :           0 :     strcpy(msg, a.msg);
      66                 :           0 :     return *this;
      67                 :             : }
      68                 :             : 
      69                 :             : //---------------------------------------------------------------------------//
      70                 :             : // Function to perform the task of actually throwing an assertion.
      71                 :             : //---------------------------------------------------------------------------//
      72                 :             : 
      73                 :           0 : void toss_cookies(const char* cond, const char* file, int line) {
      74   [ #  #  #  #  :           0 :     std::string what = "Assertion '" + std::string(cond) + "' failed. \n";
                   #  # ]
      75         [ #  # ]:           0 :     what += "in \n";
      76   [ #  #  #  #  :           0 :     what += std::string(file) + ", line  " + std::to_string(line);
             #  #  #  # ]
      77                 :             : 
      78         [ #  # ]:           0 :     throw std::runtime_error(what);
      79                 :           0 : }
      80                 :             : 
      81                 :             : //---------------------------------------------------------------------------//
      82                 :             : // Function to perform the task of actually throwing an isistion.
      83                 :             : //---------------------------------------------------------------------------//
      84                 :           0 : void insist(const char* cond, const char* msg, const char* file, int line) {
      85                 :           0 :     char* fullmsg = new char[strlen(cond) + strlen(msg) + strlen(file) + 500];
      86                 :           0 :     sprintf(fullmsg, "%s\nAssertion '%s' failed in \n%s on line %8d.", msg, cond, file, line);
      87                 :             : 
      88         [ #  # ]:           0 :     throw assertion(fullmsg);
      89                 :             : }
      90                 :             : 
      91                 :             : //---------------------------------------------------------------------------//
      92                 :             : //                              end of Assert.cpp
      93                 :             : //---------------------------------------------------------------------------//
      94                 :             : 
      95                 :             : /***************************************************************************
      96                 :             :  * $RCSfile: PAssert.cpp,v $   $Author: adelmann $
      97                 :             :  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:33 $
      98                 :             :  * IPPL_VERSION_ID: $Id: PAssert.cpp,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
      99                 :             :  ***************************************************************************/
        

Generated by: LCOV version 2.0-1