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.1 KiB
C++

// ======================================================================
// \title BasicTestEnumTester.cpp
// \author bocchino
// \brief cpp file for BasicTestEnumTester component implementation class
// ======================================================================
#include <gtest/gtest.h>
#include "FppTest/state_machine/internal_instance/state/BasicTestEnumTester.hpp"
namespace FppTest {
namespace SmInstanceState {
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
BasicTestEnumTester::BasicTestEnumTester(const char* const compName)
: BasicTestEnumComponentBase(compName),
m_smStateBasicTestEnum_action_a_history(),
m_smStateBasicTestEnum_action_b_history() {}
BasicTestEnumTester::~BasicTestEnumTester() {
this->deinit();
}
// ----------------------------------------------------------------------
// Implementations for internal state machine actions
// ----------------------------------------------------------------------
void BasicTestEnumTester::FppTest_SmState_BasicTestEnum_action_a(SmId smId,
FppTest_SmState_BasicTestEnum::Signal signal) {
this->m_smStateBasicTestEnum_action_a_history.push(signal);
}
void BasicTestEnumTester::FppTest_SmState_BasicTestEnum_action_b(SmId smId,
FppTest_SmState_BasicTestEnum::Signal signal,
const SmHarness::TestEnum& value) {
this->m_smStateBasicTestEnum_action_b_history.push(signal, value);
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void BasicTestEnumTester::test() {
this->m_smStateBasicTestEnum_action_a_history.clear();
this->m_smStateBasicTestEnum_action_b_history.clear();
this->init(queueDepth, instanceId);
ASSERT_EQ(this->smStateBasicTestEnum_getState(), SmState_BasicTestEnum::State::S);
ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getSize(), 0);
const SmHarness::TestEnum value = SmHarness::Pick::testEnum();
this->smStateBasicTestEnum_sendSignal_s(value);
const auto status = this->doDispatch();
ASSERT_EQ(status, MSG_DISPATCH_OK);
ASSERT_EQ(this->smStateBasicTestEnum_getState(), SmState_BasicTestEnum::State::T);
const FwIndexType expectedASize = 5;
ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getSize(), expectedASize);
for (FwIndexType i = 0; i < expectedASize; i++) {
ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getItemAt(i), SmState_BasicTestEnum::Signal::s);
}
ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getSize(), 1);
ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getSignals().getItemAt(0),
SmState_BasicTestEnum::Signal::s);
ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getValues().getItemAt(0), value);
}
} // namespace SmInstanceState
} // namespace FppTest