Mishaal 9211a047e8
Updates for FPPTest corresponding to UT cmake update for protected/private (#3810)
* Updates for FppTest/dp and FppTest/component corresponding to UT cmake update for protected/private

* Refactor Fpp/state_machine/internal_instance/state teststo be in their own Tester classes

* Standardize headers

* Remove old ifndef from BasicGuardTester.hpp

* More cleanup of BasicGuardTester

* Remove extra /dp files (leftover from rename) and fix a header comment typo

* Revert accidentally checked in cmake

* Enable UT_AUTO_HELPERS for FppTest/dp

* Revert FppTest/state_machine/internal_instance/state

* Update state_machine/internal_instance/state/ component names to append Tester

* pdate state_machine/internal_instance/choice/ component names

* Update state_machine/internal_instance/initial/ component names

* Reformat code

---------

Co-authored-by: Rob Bocchino <bocchino@jpl.nasa.gov>
2025-07-18 09:36:46 -07:00

70 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() {}
// ----------------------------------------------------------------------
// 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