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