• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 21753596263

06 Feb 2026 02:13PM UTC coverage: 90.063% (-0.01%) from 90.073%
21753596263

Pull #5289

github

web-flow
Merge 587099284 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102237 of 113517 relevant lines covered (90.06%)

11402137.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.39
/src/lib/utils/assert.cpp
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/assert.h>
9

10
#include <botan/concepts.h>
11
#include <botan/exceptn.h>
12
#include <botan/internal/fmt.h>
13
#include <botan/internal/target_info.h>
14
#include <sstream>
15

16
#if defined(BOTAN_TERMINATE_ON_ASSERTS)
17
   #include <cstdlib>
18
   #include <iostream>
19
#endif
20

21
namespace Botan {
22

23
void throw_invalid_argument(const char* message, const char* func, const char* file) {
1,561✔
24
   throw Invalid_Argument(fmt("{} in {}:{}", message, func, file));
3,122✔
25
}
26

27
void throw_invalid_state(const char* expr, const char* func, const char* file) {
19,140✔
28
   throw Invalid_State(fmt("Invalid state: expr {} was false in {}:{}", expr, func, file));
19,140✔
29
}
30

31
// Declared in concepts.h
32
void ranges::memory_region_size_violation() {
×
33
   throw Invalid_Argument("Memory regions did not have expected byte lengths");
×
34
}
35

36
void assertion_failure(const char* expr_str, const char* assertion_made, const char* func, const char* file, int line) {
×
37
   std::ostringstream format;
×
38

39
   format << "False assertion ";
×
40

41
   if(assertion_made != nullptr && assertion_made[0] != 0) {
×
42
      format << "'" << assertion_made << "' (expression " << expr_str << ") ";
×
43
   } else {
44
      format << expr_str << " ";
×
45
   }
46

47
   if(func != nullptr) {
×
48
      format << "in " << func << " ";
×
49
   }
50

51
   format << "@" << file << ":" << line;
×
52

53
#if defined(BOTAN_TERMINATE_ON_ASSERTS)
54
   std::cerr << format.str() << '\n';
×
55
   std::abort();
×
56
#else
57
   throw Internal_Error(format.str());
58
#endif
59
}
×
60

61
void assert_unreachable(const char* file, int line) {
×
62
   const std::string msg = fmt("Codepath that was marked unreachable was reached @{}:{}", file, line);
×
63

64
#if defined(BOTAN_TERMINATE_ON_ASSERTS)
65
   std::cerr << msg << '\n';
×
66
   std::abort();
×
67
#else
68
   throw Internal_Error(msg);
69
#endif
70
}
×
71

72
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc