mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
PRIVATE -> private for Fw/Dp (#3753)
* PRIVATE -> private for Fw/Dp/DpContainer.hpp * Add newline to DpContainerTester.hpp * Update FPP Test to use DpContainerHelper; spelling fix; remove commented out code * Move DpContainerTester to Fw namespace; refactor DpContainer protected checks into DpContainerTester itself
This commit is contained in:
parent
9992e71dc4
commit
0ec96fbea7
@ -8,6 +8,7 @@
|
||||
|
||||
#include "FppTest/dp/DpTest.hpp"
|
||||
#include "Fw/Types/Assert.hpp"
|
||||
#include "Fw/Dp/test/ut/DpContainerTester.hpp"
|
||||
|
||||
namespace FppTest {
|
||||
|
||||
@ -251,11 +252,7 @@ void DpTest ::dpRecv_Container7_handler(DpContainer& container, Fw::Success::T s
|
||||
void DpTest::checkContainerEmpty(const DpContainer& container) const {
|
||||
const FwSizeType dataSize = container.getDataSize();
|
||||
FW_ASSERT(dataSize == 0, static_cast<FwAssertArgType>(dataSize));
|
||||
const Fw::SerializeBufferBase& buffer = container.m_dataBuffer;
|
||||
const FwSizeType buffLength = buffer.getBuffLength();
|
||||
FW_ASSERT(buffLength == 0, static_cast<FwAssertArgType>(buffLength));
|
||||
const FwSizeType buffLeft = buffer.getBuffLeft();
|
||||
FW_ASSERT(buffLeft == 0, static_cast<FwAssertArgType>(buffLeft));
|
||||
FW_ASSERT(Fw::DpContainerTester::isDataBufferEmpty(container));
|
||||
}
|
||||
|
||||
void DpTest::checkContainer(const DpContainer& container,
|
||||
|
||||
@ -15,10 +15,16 @@
|
||||
#include "config/FppConstantsAc.hpp"
|
||||
#include "config/ProcTypeEnumAc.hpp"
|
||||
|
||||
// Forward declare for UTs
|
||||
namespace Fw { class DpContainerTester; }
|
||||
|
||||
namespace Fw {
|
||||
|
||||
//! A data product Container
|
||||
class DpContainer {
|
||||
|
||||
friend class Fw::DpContainerTester;
|
||||
|
||||
public:
|
||||
// ----------------------------------------------------------------------
|
||||
// Constants and Types
|
||||
@ -234,7 +240,7 @@ class DpContainer {
|
||||
return Header::SIZE + dataSize + 2 * HASH_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
PRIVATE:
|
||||
private:
|
||||
// ----------------------------------------------------------------------
|
||||
// Private member functions
|
||||
// ----------------------------------------------------------------------
|
||||
@ -250,7 +256,7 @@ class DpContainer {
|
||||
//! The user data
|
||||
Header::UserData m_userData;
|
||||
|
||||
PROTECTED:
|
||||
protected:
|
||||
// ----------------------------------------------------------------------
|
||||
// Protected member variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
47
Fw/Dp/test/ut/DpContainerTester.hpp
Normal file
47
Fw/Dp/test/ut/DpContainerTester.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// ======================================================================
|
||||
// \title DpContainerTester.hpp
|
||||
// \author m-aleem
|
||||
// \brief hpp file for DpContainerTester
|
||||
// ======================================================================
|
||||
|
||||
#ifndef Fw_DpContainerTester_HPP
|
||||
#define Fw_DpContainerTester_HPP
|
||||
|
||||
#include "Fw/Dp/DpContainer.hpp"
|
||||
|
||||
namespace Fw {
|
||||
|
||||
class DpContainerTester {
|
||||
|
||||
public:
|
||||
|
||||
static bool verifyBufferSize(const Fw::DpContainer& container, FwSizeType expectedSize) {
|
||||
return container.m_buffer.getSize() == expectedSize;
|
||||
}
|
||||
|
||||
static U8* getBufferPointers(const Fw::DpContainer& container) {
|
||||
U8* const buffPtr = container.m_buffer.getData();
|
||||
return buffPtr;
|
||||
}
|
||||
|
||||
static bool verifyDataBufferAddress(const Fw::DpContainer& container, const U8* expectedAddr) {
|
||||
return container.m_dataBuffer.getBuffAddr() == expectedAddr;
|
||||
}
|
||||
|
||||
static bool verifyDataBufferCapacity(const Fw::DpContainer& container, FwSizeType expectedCapacity) {
|
||||
return container.m_dataBuffer.getBuffCapacity() == expectedCapacity;
|
||||
}
|
||||
|
||||
static bool isDataBufferEmpty(const Fw::DpContainer& container) {
|
||||
const Fw::SerializeBufferBase& buffer = container.m_dataBuffer;
|
||||
const FwSizeType buffLength = buffer.getBuffLength();
|
||||
const FwSizeType buffLeft = buffer.getBuffLeft();
|
||||
|
||||
return buffLength == 0 && buffLeft == 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -12,6 +12,7 @@
|
||||
#include "Fw/Test/UnitTest.hpp"
|
||||
#include "STest/Pick/Pick.hpp"
|
||||
#include "STest/Random/Random.hpp"
|
||||
#include "Fw/Dp/test/ut/DpContainerTester.hpp"
|
||||
|
||||
using namespace Fw;
|
||||
|
||||
@ -83,13 +84,13 @@ void checkHeader(FwDpIdType id, Fw::Buffer& buffer, DpContainer& container) {
|
||||
|
||||
void checkBuffers(DpContainer& container, FwSizeType bufferSize) {
|
||||
// Check the packet buffer
|
||||
ASSERT_EQ(container.m_buffer.getSize(), bufferSize);
|
||||
ASSERT_TRUE(Fw::DpContainerTester::verifyBufferSize(container, bufferSize));
|
||||
// Check the data buffer
|
||||
U8* const buffPtr = container.m_buffer.getData();
|
||||
U8* const buffPtr = Fw::DpContainerTester::getBufferPointers(container);
|
||||
U8* const dataPtr = &buffPtr[Fw::DpContainer::DATA_OFFSET];
|
||||
const FwSizeType dataCapacity = container.m_buffer.getSize() - Fw::DpContainer::MIN_PACKET_SIZE;
|
||||
ASSERT_EQ(container.m_dataBuffer.getBuffAddr(), dataPtr);
|
||||
ASSERT_EQ(container.m_dataBuffer.getBuffCapacity(), dataCapacity);
|
||||
const FwSizeType dataCapacity = bufferSize - Fw::DpContainer::MIN_PACKET_SIZE;
|
||||
ASSERT_TRUE(Fw::DpContainerTester::verifyDataBufferAddress(container, dataPtr));
|
||||
ASSERT_TRUE(Fw::DpContainerTester::verifyDataBufferCapacity(container, dataCapacity));
|
||||
}
|
||||
|
||||
void fillWithData(Fw::Buffer& buffer) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user