| 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 | 4 | HashBuffer::HashBuffer() : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {} | |
| 11 | |||
| 12 | ✗ | HashBuffer::HashBuffer(const U8* args, FwSizeType size) : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) { | |
| 13 | ✗ | Fw::SerializeStatus stat = Fw::LinearBufferBase::setBuff(args, size); | |
| 14 | ✗ | FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat)); | |
| 15 | ✗ | } | |
| 16 | |||
| 17 | 8 | 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 | 2 | HashBuffer& HashBuffer::operator=(const HashBuffer& other) { | |
| 25 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (this == &other) { |
| 26 | ✗ | return *this; | |
| 27 | } | ||
| 28 | |||
| 29 | 2 | Fw::SerializeStatus stat = Fw::LinearBufferBase::setBuff(other.m_bufferData, other.getSize()); | |
| 30 | 2 | FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat)); | |
| 31 | 2 | return *this; | |
| 32 | } | ||
| 33 | |||
| 34 | 1 | bool HashBuffer::operator==(const HashBuffer& other) const { | |
| 35 |
1/2✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
|
1 | if (this->getSize() != other.getSize()) { |
| 36 | ✗ | return false; | |
| 37 | } | ||
| 38 |
2/4✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
|
1 | 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 | 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 |