M Starch cddf38bb6f
Make Os::Queues use Fw::MemAllocator pattern for memory (#4451)
* Queues use MemAllocator pattern

* Derive queue allocation from MallocRegistry

* Formatting

* Fix UTs

* Fix CI

* Fix alignment in UT

* Formatting and sp

* Formatting, bad header

* More formatting

* Add queue teardown

* Deinit components

* Fix priority queue test

* Fix bug in priority queue allocation

* Correct comments

* Fix FppTest and Ref UTs

* Fix max heap teardown

* Fix review comment on max heap

* Fix null -> nullptr
2025-12-02 17:36:15 -08:00

72 lines
3.2 KiB
C++

// ======================================================================
// \title BasicTestArrayTester.cpp
// \author bocchino
// \brief cpp file for BasicTestArrayTester component implementation class
// ======================================================================
#include <gtest/gtest.h>
#include "FppTest/state_machine/internal_instance/state/BasicTestArrayTester.hpp"
namespace FppTest {
namespace SmInstanceState {
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
BasicTestArrayTester::BasicTestArrayTester(const char* const compName)
: BasicTestArrayComponentBase(compName),
m_smStateBasicTestArray_action_a_history(),
m_smStateBasicTestArray_action_b_history() {}
BasicTestArrayTester::~BasicTestArrayTester() {
this->deinit();
}
// ----------------------------------------------------------------------
// Implementations for internal state machine actions
// ----------------------------------------------------------------------
void BasicTestArrayTester::FppTest_SmState_BasicTestArray_action_a(SmId smId,
FppTest_SmState_BasicTestArray::Signal signal) {
this->m_smStateBasicTestArray_action_a_history.push(signal);
}
void BasicTestArrayTester::FppTest_SmState_BasicTestArray_action_b(SmId smId,
FppTest_SmState_BasicTestArray::Signal signal,
const SmHarness::TestArray& value) {
this->m_smStateBasicTestArray_action_b_history.push(signal, value);
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void BasicTestArrayTester::test() {
this->m_smStateBasicTestArray_action_a_history.clear();
this->m_smStateBasicTestArray_action_b_history.clear();
this->init(queueDepth, instanceId);
ASSERT_EQ(this->smStateBasicTestArray_getState(), SmState_BasicTestArray::State::S);
ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getSize(), 0);
const SmHarness::TestArray value = SmHarness::Pick::testArray();
this->smStateBasicTestArray_sendSignal_s(value);
const auto status = this->doDispatch();
ASSERT_EQ(status, MSG_DISPATCH_OK);
ASSERT_EQ(this->smStateBasicTestArray_getState(), SmState_BasicTestArray::State::T);
const FwIndexType expectedASize = 5;
ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getSize(), expectedASize);
for (FwIndexType i = 0; i < expectedASize; i++) {
ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getItemAt(i), SmState_BasicTestArray::Signal::s);
}
ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getSize(), 1);
ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getSignals().getItemAt(0),
SmState_BasicTestArray::Signal::s);
ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getValues().getItemAt(0), value);
}
} // namespace SmInstanceState
} // namespace FppTest