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

randombit / botan / 13210394651

08 Feb 2025 12:33AM UTC coverage: 91.656% (-0.006%) from 91.662%
13210394651

push

github

web-flow
Merge pull request #4642 from randombit/jack/target-info-header

Add internal target_info.h header

94837 of 103471 relevant lines covered (91.66%)

11243945.63 hits per line

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

19.05
/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/exceptn.h>
11
#include <botan/internal/fmt.h>
12
#include <botan/internal/target_info.h>
13
#include <sstream>
14

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

20
namespace Botan {
21

22
void throw_invalid_argument(const char* message, const char* func, const char* file) {
5,832✔
23
   throw Invalid_Argument(fmt("{} in {}:{}", message, func, file));
11,664✔
24
}
25

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

30
void assertion_failure(const char* expr_str, const char* assertion_made, const char* func, const char* file, int line) {
×
31
   std::ostringstream format;
×
32

33
   format << "False assertion ";
×
34

35
   if(assertion_made && assertion_made[0] != 0) {
×
36
      format << "'" << assertion_made << "' (expression " << expr_str << ") ";
×
37
   } else {
38
      format << expr_str << " ";
×
39
   }
40

41
   if(func) {
×
42
      format << "in " << func << " ";
×
43
   }
44

45
   format << "@" << file << ":" << line;
×
46

47
#if defined(BOTAN_TERMINATE_ON_ASSERTS)
48
   std::cerr << format.str() << '\n';
×
49
   std::abort();
×
50
#else
51
   throw Internal_Error(format.str());
52
#endif
53
}
×
54

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

58
#if defined(BOTAN_TERMINATE_ON_ASSERTS)
59
   std::cerr << msg << '\n';
×
60
   std::abort();
×
61
#else
62
   throw Internal_Error(msg);
63
#endif
64
}
×
65

66
}  // 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