GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 10 / 0 / 10
Functions: 100.0% 3 / 0 / 3
Branches: 62.5% 10 / 0 / 16

storage/cache/cache_factory.h
Line Branch Exec Source
1 #pragma once
2
3 #include <algorithm>
4 #include <cctype>
5 #include <memory>
6 #include <stdexcept>
7 #include <string>
8
9 #include "storage/cache/lru/lru_cache.h"
10
11 namespace storage {
12 namespace cache {
13
14 4 inline std::string ToUpper(std::string s) {
15 4 std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
16 14 return static_cast<char>(std::toupper(c));
17 });
18 4 return s;
19 }
20
21 template <typename Key>
22 inline std::unique_ptr<CachePolicy<Key>>
23 4 CreateCachePolicy(const std::string& cache_policy, size_t capacity) {
24
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 const std::string policy = ToUpper(cache_policy);
25
5/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 2 times.
4 if (policy.empty() || policy == "LRU") {
26
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 return std::make_unique<LRUCachePolicy<Key>>(capacity);
27 }
28
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 throw std::invalid_argument("unsupported cache_policy: " + cache_policy);
29 4 }
30
31 } // namespace cache
32 } // namespace storage
33