dte test coverage


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 50.0% high: ≥ 85.0%
Coverage Exec / Excl / Total
Lines: 100.0% 11 / 0 / 11
Functions: 100.0% 3 / 0 / 3
Branches: 100.0% 6 / 0 / 6

src/util/intern.c
Line Branch Exec Source
1 #include "intern.h"
2 #include "hashset.h"
3
4 // NOLINTNEXTLINE(*-avoid-non-const-global-variables)
5 static HashSet interned_strings;
6
7 3454 const void *mem_intern(const void *data, size_t len)
8 {
9
2/2
✓ Branch 2 → 3 taken 11 times.
✓ Branch 2 → 4 taken 3443 times.
3454 if (unlikely(interned_strings.table_size == 0)) {
10 11 hashset_init(&interned_strings, 32, false);
11 }
12
13 3454 HashSetEntry *e = hashset_insert(&interned_strings, data, len);
14 3454 return e->str;
15 }
16
17 1027 bool mem_is_intern(const void *data, size_t len)
18 {
19 1027 const HashSetEntry *entry = hashset_get(&interned_strings, data, len);
20
4/4
✓ Branch 3 → 4 taken 1026 times.
✓ Branch 3 → 5 taken 1 time.
✓ Branch 4 → 5 taken 513 times.
✓ Branch 4 → 6 taken 513 times.
1027 return entry && entry->str == data;
21 }
22
23 11 void free_interned_strings(void)
24 {
25 11 hashset_free(&interned_strings);
26 11 }
27