Coverage Report

Created: 2020-02-14 15:38

/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
4.60k
   {
17
4.60k
   std::ostringstream format;
18
4.60k
   format << message << " in " << func << ":" << file;
19
4.60k
   throw Invalid_Argument(format.str());
20
4.60k
   }
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
730
   {
37
730
   std::ostringstream format;
38
730
39
730
   format << "False assertion ";
40
730
41
730
   if(assertion_made && assertion_made[0] != 0)
42
706
      format << "'" << assertion_made << "' (expression " << expr_str << ") ";
43
24
   else
44
24
      format << expr_str << " ";
45
730
46
730
   if(func)
47
730
      format << "in " << func << " ";
48
730
49
730
   format << "@" << file << ":" << line;
50
730
51
730
   throw Internal_Error(format.str());
52
730
   }
53
54
}