GCC Code Coverage Report


Directory: ./
File: Utils/Hash/HashBufferCommon.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 14 33 42.4%
Functions: 5 9 55.6%
Branches: 3 9 33.3%

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