Chrysalis - Pattern Test Coverage


pattern/
File: pattern/include/AssociativeContainer.h
Date: 2026-08-27 18:35:18
Lines:
15/17
88.2%
Functions:
65/78
83.3%
Branches:
1/2
50.0%
Decisions:
0/0
-%
Calls:
48/56
85.7%

Line Branch Decision Call Exec Source
1 #ifndef CHRYSALIS_ASSOCIATIVECONTAINER_H
2 #define CHRYSALIS_ASSOCIATIVECONTAINER_H
3
4 #include <vector>
5
6 #include "serialization.h"
7
8 namespace Chrysalis {
9 template<typename T>
10 class AssociativeContainer {
11 PROVIDE_SERIALIZATION_ACCESS_T(AssociativeContainer)
12 public:
13
6/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
971 explicit AssociativeContainer() = default;
14
1/2
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
9/10
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✗ Call 11 not invoked.
204 explicit AssociativeContainer(std::initializer_list<T*> items): items_(items) {}
15
16
6/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
2606 virtual ~AssociativeContainer() = default;
17
18 96 virtual void add(T* item) {
19
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
96 items_.push_back(item);
20 96 }
21 6 size_t count() const {
22
6/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
6 return items_.size();
23 }
24 1573 std::vector<T*>::const_iterator begin() const {
25
6/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
1573 return items_.begin();
26 }
27 476 std::vector<T*>::const_iterator end() const {
28
6/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
476 return items_.end();
29 }
30 ✗ T* operator[](size_t index) const {
31
0/7
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ return items_[index];
32 }
33 private:
34 std::vector<T*> items_;
35 };
36 template <class Archive, typename T>
37 2600 void serialize(Archive& archive, AssociativeContainer<T>& obj, const unsigned int version)
38 {
39
5/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
2600 archive & obj.items_;
40 2600 }
41
42 template <class Archive, typename T>
43 void save_construct_data(Archive& archive, const AssociativeContainer<T>* obj, const unsigned int)
44 {
45 archive & obj->items_;
46 }
47
48 template <class Archive, typename T>
49 void load_construct_data(Archive& archive, AssociativeContainer<T>* obj, const unsigned int)
50 {
51 decltype(obj->items_) items_;
52 archive >> items_;
53 ::new(obj) AssociativeContainer<T>();
54 }
55 }
56
57 #endif //CHRYSALIS_ASSOCIATIVECONTAINER_H
58