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

randombit / botan / 5123321399

30 May 2023 04:06PM UTC coverage: 92.213% (+0.004%) from 92.209%
5123321399

Pull #3558

github

web-flow
Merge dd72f7389 into 057bcbc35
Pull Request #3558: Add braces around all if/else statements

75602 of 81986 relevant lines covered (92.21%)

11859779.3 hits per line

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

75.56
/src/lib/asn1/oid_map.cpp
1
/*
2
* (C) 2023 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include <botan/internal/oid_map.h>
8

9
namespace Botan {
10

11
OID_Map::OID_Map() {
1,918✔
12
   m_str2oid = OID_Map::load_str2oid_map();
1,918✔
13
   m_oid2str = OID_Map::load_oid2str_map();
1,918✔
14
}
1,918✔
15

16
OID_Map& OID_Map::global_registry() {
91,100✔
17
   static OID_Map g_map;
91,100✔
18
   return g_map;
91,100✔
19
}
20

21
void OID_Map::add_oid(const OID& oid, std::string_view str) {
6✔
22
   const std::string oid_str = oid.to_string();
6✔
23

24
   lock_guard_type<mutex_type> lock(m_mutex);
6✔
25

26
   auto o2s = m_oid2str.find(oid_str);
6✔
27

28
   if(o2s == m_oid2str.end()) {
6✔
29
      m_oid2str.insert(std::make_pair(oid_str, str));
4✔
30
   } else if(o2s->second != str) {
3✔
31
      throw Invalid_State("Cannot register two different names to a single OID");
1✔
32
   }
33

34
   auto s2o = m_str2oid.find(std::string(str));
10✔
35

36
   if(s2o == m_str2oid.end()) {
5✔
37
      m_str2oid.insert(std::make_pair(str, oid));
7✔
38
   }
39
}
10✔
40

41
void OID_Map::add_str2oid(const OID& oid, std::string_view str) {
×
42
   lock_guard_type<mutex_type> lock(m_mutex);
×
43
   if(!m_str2oid.contains(std::string(str))) {
×
44
      m_str2oid.insert(std::make_pair(str, oid));
×
45
   }
46
}
×
47

48
void OID_Map::add_oid2str(const OID& oid, std::string_view str) {
×
49
   const std::string oid_str = oid.to_string();
×
50
   lock_guard_type<mutex_type> lock(m_mutex);
×
51
   if(!m_oid2str.contains(oid_str)) {
×
52
      m_oid2str.insert(std::make_pair(oid_str, str));
×
53
   }
54
}
×
55

56
std::string OID_Map::oid2str(const OID& oid) {
44,133✔
57
   const std::string oid_str = oid.to_string();
44,133✔
58

59
   lock_guard_type<mutex_type> lock(m_mutex);
44,133✔
60

61
   auto i = m_oid2str.find(oid_str);
44,133✔
62
   if(i != m_oid2str.end()) {
44,133✔
63
      return i->second;
85,539✔
64
   }
65

66
   return "";
2,727✔
67
}
83,321✔
68

69
OID OID_Map::str2oid(std::string_view str) {
46,961✔
70
   lock_guard_type<mutex_type> lock(m_mutex);
46,961✔
71
   auto i = m_str2oid.find(std::string(str));
93,922✔
72
   if(i != m_str2oid.end()) {
46,961✔
73
      return i->second;
46,764✔
74
   }
75

76
   return OID();
46,961✔
77
}
46,961✔
78

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