Chrysalis - Hooks Test Coverage


integrations/hooks/
File: integrations/hooks/src/HooksManager.cpp
Date: 2026-08-27 18:35:56
Lines:
15/16
93.8%
Functions:
2/2
100.0%
Branches:
15/38
39.5%
Decisions:
2/6
33.3%
Calls:
49/62
79.0%

Line Branch Decision Call Exec Source
1 #include "HooksManager.h"
2
3 23 void HooksManager::remove(void* address) {
4
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
23 const auto it = _hooks.find(address);
5
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 23 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 23 times.
5/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
23 if (it == _hooks.end()) return;
6
3/3
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
23 const auto *hook = it->second;
7
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
1/1
✓ Call 0 invoked.
23 _hooks.erase(it);
8
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
7/7
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
23 delete hook; // ~Hook() → unHook() then ~HookBase()
9 }
10
11 24 std::string HooksManager::getName(void* address) {
12
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
24 const auto it = _hooks.find(address);
13
1/4
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
0/1
? Decision couldn't be analyzed.
5/9
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
24 if (it == _hooks.end()) return "<unknown>";
14
15
2/4
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
✓ Branch 16 taken 24 times.
✗ Branch 17 not taken.
14/16
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✗ Call 10 not invoked.
✓ Call 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
✓ Call 14 invoked.
✓ Call 15 invoked.
✓ Call 18 invoked.
✗ Call 19 not invoked.
72 std::string raw = typeid(*it->second).name();
16
17 // The template instantiation string contains the original function
18 // signature — extract the last "Namespace::Method(" token from it.
19
4/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4/5
✓ Call 2 invoked.
✓ Call 5 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✗ Call 12 not invoked.
24 static const std::regex re(R"(<[^>]*?(\w+::\w+)\()");
20
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
24 std::smatch match;
21
3/8
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 24 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 24 times.
1/2
✓ Call 0 invoked.
✗ Call 5 not invoked.
24 if (std::regex_search(raw, match, re) && match.size() > 1)
22
0/3
✗ Call 0 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ return match[1].str();
23
1/1
✓ Call 0 invoked.
24 return raw;
24
2/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
24 }
25