Coverage Report

Created: 2021-11-25 09:31

/src/botan/src/lib/utils/assert.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
* Runtime assertion checking
3
* (C) 2010,2012,2018 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#include <botan/exceptn.h>
9
#include <sstream>
10
11
namespace Botan {
12
13
void throw_invalid_argument(const char* message,
14
                            const char* func,
15
                            const char* file)
16
1.31k
   {
17
1.31k
   std::ostringstream format;
18
1.31k
   format << message << " in " << func << ":" << file;
19
1.31k
   throw Invalid_Argument(format.str());
20
1.31k
   }
21
22
void throw_invalid_state(const char* expr,
23
                         const char* func,
24
                         const char* file)
25
0
   {
26
0
   std::ostringstream format;
27
0
   format << "Invalid state: " << expr << " was false in " << func << ":" << file;
28
0
   throw Invalid_State(format.str());
29
0
   }
30
31
void assertion_failure(const char* expr_str,
32
                       const char* assertion_made,
33
                       const char* func,
34
                       const char* file,
35
                       int line)
36
775
   {
37
775
   std::ostringstream format;
38
39
775
   format << "False assertion ";
40
41
775
   if(assertion_made && assertion_made[0] != 0)
42
751
      format << "'" << assertion_made << "' (expression " << expr_str << ") ";
43
24
   else
44
24
      format << expr_str << " ";
45
46
775
   if(func)
47
775
      format << "in " << func << " ";
48
49
775
   format << "@" << file << ":" << line;
50
51
775
   throw Internal_Error(format.str());
52
775
   }
53
54
}