GCC Code Coverage Report


Directory: Utils/
File: Hash/HashBufferCommon.cpp
Date: 2026-09-23 21:15:08
Exec Total Coverage
Lines: 29 33 87.9%
Functions: 8 9 88.9%
Branches: 9 13 69.2%

Line Branch Exec Source
1 #include <Utils/Hash/HashBuffer.hpp>
2 #include <cstring>
3
4 #include <algorithm>
5
6 #include "Fw/Types/Serializable.hpp"
7
8 namespace Utils {
9
10 14 HashBuffer::HashBuffer() : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {}
11
12 1 HashBuffer::HashBuffer(const U8* args, FwSizeType size) : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {
13
1/1
✓ Branch 5 taken 1 times.
1 Fw::SerializeStatus stat = Fw::LinearBufferBase::setBuff(args, size);
14 1 FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
15 1 }
16
17 32 HashBuffer::~HashBuffer() = default;
18
19 1 HashBuffer::HashBuffer(const HashBuffer& other) : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {
20
2/2
✓ Branch 15 taken 1 times.
✓ Branch 20 taken 1 times.
1 Fw::SerializeStatus stat = Fw::LinearBufferBase::setBuff(other.m_bufferData, other.getSize());
21 1 FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
22 1 }
23
24 9 HashBuffer& HashBuffer::operator=(const HashBuffer& other) {
25
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (this == &other) {
26 ✗ return *this;
27 }
28
29 9 Fw::SerializeStatus stat = Fw::LinearBufferBase::setBuff(other.m_bufferData, other.getSize());
30 9 FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
31 9 return *this;
32 }
33
34 2 bool HashBuffer::operator==(const HashBuffer& other) const {
35
1/2
✗ Branch 22 not taken.
✓ Branch 23 taken 2 times.
2 if (this->getSize() != other.getSize()) {
36 ✗ return false;
37 }
38
2/4
✗ Branch 25 not taken.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2 times.
2 return memcmp(this->getBuffAddr(), other.getBuffAddr(), static_cast<size_t>(this->getSize())) == 0;
39 }
40
41 1 bool HashBuffer::operator!=(const HashBuffer& other) const {
42 1 return !(*this == other);
43 }
44
45 ✗ FwSizeType HashBuffer::getBuffCapacity() const {
46 ✗ return this->getCapacity();
47 }
48
49 1 U32 HashBuffer::asBigEndianU32() const {
50 1 U32 result = 0;
51 1 const FwSizeType bufferSize = sizeof this->m_bufferData;
52 1 const FwSizeType numBytes = std::min(bufferSize, static_cast<FwSizeType>(sizeof(U32)));
53
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (FwSizeType i = 0; i < numBytes; i++) {
54 4 result <<= 8;
55 4 FW_ASSERT(i < bufferSize, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(bufferSize));
56 4 result += this->m_bufferData[i];
57 }
58 1 return result;
59 }
60 } // namespace Utils
61