Index: denali.pro.user =================================================================== diff -u -r741b1c70f851810f2c265cdd38dfa158b7ee0c37 -r911882aaf10ee02ef646013914a2ddd6225224ca --- denali.pro.user (.../denali.pro.user) (revision 741b1c70f851810f2c265cdd38dfa158b7ee0c37) +++ denali.pro.user (.../denali.pro.user) (revision 911882aaf10ee02ef646013914a2ddd6225224ca) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/AlarmGenerator.cpp =================================================================== diff -u -r4d322070769e54c059b020f18215dca88c90acd7 -r911882aaf10ee02ef646013914a2ddd6225224ca --- sources/AlarmGenerator.cpp (.../AlarmGenerator.cpp) (revision 4d322070769e54c059b020f18215dca88c90acd7) +++ sources/AlarmGenerator.cpp (.../AlarmGenerator.cpp) (revision 911882aaf10ee02ef646013914a2ddd6225224ca) @@ -37,7 +37,7 @@ * \note vBits list template(quint16) depends on the Alarm_State_Flag_Bit_Positions length. * quint16 is currently used to cover 256 Alarm ID ( but I guess it should be S32 regarding ti RM46 arch unless has been defined otherwise) */ -QBitArray AlarmGenerator::setBits(QList vBits) +QBitArray AlarmGenerator::setBits(TBits vBits) { QBitArray mFlags = QBitArray(_len,false); // Initialize the QBitArray of false for (auto i: vBits) { Index: sources/AlarmGenerator.h =================================================================== diff -u -r19092150c9343b729ad87be76805300417bfd68c -r911882aaf10ee02ef646013914a2ddd6225224ca --- sources/AlarmGenerator.h (.../AlarmGenerator.h) (revision 19092150c9343b729ad87be76805300417bfd68c) +++ sources/AlarmGenerator.h (.../AlarmGenerator.h) (revision 911882aaf10ee02ef646013914a2ddd6225224ca) @@ -21,26 +21,33 @@ // Project #include "MAlarmStatusData.h" +// forward declarations +class tst_messaging; + /*! * \brief The AlarmGenerator class * \details This class is a helper class for the UI generated Alarms */ class AlarmGenerator { + // friends + friend class ::tst_messaging; + // typedef /*! \brief quint16 depends on the Alarm_State_Flag_Bit_Positions length. * quint16 is currently used to cover 256 Alarm ID * ( but I guess it should be S32 regarding ti RM46 arch * unless has been defined otherwise and since we started from 0 (signed not used) * then quint16 would be enough) */ - typedef quint16 TAlarms; + typedef quint16 TAlarms ; + typedef QList TBits ; // member variables static const quint8 _len = Gui::GuiAlarmFlags::NUM_OF_ALARM_STATE_FLAG_BIT_POS; // member functions - static QBitArray setBits(QList vBits); + static QBitArray setBits(TBits vBits); public: AlarmGenerator() {} @@ -52,4 +59,3 @@ static const AlarmStatusData ALARM_ID_HD_COMM_TIMEOUT(); static const AlarmStatusData ALARM_ID_BLE_CUFF (); // not implemented (PRS 395) }; - Index: unittests/tst_messaging.cpp =================================================================== diff -u -r0d3114203575d6725576f8bdc8299ad772d55fd5 -r911882aaf10ee02ef646013914a2ddd6225224ca --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 0d3114203575d6725576f8bdc8299ad772d55fd5) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 911882aaf10ee02ef646013914a2ddd6225224ca) @@ -22,6 +22,7 @@ #include "MessageBuilder.h" #include "MPowerOff.h" #include "MessageDispatcher.h" +#include "AlarmGenerator.h" tst_messaging::tst_messaging(QObject *parent) : QObject(parent) { } @@ -716,3 +717,19 @@ Can::Sequence seq = 1; dMsg.actionTransmit(Gui::GuiActionType::ID_KeepAlive, data, seq); } + +/*! + * \brief tst_messaging::tst_AlarmGenerator_setBits_OutOfRange + * \details Tests the longer list of the bits sent to AlarmGenerator::setBits method. + */ +void tst_messaging::tst_AlarmGenerator_setBits_OutOfRange() +{ + quint8 len = sizeof(AlarmGenerator::TAlarms) * 8; + AlarmGenerator ag; + AlarmGenerator::TBits bits {0, 15, len}; // 16 is out of range + QBitArray ba_actual = ag.setBits(bits); + QBitArray ba_expected(len,false); + ba_expected.setBit(0); + ba_expected.setBit(15); + QCOMPARE(ba_actual, ba_expected); +} Index: unittests/tst_messaging.h =================================================================== diff -u -r0d3114203575d6725576f8bdc8299ad772d55fd5 -r911882aaf10ee02ef646013914a2ddd6225224ca --- unittests/tst_messaging.h (.../tst_messaging.h) (revision 0d3114203575d6725576f8bdc8299ad772d55fd5) +++ unittests/tst_messaging.h (.../tst_messaging.h) (revision 911882aaf10ee02ef646013914a2ddd6225224ca) @@ -94,4 +94,6 @@ void tst_MessageDispatcher_actionTransmit(); void tst_MessageDispatcher_actionTransmit_Unknown(); + + void tst_AlarmGenerator_setBits_OutOfRange(); };