Index: denali.pro =================================================================== diff -u --- denali.pro (revision 0) +++ denali.pro (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1 @@ +../application/denali.pro \ No newline at end of file Index: resources =================================================================== diff -u --- resources (revision 0) +++ resources (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1 @@ +../application/resources \ No newline at end of file Index: sources =================================================================== diff -u --- sources (revision 0) +++ sources (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1 @@ +../application/sources \ No newline at end of file Index: unittests/tst_acknow.cpp =================================================================== diff -u --- unittests/tst_acknow.cpp (revision 0) +++ unittests/tst_acknow.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,201 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_acknow.cpp + * \author (last) Behrouz NematiPour + * \date (last) 10-Aug-2021 + * \author (original) Behrouz NematiPour + * \date (original) 21-Jan-2020 + * + */ +#include "tst_acknow.h" + +// Project +#include "CanInterface.h" +#include "FrameInterface.h" +#include "MessageAcknowModel.h" + +#define DEBUG_ACKBACK_HD_TO_UI + +using namespace Can; + +tst_acknow::tst_acknow(QObject *parent) { + Q_UNUSED(parent) +} + +/*! + * \brief tst_acknow::init + * \details this method should only initialize the can interfaces and is not for test + * bus needs to pass the initialization. + */ +void tst_acknow::init() +{ + _emited = false; + _Logger.init(); + _CanInterface.init(); + _CanInterface.enableConsoleOut(true); + QString mTr = tr("Connected"); + QCOMPARE(_CanInterface.status().left(mTr.length()), mTr); + + _CanInterface.onFrameReceive (); + + _FrameInterface .init(); + _MessageDispatcher .init(); + _MessageDispatcher .enableConsoleOut(true); + + connect(&_MessageDispatcher , SIGNAL(didFrameTransmit(Can_Id , const QByteArray &)), + this , SLOT( onFrameTransmit(Can_Id , const QByteArray &))); + connect(&_MessageDispatcher , SIGNAL(didActionReceive(GuiActionType , const QVariantList &)), + this , SLOT( onActionReceive(GuiActionType , const QVariantList &))); + + connect(&_MessageAcknowModel, SIGNAL(didFramesTransmit(Can_Id, Sequence, const FrameList &)), + this , SLOT( onFramesTransmit(Can_Id, Sequence, const FrameList &))); + connect(&_MessageAcknowModel, SIGNAL(didFailedTransmit(Sequence)), + this , SLOT( onFailedTransmit(Sequence))); + +} + +void tst_acknow::tst_AcknowModel_Init() +{ + QVERIFY( _MessageAcknowModel.init() ); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_Receive_Normal + * \details UI receives a message which does not require Acknow + */ +void tst_acknow::tst_AcknowModel_Receive_Normal() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.01.00.01.00.01.00.38"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY(_emited); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_Receive_Acknow + * \details UI receives a message which requires Acknow + * UI should send the Ack Back + */ +void tst_acknow::tst_AcknowModel_Receive_Acknow() +{ + _expected = "A5.01.00.FF.FF.00.19.00"; + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.FF.FF.01.00.01.00.96"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY(_emited); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_Transmit_Normal + * \details Transmit a normal message + */ +void tst_acknow::tst_AcknowModel_Transmit_Normal() +{ + _expected = "A5.02.00.07.00.00.74.00"; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_KeepAlive, {}); + QVERIFY(_emited); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_Transmit_Acknow + * \details Transmit a message which needs a + */ +void tst_acknow::tst_AcknowModel_Transmit_Acknow() +{ + QCOMPARE( _MessageAcknowModel._acknowList.count(), 0 ); + _MessageDispatcher._needsAcknow.append(Gui::GuiActionType::ID_KeepAlive); + _expected = "A5.FD.FF.07.00.00.30.00"; + Sequence sequence = 3; + _MessageDispatcher.actionTransmit(Gui::GuiActionType::ID_KeepAlive, {}, sequence); + QCOMPARE( _MessageAcknowModel._acknowList.count(), 1 ); + QVERIFY(_emited); + _MessageDispatcher._needsAcknow.removeOne(Gui::GuiActionType::ID_KeepAlive); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_Receive_Normal + * \details UI receives a message which does not require Acknow + */ +void tst_acknow::tst_AcknowModel_onAcknowReceive_Correct() +{ + QCOMPARE( _MessageAcknowModel._acknowList.count(), 1 ); + _action = Gui::GuiActionType::ID_KeepAlive; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.03.00.FF.FF.01.00.91"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + qDebug() << "#" << mFrame.toString(); + emit _CanInterface.didFrameReceive(mFrame); + QCOMPARE( _MessageAcknowModel._acknowList.count(), 0 ); +} + +/*! + * \brief tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect + * \details Tries to remove a seq from acknow model which is not expected + * (there was no message send with this seq which required acknow) + * and the seq should not exist before and after removal + * this is a test for qt hash test used for acknow model + * \param vSequence + */ +void tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect() +{ + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); + _MessageAcknowModel.onAcknowReceive(9999); + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); +} + +void tst_acknow::cleanupTestCase() +{ + _CanInterface.quitDevice(); + QString mTr = tr("Disconnected"); + QCOMPARE(_CanInterface.status().left(mTr.length()), mTr); +} + +void tst_acknow::onFrameTransmit(Can_Id vCan_Id, const QByteArray &vPayload) +{ + Q_UNUSED(vCan_Id) + _emited = true; + QCOMPARE(Format::toHexString(vPayload), _expected); +} + +void tst_acknow::onActionReceive(Gui::GuiActionType vAction, const QVariantList &vData) +{ + _emited = true; + QVERIFY(vAction == _action); + for (int i = 0; i < vData.length(); i++) { + if (! strcmp(vData[i].typeName(), "float")) { + float f1 = vData[i].toFloat(); + float f2 = _data[i].toFloat(); + QVERIFY(Types::floatCompare(f1, f2)); + } else { + QVERIFY(vData[i] == _data[i]); + } + } +} + +void tst_acknow::onFramesTransmit(Can_Id vCan_Id, Sequence vSequence, const FrameList &vFrameList) +{ + qDebug() << quint16(vCan_Id) << vSequence << vFrameList; +} + +void tst_acknow::onFailedTransmit(Sequence) +{ + qDebug() << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "; +} Index: unittests/tst_acknow.h =================================================================== diff -u --- unittests/tst_acknow.h (revision 0) +++ unittests/tst_acknow.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,58 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_acknow.h + * \author (last) Behrouz NematiPour + * \date (last) 10-Aug-2021 + * \author (original) Behrouz NematiPour + * \date (original) 21-Jan-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project +#include "MessageDispatcher.h" +using namespace Can; + +class tst_acknow : public QObject +{ + Q_OBJECT + + bool _emited = false ; + QByteArray _expected {} ; + QVariantList _data {} ; + int _action = -1 ; + +public: + explicit tst_acknow(QObject *parent = nullptr); + +private slots: + void init(); + void tst_AcknowModel_Init(); + + // NOTE : PLEASE DO NOT CHANGE THE ORDER + // THE SEQUENCES HAS BEEN HARD CODED IN THE MESSAGES. + void tst_AcknowModel_Receive_Normal(); + void tst_AcknowModel_Receive_Acknow(); + + void tst_AcknowModel_Transmit_Normal(); + void tst_AcknowModel_Transmit_Acknow(); + + void tst_AcknowModel_onAcknowReceive_Correct(); + void tst_AcknowModel_onAcknowReceive_Incorrect(); + + void cleanupTestCase(); + + void onFrameTransmit (Can_Id vCan_Id , const QByteArray &vPayload); + void onActionReceive (GuiActionType vAction , const QVariantList &vData ); + void onFramesTransmit(Can_Id vCan_Id , Sequence vSequence, const FrameList &vFrameList); + void onFailedTransmit(Sequence); +}; Index: unittests/tst_canbus.cpp =================================================================== diff -u --- unittests/tst_canbus.cpp (revision 0) +++ unittests/tst_canbus.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,344 @@ +/*! + * + * Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_canbus.cpp + * \author (last) Behrouz NematiPour + * \date (last) 10-Aug-2021 + * \author (original) Behrouz NematiPour + * \date (original) 19-Dec-2019 + * + */ +#include "tst_canbus.h" + +// Project +#include "CanInterface.h" +#include "FrameInterface.h" + +using namespace Can; + +/*! + * \brief tst_canbus::tst_canbus + * \details Constructor + * \param parent - QObject parent owner object. + * Qt handles the children destruction by their parent objects life-cycle. + */ +tst_canbus::tst_canbus(QObject *parent) : QObject(parent) { } + +void tst_canbus::initTestCase() +{ +} + +void tst_canbus::initTestCase_data() +{ +} + +void tst_canbus::init() +{ + _emited = false; + _Logger.init(); +} + +void tst_canbus::tst_CanInterface_Connect_Error_Interface() +{ + QString mTr = tr("Connection"); + _CanInterface._canInterface = "can1"; + _CanInterface._init = false; + _CanInterface.init(); + _CanInterface.enableConsoleOut(false); + QCOMPARE(_CanInterface.status().left(mTr.length()), mTr); +} + +void tst_canbus::tst_CanInterface_Connect_NoError() +{ + _CanInterface._canInterface = "can0"; + _CanInterface._init = false; + _CanInterface.init(); + _CanInterface.enableConsoleOut(true); + QString mTr = tr("Connected"); + QCOMPARE(_CanInterface.status().left(mTr.length()), mTr); + + _CanInterface.onFrameReceive (); +} + +void tst_canbus::tst_FrameInterface_Init() +{ + _FrameInterface .init(); + _MessageDispatcher .init(); + _MessageDispatcher .enableConsoleOut(true); + + connect(&_MessageDispatcher , SIGNAL(didFrameTransmit(Can_Id , const QByteArray &)), + this , SLOT( onFrameTransmit(Can_Id , const QByteArray &))); + connect(&_MessageDispatcher , SIGNAL(didActionReceive(GuiActionType , const QVariantList &)), + this , SLOT( onActionReceive(GuiActionType , const QVariantList &))); +} + +void tst_canbus::tst_FrameInterface_ReInit() +{ + QVERIFY( ! _FrameInterface .init() ); // Coverage + QVERIFY( ! _MessageDispatcher .init() ); // Coverage +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_KeepAlive() +{ + _expected = "A5.01.00.07.00.00.30.00"; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_KeepAlive, {}); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_TransmitFrame_LongerData() +{ + _expected = QByteArray("123456789"); + _FrameInterface.transmitFrame(Can_Id::eChlid_HD_UI, _expected); + QVERIFY( ! _emited ); //there is no signal call - Code Coverage only : Error : "Payload cannot be larger than 8 bytes" +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff_Accepted() +{ + _expected = "A5.02.00.01.00.01.01.F0"; + QVariantList mData {static_cast(Gui::GuiActionData::Accepted)}; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_PowerOff, mData); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff_Rejected() +{ + _expected = "A5.03.00.01.00.01.02.F4"; + QVariantList mData {static_cast(Gui::GuiActionData::Rejected)}; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_PowerOff, mData); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_PowerOff() +{ + _expected = "A5.04.00.01.00.01.00.02"; + QVariantList mData {static_cast(Gui::GuiActionData::NoData)}; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_PowerOff, mData); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_Raw() +{ + // An example of longest data transmission by Gui::GuiActionType::String + // which can be as long as 255 byte. + _expected = "A5.05.00.FF.FE.01.41.18"; + // A + QVariantList mData {"A"}; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_RawData, mData); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_ShortPayload() +{ + _expected = "A5.06.00.01.00.00.00.00"; + QVariantList mData {}; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_PowerOff, mData); + QVERIFY(! _emited); // not emitted due to short payload len +} + +void tst_canbus::tst_FrameInterface_ActionTransmit_Unknown() +{ + _expected = ""; + _MessageDispatcher.onActionTransmit(Gui::GuiActionType::ID_Unknown, {}); + QVERIFY( ! _emited ); // should not emit the signal due to unknown action +} + +void tst_canbus::tst_FrameInterface_FrameReceived_PowerOff() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.01.00.01.00.01.00.38"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_FrameReceived_PowerOff_Timeout() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {1}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.02.00.01.00.01.01.F0"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_FrameReceived_Channel_NotListen() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {1}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_DG); + mPayload = "A5.03.00.01.00.01.01.XX"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY( ! _emited ); // should not be emitted due to not listening channel +} + +void tst_canbus::tst_FrameInterface_FrameReceived_Channel_Incorrect() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {1}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(0x999); + mPayload = "A5.01.00.01.01.5E.00.00"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY( ! _emited ); // should not be emitted due to not listening channel +} + +void tst_canbus::tst_FrameInterface_FrameReceived_CRC_Error() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.01.00.01.00.66.00.00"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QCOMPARE(_emited, false); // Should not emit due to crc error +} + +void tst_canbus::tst_FrameInterface_FrameReceived_ShortFrame_Error() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.01.00.01.00.6F"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY( ! _emited); // Should not emit due to frame length less than 8 +} + +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_Error() +{ + _action = Gui::GuiActionType::ID_PowerOff; + _data = {0}; + QCanBusFrame mFrame; + QString mPayload; + mFrame.setFrameId(Can_Id::eChlid_HD_UI); + mPayload = "A5.04.00.01.00.01.00.6F.FF.FF"; + mFrame.setPayload(QByteArray::fromHex(mPayload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + QVERIFY( ! _emited); // Should not emit due to crc error +} + +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_BloodFlow() +{ + _action = Gui::GuiActionType::ID_BloodFlow; + _data = { -400, -397.50f, -26.20f, -2000.00f, -2002.50f, 648.75f, 62.50f }; + QCanBusFrame mFrame; + mFrame.setFrameId(Can_Id::eChlid_HD_Sync); + QStringList mPayloadList { + "a5.0a.00.05.00.1c.70.fe" , + "ff.ff.00.c0.c6.c3.9a.99" , + "d1.c1.00.00.fa.c4.00.50" , + "fa.c4.00.30.22.44.00.00" , + "7a.42.fb.00.00.00.00.00" , + }; + for ( QString payload : mPayloadList ) { + mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + } + QVERIFY(_emited); +} + +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_BloodFlow_LessData() +{ + _action = Gui::GuiActionType::ID_BloodFlow; + _data = { -400, -397.50f, -26.20f, -2000.00f, -2002.50f, 648.75f, 62.50f }; + QCanBusFrame mFrame; + mFrame.setFrameId(Can_Id::eChlid_HD_Sync); + QStringList mPayloadList { + "a5.05.00.1c.70.fe.ff.ff" , + "00.c0.c6.c3.9a.99.d1.c1" , + "00.00.fa.c4.00.50.fa.c4" , + "00.30.22.44.00.00.7a.42" , + }; + for ( QString payload : mPayloadList ) { + mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); + emit _CanInterface.didFrameReceive(mFrame); + } + QVERIFY( ! _emited ); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0500'" +} + +void tst_canbus::tst_FrameInterface_FrameReceived_LongFrame_AlarmStatus_LessData() +{ + _action = Gui::GuiActionType::ID_AlarmStatus; + _data = { 2, 10, 60, 30, + false,true ,false,false, // 0100 + true ,false,false,false, // 1000 + true ,true ,false,false, // 1100 + false,false,false,false, // 0000 + }; + QCanBusFrame mFrame; + mFrame.setFrameId(Can_Id::eChlid_HD_Alarm); + QStringList mPayloadList { + "a5.02.00.12.02.00.00.00" , + "0a.00.00.00.3c.00.00.00" , + }; + for ( QString payload : mPayloadList ) { + mFrame.setPayload(QByteArray::fromHex(payload.remove(QLatin1Char('.')).toLatin1())); + qDebug() << " ~ @ ~ : " << mFrame.payload(); + emit _CanInterface.didFrameReceive(mFrame); + } + QVERIFY( ! _emited ); // Should not emit due to - ERROR : "Incorrect data for Message ID (HD) '0x0200'" +} + +void tst_canbus::tst_FrameInterface_FrameReceived_removeHead_EmptyList() +{ + FrameInterface frame; + frame.init(); + QVERIFY(frame._txFrameList.isEmpty()); + frame.removeHead(); + // if the code does not work and calls the removeFirst of and empty list it will assert. + QVERIFY(true); +} + +void tst_canbus::cleanup() +{ +} + +void tst_canbus::cleanupTestCase() +{ + _CanInterface.quitDevice(); + QString mTr = tr("Disconnected"); + QCOMPARE(_CanInterface.status().left(mTr.length()), mTr); +} + +void tst_canbus::onFrameTransmit(Can_Id vCan_Id, const QByteArray &vPayload) +{ + Q_UNUSED(vCan_Id) + _emited = true; + QCOMPARE(Format::toHexString(vPayload), _expected); +} + +void tst_canbus::onActionReceive(Gui::GuiActionType vAction, const QVariantList &vData) +{ + _emited = true; + QVERIFY(vAction == _action); + qDebug() << " ~ @ ~ : " << vData; + for (int i = 0; i < vData.length(); i++) { + if (! strcmp(vData[i].typeName(), "float")) { + float f1 = vData[i].toFloat(); + float f2 = _data[i].toFloat(); + QVERIFY(Types::floatCompare(f1, f2)); + } else { + QCOMPARE(vData, _data); + } + } +} Index: unittests/tst_canbus.h =================================================================== diff -u --- unittests/tst_canbus.h (revision 0) +++ unittests/tst_canbus.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,81 @@ +/*! + * + * Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_canbus.h + * \author (last) Behrouz NematiPour + * \date (last) 10-Aug-2021 + * \author (original) Behrouz NematiPour + * \date (original) 19-Dec-2019 + * + */ +#pragma once + +// Qt +#include +#include + +// Project +#include "MessageDispatcher.h" +using namespace Can; + +class tst_canbus : public QObject +{ + Q_OBJECT + + bool _emited = false ; + QByteArray _expected {} ; + QVariantList _data {} ; + int _action = -1 ; + +public: + explicit tst_canbus(QObject *parent = nullptr); + +private slots: + void initTestCase_data(); + + void initTestCase(); + void init(); + + void tst_CanInterface_Connect_Error_Interface(); + void tst_CanInterface_Connect_NoError(); + + void tst_FrameInterface_Init(); + + void tst_FrameInterface_ReInit(); + + // NOTE : PLEASE DO NOT CHANGE THE ORDER + // THE SEQUENCES HAVE BEEN HARD CODED IN THE MESSAGES. + void tst_FrameInterface_ActionTransmit_KeepAlive(); + void tst_FrameInterface_TransmitFrame_LongerData(); + void tst_FrameInterface_ActionTransmit_PowerOff_Accepted(); + void tst_FrameInterface_ActionTransmit_PowerOff_Rejected(); + void tst_FrameInterface_ActionTransmit_PowerOff(); + void tst_FrameInterface_ActionTransmit_Raw(); + void tst_FrameInterface_ActionTransmit_ShortPayload(); + void tst_FrameInterface_ActionTransmit_Unknown (); + + void tst_FrameInterface_FrameReceived_PowerOff(); + void tst_FrameInterface_FrameReceived_PowerOff_Timeout(); + void tst_FrameInterface_FrameReceived_Channel_NotListen(); + void tst_FrameInterface_FrameReceived_Channel_Incorrect(); + void tst_FrameInterface_FrameReceived_CRC_Error(); + void tst_FrameInterface_FrameReceived_ShortFrame_Error(); + void tst_FrameInterface_FrameReceived_LongFrame_Error(); + + void tst_FrameInterface_FrameReceived_LongFrame_BloodFlow(); + void tst_FrameInterface_FrameReceived_LongFrame_BloodFlow_LessData(); + + void tst_FrameInterface_FrameReceived_LongFrame_AlarmStatus_LessData(); + + void tst_FrameInterface_FrameReceived_removeHead_EmptyList(); + + void cleanup(); + void cleanupTestCase(); + + void onFrameTransmit(Can_Id vCan_Id , const QByteArray &vPayload); + void onActionReceive(GuiActionType vAction , const QVariantList &vData ); +}; Index: unittests/tst_fileHandler.cpp =================================================================== diff -u --- unittests/tst_fileHandler.cpp (revision 0) +++ unittests/tst_fileHandler.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,142 @@ +/*! + * + * Copyright (c) 2023-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_fileHandler.cpp + * \author (last) Vy + * \date (last) 01-Dec-2023 + * \author (original) Vy + * \date (original) 01-Dec-2023 + * + */ +#include "tst_fileHandler.h" + +// Qt + +// Project +#include "VAdjustmentResponseBase.h" +#include "VTreatmentAdjustmentUltrafiltrationState.h" +#include "FileHandler.h" +#include "VPreTreatmentDisposablesPrimeData.h" +#include "VAlarmStatus.h" + +tst_fileHandler::tst_fileHandler(QObject *parent) : QObject(parent) { } + +void tst_fileHandler::tst_read_append_return() +{ + int filesCreated = helperFunction_createFolderFiles("/tmp/tst_read_append_return/", "mock_folder", 1, 1); + if(filesCreated <=0) QSKIP("could not create test file"); + const QString fileToRead = "/tmp/tst_read_append_return/mock_folder_0/mock_out0.out"; + const QString controlString = "TestContent"; + QString contentRead = controlString; + bool readResults = FileHandler::read(fileToRead, contentRead, true); + QVERIFY(readResults); + QVERIFY(contentRead.contains(controlString) && (contentRead.length() > controlString.length())); +} + +void tst_fileHandler::tst_removeFiles() +{ + const int testCount = 15; + int filesCreated = helperFunction_createFolderFiles("/tmp/tst_removeFiles/", "mock_folder", 1, testCount); + if(filesCreated != testCount) { QSKIP("creation of temp files failed"); } + + QStringList folderList = {"/tmp/tst_removeFiles/mock_folder_0/"}; + QDate dateOlderThanFilter; + int countRemoved = FileHandler::removeFiles(folderList, {}, dateOlderThanFilter); + QCOMPARE(countRemoved, testCount); +} + +void tst_fileHandler::tst_isMounted() +{ + bool isReadOnly = false; + bool isMounted = false; + + // mount location is not mounted + isMounted = FileHandler::isMounted("/media/sd-card", &isReadOnly); + QCOMPARE(isMounted, false); // Expecting a fail here + QCOMPARE(isReadOnly, false); // Expecting a fail here + + // empty path case + isMounted = FileHandler::isMounted("", &isReadOnly); + QCOMPARE(isMounted, false); // Expecting a fail here + QCOMPARE(isReadOnly, false); // Expecting a fail here + + //Coverage call since we remove the trailing slash + isMounted = FileHandler::isMounted("/media/sd-card/", &isReadOnly); + QCOMPARE(isReadOnly, false); // Expecting a fail here +} + +void tst_fileHandler::tst_tmpUsable() +{ + bool isTmpUsable = FileHandler::tmpUsable(); + QVERIFY(isTmpUsable); + + isTmpUsable = FileHandler::tmpUsable(); + QVERIFY(isTmpUsable); +} + +void tst_fileHandler::tst_find() +{ + // tests for find(QString, QStringList, quint8) + const QString folderPath = "/tmp/tst_find/mock_folder_0/"; + int filesCreatedCount = helperFunction_createFolderFiles(folderPath, "mock_folder", 1, 0); + QFileInfoList list = FileHandler::find(folderPath, {}, 100); + QCOMPARE(list.length(), 0); // expect 0 files to remove when the percent retained is 100% + + list = FileHandler::find(folderPath+"_not_exist", {}, 80); + QCOMPARE(list.length(), 0); // expect 0 files to remove when the folder path doesn't exist + + list = FileHandler::find(folderPath, {}, 80); + QCOMPARE(list.length(), 0); // expecting 0 files to remove when the folder exist, but no files + + filesCreatedCount = helperFunction_createFolderFiles(folderPath, "mock_folder", 1, 10); + list = FileHandler::find(folderPath, {}, 99); + QCOMPARE(list.length(), 0); // expecting empty list when retaining 99% of files + +// list = FileHandler::find(folderPath, {}, 1); +// QVERIFY(list.length()!=0); // expecting a non-empty list when not keeping everything in path + + list = FileHandler::find(folderPath, {}, 0); + QCOMPARE(list.length(), filesCreatedCount); // expecting a non-empty list when not keeping everything in path + + // second find(QString, QStringList) function + list = FileHandler::find(folderPath+"_not_exist", {}); + QCOMPARE(list.length(), 0); // expect 0 files to remove since the path does not exist +} + +/*! + * \brief tst_fileHandler::helperFunction_createFolderFiles + * \details Creates vNumberOfFolders in the vDirPath with vNumberOfFiles in each folder. The files created contain "TestContent" text + * and their filenames are "VBaseFileNamesvBaseFileExt" the I is the index from 0...vNumberOfFiles. + * Folders are also automatically indexed from 0...vNumberOfFolders + * \return The count of files created + */ +int tst_fileHandler::helperFunction_createFolderFiles(const QString vDirPath, + const QString vBaseFolderName, const int vNumberOfFolders, + const int vNumberOfFiles, const QString VBaseFileNames, const QString vBaseFileExt) +{ + int filesCreatedCount = 0; + QDir rootPath = QDir::root(); + for(quint8 folderIndex = 0; folderIndex < vNumberOfFolders; folderIndex++) { + const QString currentFolder = QString("%1/%2_%3/").arg(vDirPath).arg(vBaseFolderName).arg(folderIndex); + bool isCreatedDir = rootPath.mkpath(currentFolder); + if(!isCreatedDir) { return -1;} + + for(quint8 i=0; i +#include + +// Project +#include "VTreatmentCreate.h" + +class tst_fileHandler : public QObject +{ + Q_OBJECT +public: + explicit tst_fileHandler(QObject *parent = nullptr); + +private slots: + void tst_read_append_return(); + void tst_removeFiles(); + void tst_isMounted(); + void tst_tmpUsable(); + void tst_find(); +private: + int helperFunction_createFolderFiles(const QString vDirPath, + const QString vBaseFolderName = "tmp_folder", + const int vNumberOfFolders = 1, + const int vNumberOfFiles = 10, + const QString VBaseFileNames = "mock_out", + const QString vBaseFileExt = ".out"); +}; Index: unittests/tst_initializations.cpp =================================================================== diff -u --- unittests/tst_initializations.cpp (revision 0) +++ unittests/tst_initializations.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,43 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_initializations.cpp + * \author (last) Behrouz NematiPour + * \date (last) 03-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#include "tst_initializations.h" + +// Qt + +// Project +#include "ApplicationController.h" +#include "GuiController.h" +#include "DeviceController.h" +#include "CanInterface.h" +#include "FrameInterface.h" +#include "MessageDispatcher.h" +#include "MessageAcknowModel.h" + +tst_initializations::tst_initializations(QObject *parent) : QObject(parent) { } + +void tst_initializations::tst_ApplicationController_init() +{ + QCOMPARE( _ApplicationController.init(), ! _ApplicationController.init()); +} + +void tst_initializations::tst_DeviceController_init() +{ + QCOMPARE( _DeviceController.init(), ! _DeviceController.init()); +} + +void tst_initializations::tst_FrameInterface_init() +{ + QCOMPARE( _FrameInterface.init(), ! _FrameInterface.init()); +} Index: unittests/tst_initializations.h =================================================================== diff -u --- unittests/tst_initializations.h (revision 0) +++ unittests/tst_initializations.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,34 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_initializations.h + * \author (last) Behrouz NematiPour + * \date (last) 03-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project + +class tst_initializations : public QObject +{ + Q_OBJECT + +public: + explicit tst_initializations(QObject *parent = nullptr); + +private slots: + void tst_ApplicationController_init(); + void tst_DeviceController_init(); + void tst_FrameInterface_init(); +}; Index: unittests/tst_logging.cpp =================================================================== diff -u --- unittests/tst_logging.cpp (revision 0) +++ unittests/tst_logging.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,196 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_logging.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 08-Jan-2020 + * + */ +#include "tst_logging.h" + +// Qt +#include +#include + +// Project +#include "FileHandler.h" +#include "Logger.h" +#include "MessageInterpreter.h" + +using namespace Storage; + +/*! + * \brief tst_logging::tst_logging + * \details Constructor + * \param parent - QObject parent owner object. + * Qt handles the children destruction by their parent objects life-cycle. + */ +tst_logging::tst_logging(QObject *parent) : QObject(parent) { } + +void tst_logging::initTestCase() +{ + Threads::registerTypes(); + QCOMPARE( _Logger.init(Threads::_Logger_Thread), !_Logger.init(Threads::_Logger_Thread)); + _Logger._timeFormat = ""; +} + +void tst_logging::cleanup() +{ + // TODO need to + QThread::currentThread()->msleep(1000); +} + +void tst_logging::init() +{ + // TODO need to fix and add a "start" step that gets called before each test function +} + +void tst_logging::logEvent() +{ + LOG_APPED("1 - Event log has been created"); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, ",1 - Event log has been created\n"); +} + +void tst_logging::logDatum() +{ + LOG_APPED("3 - Datum log has been created"); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, ",3 - Datum log has been created\n"); +} + +void tst_logging::logError() +{ + LOG_DEBUG("2 - Error log has been created"); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, ",2 - Error log has been created\n"); +} + +void tst_logging::logUnknown() +{ + emit Storage::Logger::I().didLog("4 - Datum log has been created", Storage::Logger::LogType::eLogType_Count, false); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, ",Incorrect type of logging 3\n" + ",4 - Datum log has been created\n"); +} + +void tst_logging::logError_gDisableUnhandledReport_False() +{ + gDisableUnhandledReport = false; + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AlarmTriggered; + msg.data = {}; + iMsg.printUnhandled(msg); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QStringList lines = mContent.split("\n"); + QVERIFY(lines.count()); + QCOMPARE(lines.first(), ",Unhandled Message ID (HD)"); +} + +void tst_logging::logError_gDisableUnhandledReport_True() +{ + gDisableUnhandledReport = true; + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AlarmTriggered; + msg.data = {}; + iMsg.printUnhandled(msg); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, ""); +} + +void tst_logging::logError_Unhandled_TreatmentStates() +{ + gDisableUnhandledReport = false; + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_TreatmentStates; + msg.data = {}; + QVariantList vData {}; + QVERIFY(! iMsg.interpretMessage_HD(msg, vData)); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QStringList lines = mContent.split("\n"); + QVERIFY(lines.count()); + QCOMPARE(lines.first(), ",Incorrect data length for received Message with ID '0x0F00'"); +} + +void tst_logging::setLogPath_F() +{ + _Logger._dir.setPath("/"); + bool b = _Logger.setLogPath(); + QCOMPARE(b , false); +} + +void tst_logging::setLogPath_T() +{ + _Logger._dir.setPath("/tmp"); + bool b = _Logger.setLogPath(); + QCOMPARE(b , true); +} + +void tst_logging::readUnknown() +{ + QString mContent; + QVERIFY(! FileHandler::read("TheFileWhichDoesntExist.UnknownExtension", mContent)); +} + +void tst_logging::setLogPath_TreatmentType() +{ + // setLogPath for type eLogTrmt returns true by default, check + QVERIFY(_Logger.setLogPath(Storage::Logger::LogType::eLogTrtmt)); +} + +void tst_logging::tst_log_function_extraCases() +{ + // Test the log function for the "Squish-unreachable" cases + + // case 1 : default log type of make log file name section + _Logger.log("Mock Log Message String", Storage::Logger::LogType::eLogTrtmt, false); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, "Incorrect type of logging"); + + // case 2 : logPathName is empty + _Logger._logPathNames.clear(); + _Logger.log("Mock Log Message String", Storage::Logger::LogType::eLogTrtmt, false); + //Check the logFileName constructed, it should be a debug path and file ext + QString currentDate = QDate::currentDate().toString(_Logger._dateFormat); + QString expectedFileName = currentDate + _Logger._dateSeparator + _Logger._logFileNamePrefix + _Logger._logPathNames[Storage::Logger::eLogDebug]; + QCOMPARE(_Logger._logFileName, _Logger._logPathNames[Storage::Logger::eLogDebug] + expectedFileName); +} + +void tst_logging::tst_enableConsoleOut() +{ + _Logger._enableConsoleOut = false; // need to skip the check in enableConsoleOut function + _Logger.enableConsoleOut(true); + QString mContent; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, "Console out Logging enabled"); + QVERIFY(_Logger._enableConsoleOut); // Check value stored + + _Logger._enableConsoleOut = true;// need to skip the check in enableConsoleOut function + _Logger.enableConsoleOut(false); + mContent = ""; + FileHandler::read(_Logger._logFileName, mContent); + QCOMPARE(mContent, "Console out Logging disabled"); + QVERIFY(!_Logger._enableConsoleOut); // Check expected value stored + + // Coverage + _Logger._enableConsoleOut = false;// need to skip the check in enableConsoleOut function + _Logger.enableConsoleOut(false); + QVERIFY(!_Logger._enableConsoleOut); // Check expected value stored +} Index: unittests/tst_logging.h =================================================================== diff -u --- unittests/tst_logging.h (revision 0) +++ unittests/tst_logging.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,59 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_logging.h + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 08-Jan-2020 + * + */ +#pragma once + +#include +#include + +class tst_logging : public QObject +{ + Q_OBJECT + + bool _emited = false ; + QByteArray _expected {} ; + QVariantList _data {} ; + int _action = -1 ; + +public: + explicit tst_logging(QObject *parent = nullptr); + +private slots: + // will be called before the first test function is executed. + void initTestCase(); + + // will be called after every test function. + void cleanup(); + + void init(); + + void logEvent(); + void logDatum(); + void logError(); + void logUnknown(); + + void logError_gDisableUnhandledReport_False(); + void logError_gDisableUnhandledReport_True (); + + void logError_Unhandled_TreatmentStates(); + + void setLogPath_F(); + void setLogPath_T(); + void setLogPath_TreatmentType(); + void tst_log_function_extraCases(); + + void tst_enableConsoleOut(); + + void readUnknown(); +}; Index: unittests/tst_messaging.cpp =================================================================== diff -u --- unittests/tst_messaging.cpp (revision 0) +++ unittests/tst_messaging.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,777 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_messaging.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#include "tst_messaging.h" + +// Qt + +// Project +#include "main.h" +#include "MessageInterpreter.h" +#include "MessageBuilder.h" +#include "MAdjustPowerOff.h" +#include "MessageDispatcher.h" +#include "AlarmGenerator.h" + +using namespace Can; + +tst_messaging::tst_messaging(QObject *parent) : QObject(parent) { } + +/*! + * \brief tst_messaging::tst_MessageInterpreter_isType + * \details Tests MessageInterpreter isType method + */ +void tst_messaging::tst_MessageInterpreter_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateReq; + msg.data = {}; + QVERIFY( iMsg.isType(msg, Gui::GuiActionType::ID_AdjustBloodDialysateReq)); + QVERIFY(! iMsg.isType(msg, Gui::GuiActionType::ID_BloodFlow)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_isPayloadLenValid + * \details Tests MessageInterpreter isPayloadLenValid method + */ +void tst_messaging::tst_MessageInterpreter_isPayloadLenValid() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateReq; + msg.data = {}; + QVERIFY( ! iMsg.isPayloadLenValid(msg, Gui::GuiActionType::ID_AdjustBloodDialysateReq)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_isPayloadLenValid + * \details Tests MessageInterpreter isPayloadLenValid method + */ +void tst_messaging::tst_MessageInterpreter_isPayloadLenValid_undefined() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = static_cast(-1); + msg.data = {}; + QVERIFY( ! iMsg.isPayloadLenValid(msg, msg.actionId)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_powerOffData + * \details Tests MessageInterpreter powerOffData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_powerOffData() +{ + Can::MessageInterpreter iMsg; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_PowerOff; + msg.data = {}; + msg.can_id = canId; + + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_bloodFlowData + * \details Tests MessageInterpreter bloodFlowData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_bloodFlowData() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_BloodFlow; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); + QVERIFY( data.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_dialysateInletFlowData + * \details Tests MessageInterpreter dialysateInletFlowData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_dialysateInletFlowData() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_DialysateInletFlow; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); + QVERIFY( data.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_dialysateOutletFlowData + * \details Tests MessageInterpreter dialysateOutletFlowData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_dialysateOutletFlowData() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_DialysateOutletFlow; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); + QVERIFY( data.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_treatmentTime + * \details Tests MessageInterpreter treatmentTime method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_treatmentTime() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_TreatmentTime; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); + QVERIFY( data.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_pressureOcclusionData + * \details Tests MessageInterpreter pressureOcclusionData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_pressureOcclusionData() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_PressureOcclusion; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.interpretMessage(msg, data)); + QVERIFY( data.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustBloodDialysateData_isType + * \details Tests MessageInterpreter adjustBloodDialysateData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_adjustBloodDialysateData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustBloodDialysateData_payloadLen + * \details Tests MessageInterpreter adjustBloodDialysateData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_adjustBloodDialysateData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateRsp; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustDurationData_isType + * \details Tests MessageInterpreter adjustDurationData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_adjustDurationData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustDurationData_payloadLen + * \details Tests MessageInterpreter adjustDurationData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_adjustDurationData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustDurationRsp; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationEditData_isType + * \details Tests MessageInterpreter adjustUltrafiltrationEditData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationEditData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustUltrafiltrationEdit(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationEditData_payloadLen + * \details Tests MessageInterpreter adjustUltrafiltrationEditData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationEditData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustUltrafiltrationEdit(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationConfirmData_isType + * \details Tests MessageInterpreter adjustUltrafiltrationConfirmData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationConfirmData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustUltrafiltrationConfirm(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationConfirmData_payloadLen + * \details Tests MessageInterpreter adjustUltrafiltrationConfirmData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_adjustUltrafiltrationConfirmData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustUltrafiltrationConfirm(msg, list)); +} + +/*! + * \brief tst_MessageInterpreter_Alarms + * \details Tests the message interpreter handling of empty HD messages + */ +void tst_messaging::tst_MessageInterpreter_HD_emptyMessages() +{ + gDisableUnhandledReport = true; + Can::MessageInterpreter interpreter; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_AlarmTriggered; + msg.data = {}; + QVariantList list; + + QList actionTypes = { + Gui::GuiActionType::ID_AlarmTriggered, + Gui::GuiActionType::ID_AlarmCleared, + Gui::GuiActionType::ID_TreatmentStates, + }; + + foreach (const Gui::GuiActionType &each, actionTypes) { + msg.actionId = each; + QVERIFY(! interpreter.interpretMessage_HD(msg, list)); + } + + msg.actionId = Gui::GuiActionType::ID_RawData; + QVERIFY(!interpreter.interpretMessage_HD(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_treatmentRangesData_isType + * \details Tests MessageInterpreter treatmentRangesData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_treatmentRangesData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_treatmentRangesData_payloadLen + * \details Tests MessageInterpreter treatmentRangesData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_treatmentRangesData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_TreatmentRanges; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_loadCellReadingsData_isType + * \details Tests MessageInterpreter treatmentRangesData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_loadCellReadingsData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_loadCellReadingsData_payloadLen + * \details Tests MessageInterpreter treatmentRangesData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_loadCellReadingsData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_DGLoadCellReadingsData; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_temperatureSensorsData_isType + * \details Tests MessageInterpreter treatmentRangesData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_temperatureSensorsData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_temperatureSensorsData_payloadLen + * \details Tests MessageInterpreter temperatureSensorsData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_temperatureSensorsData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_DGTemperaturesData; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_temperatureSensorsData_isType + * \details Tests MessageInterpreter canbusFaultCountData method Message Type check + */ +void tst_messaging::tst_MessageInterpreter_canbusFaultCountData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.canbusFaultCountData(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_temperatureSensorsData_payloadLen + * \details Tests MessageInterpreter canbusFaultCountData method Message payload length check + */ +void tst_messaging::tst_MessageInterpreter_canbusFaultCountData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_CANBusFaultCount; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.canbusFaultCountData(msg, list)); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_String + * \details Tests MessageInterpreter interpretMessage to handle String message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_String() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_NONE; + + QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_RawData, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +void tst_messaging::tst_MessageInterpreter_interpretMessage_DG_Unhandled() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can::Message msg; + msg.actionId = static_cast(-1); + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.interpretMessage_DG(msg, list)); + QVERIFY(list.isEmpty()); +} + +void tst_messaging::tst_MessageInterpreter_notify_fromByteArray() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_PowerOff; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.notify(msg, list, Gui::GuiActionType::ID_PowerOff)); + QVERIFY(list.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustBloodDialysateReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustBloodDialysateReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustBloodDialysateReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY(! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustBloodDialysateReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustDurationReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustDurationReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustDurationReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustDurationReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AlarmSilenceReq + * \details Tests MessageInterpreter interpretMessage to handle AlarmSilenceReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AlarmSilenceReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY(! iMsg.interpretMessage(Gui::GuiActionType::ID_AlarmSilenceReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationInitReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustUltrafiltrationInitReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationInitReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY(! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationInitReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationStateReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustUltrafiltrationStateReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationStateReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY(! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationEditReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustUltrafiltrationEditReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationEditReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationConfirmReq + * \details Tests MessageInterpreter interpretMessage to handle AdjustUltrafiltrationConfirmReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationConfirmReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustSalineReq + * \details Tests MessageInterpreter interpretMessage to handle ID_AdjustSalineReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustSalineReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustSalineReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustHeparinReq + * \details Tests MessageInterpreter interpretMessage to handle ID_AdjustHeparinReq message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustHeparinReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustHeparinReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustPressuresReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustPressuresLimitsReq, {}, payload, canId)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_CANBusFaultCount + * \details Tests MessageInterpreter interpretMessage to handle ID_CANBusFaultCount message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_CANBusFaultCount() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::ID_CANBusFaultCount; + msg.data = {}; + QVariantList data; + QVERIFY( ! iMsg.canbusFaultCountData(msg, data)); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_addActionId + * \details Tests addActionId() method usage of MessageBuilder + */ +void tst_messaging::tst_MessageBuilder_addActionId() +{ + Can::MessageBuilder bMsg; + QByteArray payload; + QVERIFY( ! bMsg.addActionId(payload, Gui::GuiActionType::ID_Unknown)); + QVERIFY( payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_addData_shorterLen + * \details Tests Data length of shorter than expected + * in addData() method of MessageBuilder + + */ +void tst_messaging::tst_MessageBuilder_addData_shorterLen() +{ + Can::MessageBuilder bMsg; + QByteArray payload; + QVERIFY( ! bMsg.addData(payload, Gui::GuiActionType::ID_PowerOff, {})); + QVERIFY( payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_addData_LongerThanMax + * \details Tests Data length of longer than maximum accepted + * in addData() method of MessageBuilder + */ +void tst_messaging::tst_MessageBuilder_addData_LongerThanMax() +{ + Can::MessageBuilder bMsg; + QByteArray payload; + QByteArray data; + for (int i = 0; i<= Can::eLenMaxData + 1; i++ ) { + data += i; + } + QVERIFY(bMsg.addData(payload, Gui::GuiActionType::ID_RawData, data)); + QVERIFY( ! payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_checkCRC + * \details Tests checkCRC() method usage of MessageBuilder + */ +void tst_messaging::tst_MessageBuilder_checkCRC() +{ + Can::MessageBuilder bMsg; + QByteArray data; + quint8 vExpected, vActual; + QVERIFY( ! bMsg.checkCRC(data, vExpected, vActual)); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_getHeader + * \details Tests getHeader() method usage of MessageBuilder + */ +void tst_messaging::tst_MessageBuilder_getHeader() +{ + Can::MessageBuilder bMsg; + QByteArray payload; + QVERIFY(bMsg.getHeader(payload).isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_buildFrames_addActionId + * \details Tests addActionId() method usage of MessageBuilder in buildFrames method + */ +void tst_messaging::tst_MessageBuilder_buildFrames_addActionId() +{ + Can::MessageBuilder bMsg; + QByteArray data; + Can::FrameList framelist; + Can::Sequence seq = 1; + QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::ID_Unknown, data, framelist, seq)); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_buildFrames_addData + * \details Tests addData() method usage of MessageBuilder in buildFrames method + */ +void tst_messaging::tst_MessageBuilder_buildFrames_addData() +{ + Can::MessageBuilder bMsg; + QByteArray data; + Can::FrameList framelist; + Can::Sequence seq = 1; + QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::ID_PowerOff, data, framelist, seq)); +} + +/*! + * \brief tst_messaging::tst_MessageBuilder_buildFrames_eLenCanFrame + * \details Tests canFrameLength check in buildFrames method of MessageBuilder + */ +void tst_messaging::tst_MessageBuilder_buildFrames_eLenCanFrame() +{ + Can::MessageBuilder bMsg; + QByteArray data; + data += 0x01; + data += 0x02; + data += 0x03; + data += 0x04; + data += 0x05; + data += 0x06; + data += 0x07; + data += 0x08; + data += 0x09; + + Can::FrameList framelist; + Can::Sequence seq = 1; + QVERIFY( bMsg.buildFrames(Gui::GuiActionType::ID_RawData, data, framelist, seq)); +} + +/*! + * \brief tst_messaging::tst_MessageDispatcher_actionTransmit + * \details Tests MessageDispatcher actionTransmit() + */ +void tst_messaging::tst_MessageDispatcher_actionTransmit() +{ + Can::MessageDispatcher dMsg; + QVariantList data; + Can::Sequence seq = 1; + dMsg.actionTransmit(Gui::GuiActionType::ID_AdjustBloodDialysateReq, data, seq); +} + +/*! + * \brief tst_messaging::tst_MessageDispatcher_actionTransmit + * \details Tests MessageDispatcher actionTransmit() + */ +void tst_messaging::tst_MessageDispatcher_actionTransmit_Unknown() +{ + Can::MessageDispatcher dMsg; + QVariantList data; + 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 --- unittests/tst_messaging.h (revision 0) +++ unittests/tst_messaging.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,100 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_messaging.h + * \author (last) Behrouz NematiPour + * \date (last) 24-Jan-2021 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#pragma once + +// Qt +#include +#include + +class tst_messaging : public QObject +{ + Q_OBJECT + +public: + explicit tst_messaging(QObject *parent = nullptr); + +private slots: + void tst_MessageInterpreter_isType(); + void tst_MessageInterpreter_isPayloadLenValid(); + void tst_MessageInterpreter_isPayloadLenValid_undefined(); + + void tst_MessageInterpreter_powerOffData(); + + void tst_MessageInterpreter_bloodFlowData(); + + void tst_MessageInterpreter_dialysateInletFlowData(); + + void tst_MessageInterpreter_dialysateOutletFlowData(); + + void tst_MessageInterpreter_treatmentTime(); + + void tst_MessageInterpreter_pressureOcclusionData(); + + void tst_MessageInterpreter_adjustBloodDialysateData_isType(); + void tst_MessageInterpreter_adjustBloodDialysateData_payloadLen(); + + void tst_MessageInterpreter_adjustDurationData_isType(); + void tst_MessageInterpreter_adjustDurationData_payloadLen(); + + void tst_MessageInterpreter_adjustUltrafiltrationEditData_isType(); + void tst_MessageInterpreter_adjustUltrafiltrationEditData_payloadLen(); + + void tst_MessageInterpreter_adjustUltrafiltrationConfirmData_isType(); + void tst_MessageInterpreter_adjustUltrafiltrationConfirmData_payloadLen(); + void tst_MessageInterpreter_HD_emptyMessages(); + + void tst_MessageInterpreter_treatmentRangesData_isType(); + void tst_MessageInterpreter_treatmentRangesData_payloadLen(); + + void tst_MessageInterpreter_loadCellReadingsData_isType(); + void tst_MessageInterpreter_loadCellReadingsData_payloadLen(); + + void tst_MessageInterpreter_temperatureSensorsData_isType(); + void tst_MessageInterpreter_temperatureSensorsData_payloadLen(); + + void tst_MessageInterpreter_canbusFaultCountData_isType(); + void tst_MessageInterpreter_canbusFaultCountData_payloadLen(); + + void tst_MessageInterpreter_interpretMessage_AdjustBloodDialysateReq(); + void tst_MessageInterpreter_interpretMessage_AdjustDurationReq(); + void tst_MessageInterpreter_interpretMessage_AlarmSilenceReq(); + void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationInitReq(); + void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationStateReq(); + void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationEditReq(); + void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationConfirmReq(); + void tst_MessageInterpreter_interpretMessage_AdjustSalineReq(); + void tst_MessageInterpreter_interpretMessage_AdjustHeparinReq(); + void tst_MessageInterpreter_interpretMessage_AdjustPressuresReq(); + + void tst_MessageInterpreter_interpretMessage_CANBusFaultCount(); + void tst_MessageInterpreter_interpretMessage_String(); + void tst_MessageInterpreter_interpretMessage_DG_Unhandled(); + + void tst_MessageInterpreter_notify_fromByteArray(); + + void tst_MessageBuilder_addActionId(); + void tst_MessageBuilder_addData_shorterLen(); + void tst_MessageBuilder_addData_LongerThanMax(); + void tst_MessageBuilder_checkCRC(); + void tst_MessageBuilder_getHeader(); + void tst_MessageBuilder_buildFrames_addActionId(); + void tst_MessageBuilder_buildFrames_addData(); + void tst_MessageBuilder_buildFrames_eLenCanFrame(); + + void tst_MessageDispatcher_actionTransmit(); + void tst_MessageDispatcher_actionTransmit_Unknown(); + + void tst_AlarmGenerator_setBits_OutOfRange(); +}; Index: unittests/tst_models.cpp =================================================================== diff -u --- unittests/tst_models.cpp (revision 0) +++ unittests/tst_models.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,4884 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_models.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#include "tst_models.h" + +// Qt + +// Project +#include "MTreatmentAdjustBloodDialysateResponse.h" +#include "MTreatmentAdjustDurationResponse.h" +#include "MTreatmentRangesData.h" +#include "MAdjustPowerOff.h" + +#include "MDGDrainPumpData.h" +#include "MDGHeatersData.h" +#include "MDGLoadCellReadingsData.h" +#include "MDGOperationModeData.h" +#include "MDGPressuresData.h" +#include "MDGReservoirData.h" +#include "MDGROPumpData.h" +#include "MDGTemperaturesData.h" +#include "MDGValvesStatesData.h" + +#include "MHDOperationModeData.h" +#include "MTreatmentStatesData.h" +#include "MTreatmentOutletFlowData.h" +#include "MPreTreatmentAdjustParametersValidationResponse.h" +#include "MPreTreatmentAdjustInitTreatmentResponse.h" +#include "MTreatmentTimeData.h" +#include "MTreatmentPressureOcclusionData.h" +#include "MTreatmentSalineData.h" +#include "MPreTreatmentDisposablesPrimeData.h" + +#include "MTreatmentAdjustUltrafiltrationStateResponse.h" +#include "MTreatmentAdjustUltrafiltrationEditResponse.h" +#include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" +#include "MTreatmentAdjustPressuresLimitsResponse.h" +#include "MTreatmentAdjustSalineResponse.h" +#include "MTreatmentAdjustHeparinResponse.h" +#include "MUIBloodPressureData.h" + +#include "MAlarmStatusData.h" +#include "MAlarmTriggered.h" +#include "MAlarmCleared.h" +#include "MAlarmClearedCondition.h" + +#include "MPreTreatmentAdjustParametersValidationResponse.h" +#include "MPreTreatmentAdjustInitTreatmentResponse.h" + +#include "MessageInterpreter.h" + + +using namespace Can; + +#undef CONSOLEOUT + +/*! + * \brief tst_models::tst_models + * \details Constructor + * \param parent - QObject parent owner object. + * Qt handles the children destruction by their parent objects life-cycle. + */ +tst_models::tst_models(QObject *parent) : QObject(parent) {} + +void tst_models::tst_MAdjustBloodDialysateResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mBloodRate ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mBloodRate ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mBloodRate ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mBloodRate ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDialysateRate ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDialysateRate ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDialysateRate ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDialysateRate ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} + +void tst_models::tst_MAdjustBloodDialysateResponse () +{ + Model::MAdjustBloodDialysateResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mBloodRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDialysateRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +void tst_models::tst_MTreatmentRanges_data() +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mDuration_Min ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mDuration_Min ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mDuration_Min ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mDuration_Min ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mDuration_Max ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mDuration_Max ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mDuration_Max ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mDuration_Max ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mUltrafiltration_Volume_Min")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mUltrafiltration_Volume_Min")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mUltrafiltration_Volume_Min")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mUltrafiltration_Volume_Min")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mUltrafiltration_Volume_Max")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mUltrafiltration_Volume_Max")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mUltrafiltration_Volume_Max")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mUltrafiltration_Volume_Max")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mDialysate_Flow_Min ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mDialysate_Flow_Min ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mDialysate_Flow_Min ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mDialysate_Flow_Min ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mDialysate_Flow_Max ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mDialysate_Flow_Max ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mDialysate_Flow_Max ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mDialysate_Flow_Max ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); +} + +void tst_models::tst_MTreatmentRanges() +{ + Model::MTreatmentRanges mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mDuration_Min ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mDuration_Max ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mUltrafiltration_Volume_Min; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mUltrafiltration_Volume_Max; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mDialysate_Flow_Min ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mDialysate_Flow_Max ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Duration Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDurationResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} + +void tst_models::tst_MAdjustDurationResponse () +{ + Model::MAdjustDurationResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mUFVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration Init Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustUltrafiltrationInitResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} + +void tst_models::tst_MAdjustUltrafiltrationInitResponse () +{ + Model::MAdjustUltrafiltrationInitResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration State Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustUltrafiltrationStateResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mState ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mState ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mState ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mState ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} + +void tst_models::tst_MAdjustUltrafiltrationStateResponse () +{ + Model::MAdjustUltrafiltrationStateResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mUFState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration Edit Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustUltrafiltrationEditResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mDurationDiff ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mDurationDiff ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mDurationDiff ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mDurationDiff ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mRate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mRate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mRate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mRate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mRateDiff ")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mRateDiff ")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mRateDiff ")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mRateDiff ")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mRateOld ")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mRateOld ")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mRateOld ")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mRateOld ")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); +} + +void tst_models::tst_MAdjustUltrafiltrationEditResponse () +{ + Model::MAdjustUltrafiltrationEditResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mDurationDiff ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mRateDiff ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mRateOld ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration Confirm Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustUltrafiltrationConfirmResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mVolume ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDuration ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mRate ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mRate ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mRate ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mRate ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); +} + +void tst_models::tst_MAdjustUltrafiltrationConfirmResponse () +{ + Model::MAdjustUltrafiltrationConfirmResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Pressures Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPressuresLimitsResponse_data() +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mArterialPressureLimitWindow ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mArterialPressureLimitWindow ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mArterialPressureLimitWindow ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mArterialPressureLimitWindow ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mVenousPressureLimitWindow ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mVenousPressureLimitWindow ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mVenousPressureLimitWindow ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mVenousPressureLimitWindow ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mVenousPressureLimitAsymtrc ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mVenousPressureLimitAsymtrc ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mVenousPressureLimitAsymtrc ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mVenousPressureLimitAsymtrc ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); +} + +void tst_models::tst_MAdjustPressuresLimitsResponse() +{ + Model::MAdjustPressuresLimitsResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mArterialPressureLimitWindow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mVenousPressureLimitWindow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mVenousPressureLimitAsymtrc ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGROPumpData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mTgtFlowRate ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mTgtFlowRate ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mTgtFlowRate ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mTgtFlowRate ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mFBPWM ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mFBPWM ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mFBPWM ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mFBPWM ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGROPumpData() { + Model::MDGROPump mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mPWM ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTgtFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mFBPWM ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGPressuresData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mBarometricPSI ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mBarometricPSI ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mBarometricPSI ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mBarometricPSI ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGPressuresData() { + Model::MDGPressures mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mROInletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mROOutletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDrainInletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDrainOutletPSI; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mBarometricPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGDrainPumpData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mRPMI ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mRPMI ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mRPMI ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mRPMI ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mRPMO ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mRPMO ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mRPMO ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mRPMO ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mTargetFLPMO ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mTargetFLPMO ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mTargetFLPMO ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mTargetFLPMO ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mCurrentA ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mCurrentA ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mCurrentA ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mCurrentA ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mDirection ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mDirection ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mDirection ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mDirection ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mMaxonRPM ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mMaxonRPM ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mMaxonRPM ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mMaxonRPM ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGDrainPumpData() { + Model::MDGDrainPump mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRPMI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mDAC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mRPMO ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTargetFLPMO ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mCurrentA ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mDirection ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mMaxonRPM ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGOperationMode_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGOperationMode() { + Model::MDGOperationMode mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mOpMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mSubMode; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGReservoirData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mTimeReservoirCycleMS ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mTimeReservoirCycleMS ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mTimeReservoirCycleMS ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mTimeReservoirCycleMS ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mTimeReservoirFill2SwitchMS ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mTimeReservoirFill2SwitchMS ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mTimeReservoirFill2SwitchMS ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mTimeReservoirFill2SwitchMS ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mTimeUFDecayMS ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mTimeUFDecayMS ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mTimeUFDecayMS ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mTimeUFDecayMS ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mTempUFFill ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mTempUFFill ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mTempUFFill ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mTempUFFill ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mTempReservoirUseActual ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mTempReservoirUseActual ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mTempReservoirUseActual ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mTempReservoirUseActual ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mTempReservoirEndFill ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mTempReservoirEndFill ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mTempReservoirEndFill ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mTempReservoirEndFill ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mTempAvgFill ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mTempAvgFill ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mTempAvgFill ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mTempAvgFill ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + QTest::newRow("mTempLastFill ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mTempLastFill ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); + QTest::newRow("mTempLastFill ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); + QTest::newRow("mTempLastFill ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); + QTest::newRow("mTimereservoirFill ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B")); + QTest::newRow("mTimereservoirFill ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C")); + QTest::newRow("mTimereservoirFill ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D")); + QTest::newRow("mTimereservoirFill ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGReservoirData() { + Model::MDGReservoir mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mActiveReservoir ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mFillToVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDrainToVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mTimeReservoirCycleMS ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTimeReservoirFill2SwitchMS ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mTimeUFDecayMS ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mTempUFFill ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mTempReservoirUseActual ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mTempReservoirEndFill ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mTempAvgFill ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mTempLastFill ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mTimereservoirFill ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGValvesStates_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + + int lastFlag = 0; + int errorIndex = 1; + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mStates" , errorIndex++, 1, 16); // adding 16 rows for the two bytes of data for the states flag + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVRf" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVRi" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mRes" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVRo" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVPo" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVBf" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVRc" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVDr" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVPi" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVSP" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVR1" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVR2" , errorIndex++, lastFlag + 1); + lastFlag = HelperFunctions_tstModel::generate_bitDataRow("mVPd" , errorIndex++, lastFlag + 1); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGValvesStates() { + Model::MDGValvesStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = errorIndex+1; + int index = errorIndex+1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + // The mStates param contains 2byte of data or 16 bits of states + case 1: { index = index * sizeof mData._data.mStates/8 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + // All of these are single byte types (u8) + case 2: { index = index * sizeof mData._data.mVRf ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mVRi ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mRes ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mVRo ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mVPo ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mVBf ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mVRc ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mVDr ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mVPi ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mVSP ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mVR1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mVR2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + // The test data is set up in bits and we are testing for bytes, when we reach the last case, the + // fromByteArray function returns true even though we have a partial byte filled out, the remainder/"missing" bits are 0 + case 14: { index = index * sizeof mData._data.mVPd ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGHeatersData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F" "30" "31" "32" "33")); + QTest::newRow("mMainPrimayHeaterDC ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mMainPrimayHeaterDC ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mMainPrimayHeaterDC ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mMainPrimayHeaterDC ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mSmallPrimaryHeaterDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mSmallPrimaryHeaterDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mSmallPrimaryHeaterDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mSmallPrimaryHeaterDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mTrimmerHeaterDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mTrimmerHeaterDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mTrimmerHeaterDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mTrimmerHeaterDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mPrimaryTargetTemp ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mPrimaryTargetTemp ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mPrimaryTargetTemp ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mPrimaryTargetTemp ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mTrimmerTargetTemp ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mTrimmerTargetTemp ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mTrimmerTargetTemp ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mTrimmerTargetTemp ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mPrimaryHeaterState ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mPrimaryHeaterState ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mPrimaryHeaterState ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mPrimaryHeaterState ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mTrimmerHeaterState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mTrimmerHeaterState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mTrimmerHeaterState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mTrimmerHeaterState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mPrimaryEfficiency ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mPrimaryEfficiency ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mPrimaryEfficiency ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mPrimaryEfficiency ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mPrimaryCalcTargetTemp ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mPrimaryCalcTargetTemp ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mPrimaryCalcTargetTemp ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mPrimaryCalcTargetTemp ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mTrimmerCalcCurrentTemp ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mTrimmerCalcCurrentTemp ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mTrimmerCalcCurrentTemp ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mTrimmerCalcCurrentTemp ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + QTest::newRow("mTrimmerUseLastDC ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mTrimmerUseLastDC ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); + QTest::newRow("mTrimmerUseLastDC ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); + QTest::newRow("mTrimmerUseLastDC ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); + QTest::newRow("mTrimmerPreviousFlow ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B")); + QTest::newRow("mTrimmerPreviousFlow ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C")); + QTest::newRow("mTrimmerPreviousFlow ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D")); + QTest::newRow("mTrimmerPreviousFlow ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E")); + QTest::newRow("mTrimmerContolCounter ") << 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F")); + QTest::newRow("mTrimmerContolCounter ") << 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F" "30")); + QTest::newRow("mTrimmerContolCounter ") << 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F" "30" "31")); + QTest::newRow("mTrimmerContolCounter ") << 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F" "30" "31" "32")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGHeatersData() { + Model::MDGHeaters mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mMainPrimayHeaterDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mSmallPrimaryHeaterDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mTrimmerHeaterDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mPrimaryTargetTemp ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTrimmerTargetTemp ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mPrimaryHeaterState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mTrimmerHeaterState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mPrimaryEfficiency ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPrimaryCalcTargetTemp ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mTrimmerCalcCurrentTemp; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mTrimmerUseLastDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mTrimmerPreviousFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mTrimmerContolCounter ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGLoadCellReadingsData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGLoadCellReadingsData() { + Model::MDGLoadCellReadings mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mReservoir1Prim; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReservoir1Bkup; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mReservoir2Prim; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mReservoir2Bkup; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGTemperaturesData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mInletPrimaryHeater ", + "mHeatDisinfect ", + "mOutletPrimaryHeater ", + "mConductivitySensor1 ", + "mConductivitySensor2 ", + "mOutletRedundancy ", + "mInletDialysate ", + "mPrimaryHeaterThermoCouple ", + "mTrimmerHeaterThermoCouple ", + "mPrimaryHeaterColdJunction ", + "mTrimmerHeaterColdJunction ", + "mPrimaryHeaterInternal ", + "mTrimmerHeaterInternal ", + "mFpgaBoard ", + "mLoadCellA1B1 ", + "mLoadCellA2B2 ", + "mInternalTHDORTD ", + "mInternalTDIRTD ", + "mInteralTHDRTD ", + "mInternalCondSnsrTemp ", + "mBaroTempSensor ", + "mDialysateInletMvngAvg ", + "mRedundantOutletMvngAvg " + + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGTemperaturesData() { + Model::MDGTemperatures mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mInletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mHeatDisinfect ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mOutletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mConductivitySensor1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mConductivitySensor2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mOutletRedundancy ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mInletDialysate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mPrimaryHeaterThermoCouple; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mTrimmerHeaterThermoCouple; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mPrimaryHeaterColdJunction; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mTrimmerHeaterColdJunction; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mPrimaryHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mTrimmerHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 14: { index = index * sizeof mData._data.mFpgaBoard ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 15: { index = index * sizeof mData._data.mLoadCellA1B1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 16: { index = index * sizeof mData._data.mLoadCellA2B2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 17: { index = index * sizeof mData._data.mInternalTHDORTD ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 18: { index = index * sizeof mData._data.mInternalTDIRTD ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 19: { index = index * sizeof mData._data.mInteralTHDRTD ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 20: { index = index * sizeof mData._data.mInternalCondSnsrTemp ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 21: { index = index * sizeof mData._data.mBaroTempSensor ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 22: { index = index * sizeof mData._data.mDialysateInletMvngAvg ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 23: { index = index * sizeof mData._data.mRedundantOutletMvngAvg ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentStateData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mSalineState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mSalineState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mSalineState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mSalineState ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mHeparinState") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mHeparinState") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mHeparinState") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mHeparinState") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mRinsebackState ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mRinsebackState ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mRinsebackState ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mRinsebackState ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mRecirculateState") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mRecirculateState") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mRecirculateState") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mRecirculateState") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mBloodPrimeState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mBloodPrimeState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mBloodPrimeState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mBloodPrimeState ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mTreatmentEndState ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mTreatmentEndState ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mTreatmentEndState ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mTreatmentEndState ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mTreatmentStopState ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mTreatmentStopState ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mTreatmentStopState ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mTreatmentStopState ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mDialysisState ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mDialysisState ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mDialysisState ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mDialysisState ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentStateData() { + Model::MTreatmentStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mSubMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mUFState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mSalineState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mHeparinState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mRinsebackState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mRecirculateState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mBloodPrimeState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mTreatmentEndState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mTreatmentStopState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mDialysisState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDOperationModeData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mSubMode ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDOperationModeData() { + Model::MHDOperationMode mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mOpMode; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mSubMode; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MOutletFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30" "31" "32" "33" "34")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mDopCorrOffset ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mDopCorrOffset ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mDopCorrOffset ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mDopCorrOffset ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mDopCalcRate ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mDopCalcRate ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mDopCalcRate ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mDopCalcRate ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mUfCalcRate ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mUfCalcRate ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mUfCalcRate ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mUfCalcRate ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + QTest::newRow("mRotorHall ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mRotorHall ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); + QTest::newRow("mRotorHall ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); + QTest::newRow("mRotorHall ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); + QTest::newRow("mCurrentSetUFRate")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C")); + QTest::newRow("mCurrentSetUFRate")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D")); + QTest::newRow("mCurrentSetUFRate")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E")); + QTest::newRow("mCurrentSetUFRate")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F")); + QTest::newRow("mDialOutPumpState")<< 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30")); + QTest::newRow("mDialOutPumpState")<< 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30" "31")); + QTest::newRow("mDialOutPumpState")<< 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30" "31" "32")); + QTest::newRow("mDialOutPumpState")<< 13 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2B" "2C" "2D" "2E" "2F" "30" "31" "32" "33")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MOutletFlowData() { + Model::MOutletFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRefUFVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasUFVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDtCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mDopCorrOffset ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mDopCalcRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mUfCalcRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mRotorHall ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mCurrentSetUFRate; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mDialOutPumpState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MBloodFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" )); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MBloodFlowData() { + Model::MBloodFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mFlowSetPoint ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasuredFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDutyCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mRotorCount ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPresFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mRotorHall ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDialysateFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mRotorCount ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mPresFlow ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mRotorHall ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDialysateFlowData() { + Model::MDialysateFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mFlowSetPoint ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasuredFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDutyCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mRotorCount ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPresFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mRotorHall ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentTimeData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentTimeData() { + Model::MTreatmentTime mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mElapsed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRemaining; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPressureOcclusionData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mPressureLimitState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mPressureLimitState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mPressureLimitState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mPressureLimitState ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mArterialLimitLow ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mArterialLimitLow ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mArterialLimitLow ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mArterialLimitLow ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mArterialLimitHigh ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mArterialLimitHigh ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mArterialLimitHigh ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mArterialLimitHigh ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mVenousLimitLow ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mVenousLimitLow ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mVenousLimitLow ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mVenousLimitLow ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mVenousLimitHigh") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mVenousLimitHigh") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mVenousLimitHigh") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mVenousLimitHigh") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mArtLongFilter") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mArtLongFilter") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mArtLongFilter") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" )); + QTest::newRow("mArtLongFilter") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" )); + QTest::newRow("mVenousLongFilter") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" )); + QTest::newRow("mVenousLongFilter") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mVenousLongFilter") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mVenousLongFilter") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + QTest::newRow("mBloodOcclLongFilter") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mBloodOcclLongFilter") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); + QTest::newRow("mBloodOcclLongFilter") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); + QTest::newRow("mBloodOcclLongFilter") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); + QTest::newRow("mPartialOcclBaseline") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B")); + QTest::newRow("mPartialOcclBaseline") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C")); + QTest::newRow("mPartialOcclBaseline") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D")); + QTest::newRow("mPartialOcclBaseline") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPressureOcclusionData() { + Model::MPressureOcclusion mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mArterialPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mVenousPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mBloodPumpOcclusion ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mPressureLimitState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mArterialLimitLow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mArterialLimitHigh ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mVenousLimitLow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mVenousLimitHigh ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mArtLongFilter ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mVenousLongFilter ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mBloodOcclLongFilter ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mPartialOcclBaseline ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPowerOff_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mStatus ") << 1 << QByteArray::fromHex(QByteArray()); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPowerOff() { + Model::MPowerOff mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mStatus; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +void tst_models::tst_MAlarmStatus_text() +{ + + for (int i = 1; i < Gui::GuiAlarmID::NUM_OF_ALARM_IDS; ++i) { + QVERIFY(!Model::MAlarmStatus::toText(Gui::GuiAlarmID(i)).isEmpty()); + } + + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(0)), tr("")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(-1)), tr("ALARM_ID_UNDEFINED [-1]")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(599)), tr("ALARM_ID_UNDEFINED [599]")); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmStatus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmStatus data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmStatus_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mState ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mState ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mState ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mState ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mTop ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mTop ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mTop ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mTop ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mEscalatesIn") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mEscalatesIn") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mEscalatesIn") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mEscalatesIn") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMuteTimeout") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMuteTimeout") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMuteTimeout") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMuteTimeout") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mFlags ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mFlags ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmStatus test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmStatus() { + Model::MAlarmStatus mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mTop ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mEscalatesIn; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMuteTimeout; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mFlags ; QVERIFY (! mData.fromByteArray(data)); /*GetBits does not need this */} break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmTriggered ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmTriggered data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmTriggered_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + + // The first 20Bytes of the data is for MAbstractDynamic before getting to the alarm triggered data + const QByteArray front20Bytes = QByteArray("00" "00" "00" "01" + "00" "00" "00" "02" + "00" "00" "00" "03" + "00" "00" "00" "04" + "00" "00" "00" "05" + ); + // 20 front bytes + 3 parameters * 4 bytes + 1 byte ending = 20 + 3*4 + 1 bytes + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(20 + 3*4 + 1))<<0; + + for(int i=0; i< 4; i++) + { + QTest::newRow("mPriority ") << 21 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i ))) << 20; + QTest::newRow("mRank ") << 22 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i+4))) << 24; + QTest::newRow("mClearTop ") << 23 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i+8))) << 28; + } +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmTriggered test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +// This will also test the MAbstractDynamic class' +void tst_models::tst_MAlarmTriggered() { + Model::MAlarmTriggered mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 21: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 22: { index = index * sizeof mData._xata.mRank ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 23: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAbstractDynamic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAbstractDynamic data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAbstractDynamic_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + QTest::addColumn("expectedParameters"); + + const QByteArray testFieldDescriptor1_U1 = QByteArray("00" "00" "00" "01" // mID + "01" "00" "00" "00" // mFieldDescriptor1 + ); + const QByteArray testFieldDescriptor1_S1 = QByteArray("00" "00" "00" "01" // mID + "02" "00" "00" "00" // mFieldDescriptor1 + ); + const QByteArray testFieldDescriptor1_F1 = QByteArray("00" "00" "00" "01" // mID + "03" "00" "00" "00" // mFieldDescriptor1 + ); + const QByteArray testFieldDescriptor1_BL = QByteArray("00" "00" "00" "01" // mID + "04" "00" "00" "00" // mFieldDescriptor1 + ); + + const QByteArray testFieldDescriptor2 = QByteArray("00" "00" "00" "01" // mID + "01" "00" "00" "00" // mFieldDescriptor1 + "02" "00" "00" "00" // mDataFieldU1 + ); + const QByteArray testFieldDescriptor2_U2 = QByteArray().append(testFieldDescriptor2).append("01" "00" "00" "00"); // mFieldDescriptor2 + const QByteArray testFieldDescriptor2_S2 = QByteArray().append(testFieldDescriptor2).append("02" "00" "00" "00"); // mFieldDescriptor2 + const QByteArray testFieldDescriptor2_F2 = QByteArray().append(testFieldDescriptor2).append("03" "00" "00" "00"); // mFieldDescriptor2 + const QByteArray testFieldDescriptor2_BL = QByteArray().append(testFieldDescriptor2).append("04" "00" "00" "00"); // mFieldDescriptor2 + + // ------------------------------------------------------------------ + // These data set are for testing the incomplete data, getting into the false case of GetValue() + // ------------------------------------------------------------------ + // test 1 to test x does not test MAbstractDynamic's parameters(), thus the expectedParameters are empty + // 20 front bytes + 3 parameters * 4 bytes + 1 byte ending = 20 + 3*4 + 1 bytes + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(20 + 3*4 + 1)) << 0 << QVariantList(); + QTest::newRow("msg mFieldDescriptor2 default Type case") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2)).append("00" "00" "00" "00") << 20 << QVariantList(); + QTest::newRow("msg mFieldDescriptor2 None Type case") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2).append("00" "00" "00" "00")) << 20 << QVariantList(); + + const int numberIncompleteBytes = 3; // each field has 4 bytes to complete it, to hit the "incomplete" condition, we need to account for 3 front bytes + for(int byteCount = 1; byteCount <= numberIncompleteBytes; byteCount++) + { + QTest::newRow("msg incomplete mID") << 1 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(byteCount)) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor1") << 1 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(byteCount+4)) << 0 << QVariantList(); + + // mFieldDescriptor1 subFields + QTest::newRow("msg incomplete mFieldDescriptor1 mDataFieldU1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor1_U1).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor1 mDataFieldS1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor1_S1).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor1 mDataFieldF1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor1_F1).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor1 mDataFieldBL") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor1_BL).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + + // mFieldDescriptor2 subFields + QTest::newRow("msg incomplete mFieldDescriptor2 mDataFieldU1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2_U2).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor2 mDataFieldS1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2_S2).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor2 mDataFieldF1") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2_F2).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + QTest::newRow("msg incomplete mFieldDescriptor2 mDataFieldBL") << 1 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2_BL).append(HelperFunctions_tstModel::createByteDataArray(byteCount))) << 0 << QVariantList(); + } + + // ------------------------------------------------------------------ + // These data set are for testing the parameters() unreached cases + // ------------------------------------------------------------------ + quint32 zero = 0; + QVariantList testParameterFieldDescriptor2; + testParameterFieldDescriptor2 << 16777216 // mID + << 1 // mFieldDescriptor1 + << 2 // mDataFieldU1 + << zero << zero // values added for the default case in the field type switch statement + << zero << zero << zero; // the rank, priority, and cleartop + QTest::newRow("msg parameters - mFieldDescriptor2 none Type case") << 2 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2).append("00" "00" "00" "00")) << 20 << testParameterFieldDescriptor2; + QTest::newRow("msg parameters - mFieldDescriptor2 default Type case") << 2 << QByteArray::fromHex(QByteArray().append(testFieldDescriptor2).append("00" "00" "00" "01")) << 20 << testParameterFieldDescriptor2; + + QVariantList testParameterFieldDescriptor1; + testParameterFieldDescriptor1 << 16777216 // mID + << zero // mFieldDescriptor1 + << zero << zero << zero // values added for the default case in the field type switch statement + << zero << zero << zero; // the rank, priority, and cleartop + QTest::newRow("msg parameters - mFieldDescriptor1 default Type case") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "01" // mID + "00" "00" "00" "01" // mFieldDescriptor1 + )) << 20 << testParameterFieldDescriptor1; + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAbstractDynamic test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +// Will be testing MAbstractDynamic using MAlarmTriggered since MAlarmTriggered derives from MAbstractDynamic +void tst_models::tst_MAbstractDynamic() { + Model::MAlarmTriggered mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + QFETCH(QVariantList, expectedParameters); + + int startIndex = 0; +// int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + + // case 0 is for "complete" data tests + case 0: { QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + // case 1 is for "incomplete" data tests / partial byte set (ie: 3 bytes of 4 bytes of U32 exists) + case 1: { QVERIFY ( !mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + // case 2 is testing parameters() call + case 2: + { + const QVariantList list = mData.parameters(); + bool sameLength = list.length() == expectedParameters.length(); + QVERIFY (sameLength); + if(sameLength){ + for(int i=0; i < mData.parameters().length(); i++) + { + QVERIFY(list.at(i) == expectedParameters.at(i)); + } + } + + } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmCleared ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmCleared data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmCleared_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mAlarmID ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAlarmID ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAlarmID ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAlarmID ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmCleared test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmCleared() { + Model::MAlarmCleared mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAlarmID; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp data definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentParametersResp_data() +{ + HelperFunctions_tstModel::generate_ByteDataSet( { + "mAccepted ", + "mBloodFlowRate ", + "mDialysateFlowRate ", + "mDuration ", + "mHeparinStopTime ", + "mSalineBolus ", + "mAcidConcentrate ", + "mBicarbonateConcentrate ", + "mDialyzerType ", + "mHeparinType ", + "mBloodPressureMeasureInterval ", + "mRinsebackFlowRate ", + "mArterialPressureLimitWindow ", + "mVenousPressureLimitWindow ", + "mVenousPressureLimitAsymtrc ", + "mHeparinDispensingRate ", + "mHeparinBolusVolume ", + "mDialysateTemp " + }); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentParametersResp test definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentParametersResp() +{ + Model::MAdjustParametersValidationResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << "index: " << index << "\n" + << "errorIndex: " << errorIndex << "\n" + << "startIndex: " << startIndex << "\n" + << "ok: " << ok << "\n" + << "data: " << data; +#endif + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 2: { index = index * sizeof mData._data.mBloodFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 3: { index = index * sizeof mData._data.mDialysateFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 4: { index = index * sizeof mData._data.mDuration ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 5: { index = index * sizeof mData._data.mHeparinStopTime ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 6: { index = index * sizeof mData._data.mSalineBolus ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 7: { index = index * sizeof mData._data.mAcidConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 8: { index = index * sizeof mData._data.mBicarbonateConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 9: { index = index * sizeof mData._data.mDialyzerType ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 10: { index = index * sizeof mData._data.mHeparinType ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 11: { index = index * sizeof mData._data.mBloodPressureMeasureInterval ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 12: { index = index * sizeof mData._data.mRinsebackFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 13: { index = index * sizeof mData._data.mArterialPressureLimitWindow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 14: { index = index * sizeof mData._data.mVenousPressureLimitWindow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 15: { index = index * sizeof mData._data.mVenousPressureLimitAsymtrc ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 16: { index = index * sizeof mData._data.mHeparinDispensingRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 17: { index = index * sizeof mData._data.mHeparinBolusVolume ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 18: { index = index * sizeof mData._data.mDialysateTemp ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + + default: QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentmSalineBolusData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentmSalineBolusData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentSalineBolusData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentmSalineBolusData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentSalineBolusData() { + Model::MTreatmentSaline mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCumulative; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDelivered ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentHeparinData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentHeparinData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentHeparinData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mCumulative ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mCumulative ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mCumulative ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mCumulative ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mTarget ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mTarget ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mTarget ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mTarget ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentHeparinData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentHeparinData() { + Model::MTreatmentHeparin mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mCumulative; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentPrime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentPrime data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPreTreatmentPrime_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("timeout ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("timeout ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("timeout ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("timeout ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("countdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("countdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("countdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("countdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentPrime test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPreTreatmentPrime() { + Model::MPreTreatmentDisposablesPrime mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTimeout ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCountdown ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustInitTreatmentResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustInitTreatmentResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustInitTreatmentResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustInitTreatmentResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustInitTreatmentResponse() { + Model::MAdjustInitTreatmentResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MmSalineBolusResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MmSalineBolusResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHeparinResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHeparinResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHeparinResponse() { + Model::MAdjustHeparinResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentLogResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentLogResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustTreatmentLogResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mAccepted" , + "mReason" , + "mBloodFlowRate" , + "mDialysateFlowRate" , + "mTreatmentDuration" , + "mActualTreatmentDuration" , + "mAcidConcentrateType" , + "mBicarbonateConcentrateType", + "mPotassiumConcentration" , + "mCalciumConcentration" , + "mBicarbonateConcentration" , + "mSodiumConcentration" , + "mDialysateTemperature" , + "mDialyzerType" , + "mTreatmentStartEpoch" , + "mTreatmentEndEpoch" , + "mAverageBloodFlow" , + "mAverageDialysateFlow" , + "mDialysateVolumeUsed" , + "mAverageDialysateTemp" , + "mOriginUFVolume" , + "mTargetUFVolume" , + "mActualUFVolume" , + "mOriginUFRate" , + "mTargetUFRate" , + "mActualUFRate" , + "mSalineBolusVolume" , + "mHeparinBolusVolume" , + "mHeparinDispenseRate" , + "mHeparinStop" , + "mHeparinDeliveredVolume" , + "mHeparinType" , + "mAverageArterialPressure" , + "mAverageVenousPressure" , + "mDeviceID" , + "mWaterSampleTestResult" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentLogResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustTreatmentLogResponse() { + Model::MAdjustTreatmentLogResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mBloodFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDialysateFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTreatmentDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mActualTreatmentDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mAcidConcentrateType ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mBicarbonateConcentrateType; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPotassiumConcentration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mCalciumConcentration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mBicarbonateConcentration; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mSodiumConcentration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mDialysateTemperature ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 14: { index = index * sizeof mData._data.mDialyzerType ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 15: { index = index * sizeof mData._data.mTreatmentStartEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 16: { index = index * sizeof mData._data.mTreatmentEndEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 17: { index = index * sizeof mData._data.mAverageBloodFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 18: { index = index * sizeof mData._data.mAverageDialysateFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 19: { index = index * sizeof mData._data.mDialysateVolumeUsed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 20: { index = index * sizeof mData._data.mAverageDialysateTemp ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 21: { index = index * sizeof mData._data.mOriginUFVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 22: { index = index * sizeof mData._data.mTargetUFVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 23: { index = index * sizeof mData._data.mActualUFVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 24: { index = index * sizeof mData._data.mOriginUFRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 25: { index = index * sizeof mData._data.mTargetUFRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 26: { index = index * sizeof mData._data.mActualUFRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 27: { index = index * sizeof mData._data.mSalineBolusVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 28: { index = index * sizeof mData._data.mHeparinBolusVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 29: { index = index * sizeof mData._data.mHeparinDispenseRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 30: { index = index * sizeof mData._data.mHeparinStop ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 31: { index = index * sizeof mData._data.mHeparinDeliveredVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 32: { index = index * sizeof mData._data.mHeparinType ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 33: { index = index * sizeof mData._data.mAverageArterialPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 34: { index = index * sizeof mData._data.mAverageVenousPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 35: { index = index * sizeof mData._data.mDeviceID ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 36: { index = index * sizeof mData._data.mWaterSampleTestResult ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDSyringePump ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDSyringePump data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDSyringePump_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mSyringePumpState " , + "mHeparinState" , + "mSetRate" , + "mMeasuredRate" , + "mSyringePumpPosition" , + "mVolumeDelivered" , + "mMeasuredHome" , + "mMeasuredSwitch" , + "mMeasuredForce" , + "mSafetyVol" , + "mStatus" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDSyringePump test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDSyringePump() { + Model::MHDSyringePump mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mSyringePumpState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mHeparinState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mSetRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMeasuredRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mSyringePumpPosition ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mVolumeDelivered ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mMeasuredHome ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mMeasuredSwitch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mMeasuredForce ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mSafetyVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDBloodLeakData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDBloodLeakData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDBloodLeakData_data () { + HelperFunctions_tstModel::generate_ByteDataSet({"mBloodLeakStatus", "mBloodLeakState", "mBloodLeakPersistentCounter", "mBloodLeakSerialCommState"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDBloodLeakData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDBloodLeakData() { + Model::MHDBloodLeakData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mBloodLeakStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mBloodLeakState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mBloodLeakPersistentCounter ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mBloodLeakSerialCommState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirTrapData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirTrapData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDAirTrapData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAirTrapLowerLevel", "mAirTrapUpperLevel", "mAirTrapRawLowerLevel", "mAirTrapRawUpperLevel" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirTrapData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDAirTrapData() { + Model::MHDAirTrapData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAirTrapLowerLevel ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mAirTrapUpperLevel ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mAirTrapRawLowerLevel ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mAirTrapRawUpperLevel ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAccelerometer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAccelerometer data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDAccelerometer_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mX" , + "mY" , + "mZ" , + "mXMax" , + "mYMax" , + "mZMax" , + "mXTilt", + "mYTilt", + "mZTilt" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAccelerometer test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDAccelerometer() { + Model::MHDAccelerometer mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mX ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mY ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mZ ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mXMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mYMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mZMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mXTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mYTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mZTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDUsageInfoResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDUsageInfoResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDUsageInfoResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + + int errorIndex = 1; + int lastCount = 0; + + // The "msg complete" has a total of 4*4+2 bytes since four 32-bits (or 4-bytes) and one 16-bits ( or 2 byte) + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(4*4+2))<< 0; + + // These parameters are U32 + lastCount = HelperFunctions_tstModel::addRowsForByteData("mTotalTxHours ", errorIndex, 0, (errorIndex-1)*4); errorIndex++; + lastCount = HelperFunctions_tstModel::addRowsForByteData("mTotalTxHoursSinceLastService ", errorIndex, lastCount+1, (errorIndex-1)*4); errorIndex++; + lastCount = HelperFunctions_tstModel::addRowsForByteData("mEpochOfStartOfLastTx ", errorIndex, lastCount+1, (errorIndex-1)*4); errorIndex++; + lastCount = HelperFunctions_tstModel::addRowsForByteData("mEpochOfLastRecordReset ", errorIndex, lastCount+1, (errorIndex-1)*4); errorIndex++; + + // This parameter is U16 + // This function adds eight 1-bit incremented rows. + lastCount = HelperFunctions_tstModel::addTestDataRow_bitRows("mCrc", errorIndex, (errorIndex-1)*4*8, (errorIndex-1)*4); + + return; +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDUsageInfoResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDUsageInfoResponse() { + Model::MHDUsageInfoResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTotalTxHours ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mTotalTxHoursSinceLastService ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mEpochOfStartOfLastTx ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mEpochOfLastRecordReset ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mCrc ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirBubbleData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirBubbleData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDAirBubbleData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mVenousAirBubbleStatus", "mVenousAirBubbleState" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDAirBubbleData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDAirBubbleData() { + Model::MHDAirBubbleData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mVenousAirBubbleStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mVenousAirBubbleState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentStates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentStates data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MPreTreatmentStates_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mSubMode" , + "mWaterSampleState" , + "mSelfTestConsumablesState" , + "mSelfTestNoCartridgeState" , + "mInstallationState" , + "mSelfTestDryState" , + "mPrimeState" , + "mRecirculateState" , + "mPatientConnectionState" , + "mWetSelfTestsState" , + "mPreTreatmentRsrvrState" + }); + +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentStates test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPreTreatmentStates() { + Model::MPreTreatmentStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mSubMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mWaterSampleState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mSelfTestConsumablesState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mSelfTestNoCartridgeState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mInstallationState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mSelfTestDryState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPrimeState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mRecirculateState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPatientConnectionState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mWetSelfTestsState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mPreTreatmentRsrvrState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestNoCartridge ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestNoCartridge data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MPreTreatmentSelfTestNoCartridge_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTimeout", "mCountdown" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestNoCartridge test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPreTreatmentSelfTestNoCartridge() { + Model::MPreTreatmentSelfTestNoCartridge mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTimeout ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCountdown; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestDry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestDry data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MPreTreatmentSelfTestDry_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTimeout", "mCountdown" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPreTreatmentSelfTestDry test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPreTreatmentSelfTestDry() { + Model::MPreTreatmentSelfTestDry mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTimeout ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCountdown; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPostTreatmentStates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPostTreatmentStates data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MPostTreatmentStates_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mSubMode ", "mDrainState" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPostTreatmentStates test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPostTreatmentStates() { + Model::MPostTreatmentStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mSubMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mDrainState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStop data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentStop_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTotal", "mCountDown" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStop test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentStop() { + Model::MTreatmentStop mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCountDown; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRinseback ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRinseback data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentRinseback_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mTarget " , + "mCurrent" , + "mRate" , + "mTimeoutTotal" , + "mTimeoutCountDown" , + "mIsCompleted" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRinseback test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentRinseback() { + Model::MTreatmentRinseback mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCurrent ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mTimeoutTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mTimeoutCountDown ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mIsCompleted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRecirculate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRecirculate data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentRecirculate_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTimeoutTotal", "mTimeoutCountDown" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentRecirculate test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentRecirculate() { + Model::MTreatmentRecirculate mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTimeoutTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mTimeoutCountDown ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentBloodPrime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentBloodPrime data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentBloodPrime_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTarget", "mCurrent" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentBloodPrime test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentBloodPrime() { + Model::MTreatmentBloodPrime mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCurrent ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogEventData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogEventData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentLogEventData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mEventID" , + "mOldValue" , + "mNewValue" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogEventData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentLogEventData() { + Model::MTreatmentLogEventData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mEventID ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mOldValue ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mNewValue ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAvrgeData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAvrgeData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentLogAvrgeData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mBloodFlowRate" , + "mDialysateFlowRate", + "mUFRate" , + "mArterialPressure" , + "mVenousPressure" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAvrgeData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentLogAvrgeData() { + Model::MTreatmentLogAvrgeData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mBloodFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mDialysateFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mUFRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mArterialPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mVenousPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAlarmData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAlarmData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MTreatmentLogAlarmData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mAlarmID", + "mParam1" , + "mParam2" + } ); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentLogAlarmData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentLogAlarmData() { + Model::MTreatmentLogAlarmData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAlarmID ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mParam1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mParam2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDRTCEpochData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDRTCEpochData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MHDRTCEpochData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mEpoch" }); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDRTCEpochData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDRTCEpochData() { + Model::MHDRTCEpochData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostSingleResult ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostSingleResult data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDPostSingleResult_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mResult", "mIndex" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostSingleResult test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDPostSingleResult() { + Model::MHDPostSingleResult mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mResult ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mIndex ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostFinalResult ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostFinalResult data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDPostFinalResult_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mResult"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDPostFinalResult test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDPostFinalResult() { + Model::MHDPostFinalResult mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mResult ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDAlarmVolumeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDAlarmVolumeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustHDAlarmVolumeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDAlarmVolumeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustHDAlarmVolumeResponse() { + Model::MAdjustHDAlarmVolumeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDDateTimeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDDateTimeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustHDDateTimeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustHDDateTimeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustHDDateTimeResponse() { + Model::MAdjustHDDateTimeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceModeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceModeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceModeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceModeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceModeResponse() { + Model::MAdjustServiceModeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsHDResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsHDResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustVersionsHDResponse_data () { + + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + + int errorIndex = 1; + + // The "msg complete" has a total of 9+4 bytes since nine u8 (or 1-bytes) and one U32 ( or 4 bytes) + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(9+4))<< 0; + + QTest::newRow("mMajor") << errorIndex << QByteArray() << 0; + int currentBit = 1; + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMajor ", errorIndex++, currentBit, 1); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMinor ", errorIndex++, currentBit, 2); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMicro ", errorIndex++, currentBit, 3); + + // mBuild is U16, this requires us to add two sets of 8-bits. + // The first set of 8-bit, the expected index is data-index less 1 since it's not possible to get the full 16-bits + // yet. When we add the second byte's bits, the expected index is 5 since we are handling full bytes not partials + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mBuild ", errorIndex++, currentBit, 3); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mBuild ", errorIndex++, currentBit, 5); + + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAId ", errorIndex++, currentBit, 6); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAMajor ", errorIndex++, currentBit, 7); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAMinor ", errorIndex++, currentBit, 8); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGALab ", errorIndex++, currentBit, 9); + + // U32 parameter - expecting one short to check for "false" case only + (void) HelperFunctions_tstModel::addRowsForByteData("mCompatibilityRev", errorIndex, currentBit/8, 9); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsHDResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustVersionsHDResponse() { + Model::MAdjustVersionsHDResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + + int startIndex = 0; + int index = errorIndex; // Note: this is not being use in test, but only to show which param is being checked + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mBuild ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mFPGAId ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mFPGAMajor; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mFPGAMinor; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mFPGALab ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mFPGALab ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mCompatibilityRev ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesHDResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesHDResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceDatesHDResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mLastServiceDateEpoch", "mServiceIntervalSeconds" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesHDResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceDatesHDResponse() { + Model::MAdjustServiceDatesHDResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mLastServiceDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mServiceIntervalSeconds ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRinsebackResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRinsebackResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustRinsebackResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRinsebackResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustRinsebackResponse() { + Model::MAdjustRinsebackResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRecirculateResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRecirculateResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustRecirculateResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustRecirculateResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustRecirculateResponse() { + Model::MAdjustRecirculateResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentEndResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentEndResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustTreatmentEndResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustTreatmentEndResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustTreatmentEndResponse() { + Model::MAdjustTreatmentEndResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustSalineResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustSalineResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustSalineResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason", "mTarget"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustSalineResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustSalineResponse() { + Model::MAdjustSalineResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustWaterSampleResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustWaterSampleResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustWaterSampleResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustWaterSampleResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustWaterSampleResponse() { + Model::MAdjustWaterSampleResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustStartTreatmentResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustStartTreatmentResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustStartTreatmentResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustStartTreatmentResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustStartTreatmentResponse() { + Model::MAdjustStartTreatmentResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionConfirmResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionConfirmResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientConnectionConfirmResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionConfirmResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientConnectionConfirmResponse() { + Model::MAdjustPatientConnectionConfirmResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionBeginResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionBeginResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientConnectionBeginResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientConnectionBeginResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientConnectionBeginResponse() { + Model::MAdjustPatientConnectionBeginResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesPrimeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesPrimeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesPrimeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesPrimeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesPrimeResponse() { + Model::MAdjustDisposablesPrimeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesConfirmResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesConfirmResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesConfirmResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesConfirmResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesConfirmResponse() { + Model::MAdjustDisposablesConfirmResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectStartResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectStartResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisinfectStartResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectStartResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisinfectStartResponse() { + Model::MAdjustDisinfectStartResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectModeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectModeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisinfectModeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisinfectModeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisinfectModeResponse() { + Model::MAdjustDisinfectModeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientDisconnectionConfirmResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientDisconnectionConfirmResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientDisconnectionConfirmResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustPatientDisconnectionConfirmResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustPatientDisconnectionConfirmResponse() { + Model::MAdjustPatientDisconnectionConfirmResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesRemovalConfirmResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesRemovalConfirmResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesRemovalConfirmResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDisposablesRemovalConfirmResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDisposablesRemovalConfirmResponse() { + Model::MAdjustDisposablesRemovalConfirmResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmActiveListResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmActiveListResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MAlarmActiveListResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mAccepted" , + "mReason" , + "mAlarmID0" , + "mAlarmID1" , + "mAlarmID2" , + "mAlarmID3" , + "mAlarmID4" , + "mAlarmID5" , + "mAlarmID6" , + "mAlarmID7" , + "mAlarmID8" , + "mAlarmID9" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmActiveListResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmActiveListResponse() { + Model::MAlarmActiveListResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mAlarmID0 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mAlarmID1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mAlarmID2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mAlarmID3 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mAlarmID4 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mAlarmID5 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mAlarmID6 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mAlarmID7 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mAlarmID8 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mAlarmID9 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmClearedCondition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmClearedCondition data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmClearedCondition_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAlarmID" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmClearedCondition test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAlarmClearedCondition() { + Model::MAlarmClearedCondition mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAlarmID ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGCleaningUsageResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGCleaningUsageResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MAdjustDGCleaningUsageResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { + "mRoWaterGenTotalL" , + "mRoWaterGenSinceLastServiceL" , + "mLastBasicFlushCompleteDateEpoch" , + "mLastChemDisStartDateEpoch" , + "mLastChemDisCompleteDateEpoch" , + "mLastChemDisFlushCompleteDateEpoch" , + "mLastHeatDisCompleteDateEpoch" , + "mLastHeatActiveCoolCompleteDateEpoch" , + "mLastFilterFlushCompleteDateEpoch" , + "mLastResetTimeEpoch" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGCleaningUsageResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDGCleaningUsageResponse() { + Model::MAdjustDGCleaningUsageResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRoWaterGenTotalL ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mRoWaterGenSinceLastServiceL ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mLastBasicFlushCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mLastChemDisStartDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mLastChemDisCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mLastChemDisFlushCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mLastHeatDisCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mLastHeatActiveCoolCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mLastFilterFlushCompleteDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mLastResetTimeEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGDateTimeResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGDateTimeResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDGDateTimeResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustDGDateTimeResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustDGDateTimeResponse() { + Model::MAdjustDGDateTimeResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesDGResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesDGResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceDatesDGResponse_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mLastServiceDateEpoch", "mServiceIntervalSeconds" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustServiceDatesDGResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustServiceDatesDGResponse() { + Model::MAdjustServiceDatesDGResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mLastServiceDateEpoch ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mServiceIntervalSeconds ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsDGResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsDGResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MAdjustVersionsDGResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + + // int lastFlag = 0; + int errorIndex = 1; + + // The "msg complete" has a total of 9+4 bytes since nine u8 (or 1-bytes) and one U32 ( or 4 bytes) + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(9+4))<< 0; + + QTest::newRow("mMajor") << errorIndex << QByteArray() << 0; + int currentBit = 1; + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMajor ", errorIndex++, currentBit, 1); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMinor ", errorIndex++, currentBit, 2); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMicro ", errorIndex++, currentBit, 3); + + // mBuild is U16, this requires us to add two sets of 8-bits. + // The first set of 8-bit, the expected index is data-index less 1 since it's not possible to get the full 16-bits + // yet. When we add the second byte's bits, the expected index is 5 since we are handling full bytes not partials + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mBuild ", errorIndex++, currentBit, 3); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mBuild ", errorIndex++, currentBit, 5); + + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAId ", errorIndex++, currentBit, 6); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAMajor ", errorIndex++, currentBit, 7); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGAMinor ", errorIndex++, currentBit, 8); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFPGALab ", errorIndex++, currentBit, 9); + + // U32 parameter - expecting one short to check for "false" case only + (void) HelperFunctions_tstModel::addRowsForByteData("mCompatibilityRev", errorIndex, currentBit/8, 9); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsDGResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MAdjustVersionsDGResponse() { + Model::MAdjustVersionsDGResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + + int startIndex = 0; + int index = errorIndex; // Note: this is not being use in test, but only to show which param is being checked + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) + +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mMicro ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mBuild ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mFPGAId ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mFPGAMajor; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mFPGAMinor; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mFPGALab ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mFPGALab ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mCompatibilityRev ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetRoWaterModeDGr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetRoWaterModeDGr data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDuetRoWaterModeDGr_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted" , "mReason", "mFirmwareValue" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetRoWaterModeDGr test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDuetRoWaterModeDGr() { + Model::MDuetRoWaterModeDGr mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mFirmwareValue ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGConductivityData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGConductivityData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + +void tst_models::tst_MDGConductivityData_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mRORejectionRatio" , + "mCPi" , + "mCPo" , + "mCD1" , + "mCD2" , + "mCPiRaw" , + "mCPoRaw" , + "mCD1Raw" , + "mCD2Raw" , + "mCPiSensorStatus" , + "mCPoSensorStatus" , + "mCD1SensorStatus" , + "mCD2SensorStatus" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGConductivityData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGConductivityData() { + Model::MDGConductivityData mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRORejectionRatio ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCPi ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mCPo ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mCD1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mCD2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mCPiRaw ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mCPoRaw ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mCD1Raw ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mCD2Raw ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mCPiSensorStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mCPoSensorStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mCD1SensorStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mCD2SensorStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGAccelerometer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGAccelerometer data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGAccelerometer_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mX" , + "mY" , + "mZ" , + "mXMax" , + "mYMax" , + "mZMax" , + "mXTilt", + "mYTilt", + "mZTilt" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGAccelerometer test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGAccelerometer() { + Model::MDGAccelerometer mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mX ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mY ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mZ ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mXMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mYMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mZMax ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mXTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mYTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mZTilt; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGFilterFlush ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGFilterFlush data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGFilterFlush_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mTimeout", "mCountdown" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGFilterFlush test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGFilterFlush() { + Model::MDGFilterFlush mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTimeout ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCountdown ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostSingleResult ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostSingleResult data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGPostSingleResult_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mResult", "mIndex" }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostSingleResult test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGPostSingleResult() { + Model::MDGPostSingleResult mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mResult ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mIndex ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostFinalResult ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostFinalResult data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGPostFinalResult_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mResult"}); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDGPostFinalResult test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDGPostFinalResult() { + Model::MDGPostFinalResult mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mResult ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MUIBloodPressure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MUIBloodPressure data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MUIBloodPressure_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::addColumn("expectedIndex"); + + // int lastFlag = 0; + int errorIndex = 1; + + // The "msg complete" has a total of 7*1 + 6*2 ( seven 1-byte and six 2-byte parameters) + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(HelperFunctions_tstModel::createByteDataArray(7*1 + 6*2))<< 0; + + QTest::newRow("mMajor") << errorIndex << QByteArray() << 0; + int currentBit = 1; + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mFlags ", errorIndex++, currentBit, 1); + + // mBuild is U16, this requires us to add two sets of 8-bits. + // The first set of 8-bit, the expected index is data-index less 1 since it's not possible to get the full 16-bits + // yet. When we add the second byte's bits, the expected index is 5 since we are handling full bytes not partials + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mSystolic ", errorIndex, currentBit, 1); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mSystolic ", errorIndex++, currentBit, 3); + + // U16 + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mDiastolic ", errorIndex, currentBit, 3); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mDiastolic ", errorIndex++, currentBit, 5); + + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMeanArterial ", errorIndex, currentBit, 5); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMeanArterial ", errorIndex++, currentBit, 7); + + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mYear ", errorIndex, currentBit, 7); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mYear ", errorIndex++, currentBit, 9); + + // U8 + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMonth ", errorIndex++, currentBit, 10); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mDay ", errorIndex++, currentBit, 11); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mHour ", errorIndex++, currentBit, 12); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mMinute ", errorIndex++, currentBit, 13); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mSecond ", errorIndex++, currentBit, 14); + + // U16 + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mPulseRate ", errorIndex, currentBit, 14); + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mPulseRate ", errorIndex++, currentBit, 16); + + // U8 + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mUserId ", errorIndex++, currentBit, 17); + + // U16 - Since this is the last one, only considering the failed case of GetValue(), not handling second half of the U16 + currentBit = HelperFunctions_tstModel::addTestDataRow_bitRows("mStatus ", errorIndex, currentBit, 17); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MUIBloodPressure test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MUIBloodPressure() { + Model::MUIBloodPressure mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mFlags ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mSystolic ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDiastolic ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMeanArterial ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mYear ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMonth ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mDay ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mHour ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mMinute ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mSecond ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mPulseRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mUserId ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 13: { index = index * sizeof mData._data.mStatus ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetConfirmHDi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetConfirmHDi data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDuetConfirmHDi_data () { + HelperFunctions_tstModel::generate_ByteDataSet( { "mId" , + "mCommand" , + "mReason" + }); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDuetConfirmHDi test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDuetConfirmHDi() { + Model::MDuetConfirmHDi mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << " index " << index << " errorIndex " << errorIndex <<" startIndex "<< startIndex << " ok "<< ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mId ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCommand ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +void tst_models::tst_MAlarmAcknowledgeRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_HD_Alarm; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AlarmUserActionReq, vData, payload, canId)); +} + +void tst_models::tst_MInitTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_HD_UI; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AdjustInitTreatmentReq, vData, payload, canId)); +} + +void tst_models::tst_MConfirmTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AdjustParametersConfirmReq, vData, payload, canId)); +} + +void tst_models::tst_MEndTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Message msg; + msg.actionId = Gui::GuiActions::ID_AdjustTreatmentEndReq; + + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AdjustTreatmentEndReq, vData, payload, canId)); + QVERIFY(!interpreter.interpretMessage_HD(msg,vData)); + + // Add a value to the data list to avoid length check returning false + vData.append(0); + QVERIFY(interpreter.interpretMessage(Gui::GuiActions::ID_AdjustTreatmentEndReq, vData, payload, canId)); + QVERIFY(!interpreter.interpretMessage_HD(msg,vData)); +} + +void tst_models::tst_MAdjustmentTreatmentParametersRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Can_Id canId = Can::Can_Id::eChlid_UI_HD; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AdjustParametersValidationReq, vData, payload, canId)); +} + +void tst_models::tst_DG_headerCoverage() { + // This test is for code coverage purposes of the DG model headers + + // ----------------------------------- + // FROM model/dg/data/ + // ----------------------------------- + // MDGValvesStates + Model::MDGValvesStates mdgValvesStates; + QCOMPARE(mdgValvesStates.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGTemperatures + Model::MDGTemperatures mDGTemperatures; + QCOMPARE(mDGTemperatures.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGReservoir + Model::MDGReservoir mDGReservoir; + QCOMPARE(mDGReservoir.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGROPump + Model::MDGROPump mDGROPump; + QCOMPARE(mDGROPump.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGPressures + Model::MDGPressures mDGPressures; + QCOMPARE(mDGPressures.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGOperationMode + Model::MDGOperationMode mDGOperationMode; + QCOMPARE(mDGOperationMode.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGLoadCellReadings + Model::MDGLoadCellReadings mDGLoadCellReadings; + QCOMPARE(mDGLoadCellReadings.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGHeaters + Model::MDGHeaters mDGHeaters; + QCOMPARE(mDGHeaters.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGGeneralEvent + Model::MDGGeneralEvent mDGGeneralEvent; + QCOMPARE(mDGGeneralEvent.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MDGDrainPump + Model::MDGDrainPump mDGDrainPump; + QCOMPARE(mDGDrainPump.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGDebugText + Model::MDGDebugText mDGDebugText; + QCOMPARE(mDGDebugText.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGConductivityData + Model::MDGConductivityData mDGConductivityData; + QCOMPARE(mDGConductivityData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGAccelerometer + Model::MDGAccelerometer mDGAccelerometer; + QCOMPARE(mDGAccelerometer.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/dg/data/pretreatment/ + // ----------------------------------- + // MDGFilterFlush + Model::MDGFilterFlush mDGFilterFlush; + QCOMPARE(mDGFilterFlush.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/dg/data/post/ + // ----------------------------------- + // MDGPostSingleResult + Model::MDGPostSingleResult mDGPostSingleResult; + QCOMPARE(mDGPostSingleResult.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDGPostFinalResult + Model::MDGPostFinalResult mDGPostFinalResult; + QCOMPARE(mDGPostFinalResult.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/dg/adjustment/settings/ + // ----------------------------------- + + // MAdjustVersionsDGResponse + Model::MAdjustVersionsDGResponse mAdjustVersionsDGResponse; + QCOMPARE(mAdjustVersionsDGResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustServiceDatesDGResponse + Model::MAdjustServiceDatesDGResponse mAdjustServiceDatesDGResponse; + QCOMPARE(mAdjustServiceDatesDGResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustSerialNumberDGResponse + Model::MAdjustSerialNumberDGResponse mAdjustSerialNumberDGResponse; + QCOMPARE(mAdjustVersionsDGResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDGCleaningUsageResponse + Model::MAdjustDGCleaningUsageResponse mAdjustDGCleaningUsageResponse; + QCOMPARE(mAdjustDGCleaningUsageResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MDuetRoWaterStatDGq + Model::MDuetRoWaterStatDGq mDuetRoWaterStatDGq; + QCOMPARE(mDuetRoWaterStatDGq.typeText(), Model::MAbstract::Type_Enum::eEvent ); +} + + +void tst_models::tst_HD_headerCoverage() { + // This test is for code coverage purposes of the HD model headers + + // ----------------------------------- + // FROM model/hd/alarm/ + // ----------------------------------- + // MAlarmTriggered + Model::MAlarmTriggered mAlarmTriggered; + QCOMPARE(mAlarmTriggered.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAlarmStatus + Model::MAlarmStatus mAlarmStatus; + QCOMPARE(mAlarmStatus.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MAlarmConditionCleared + Model::MAlarmClearedCondition mAlarmClearedCondition; + QCOMPARE(mAlarmClearedCondition.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAlarmCleared + Model::MAlarmCleared mAlarmCleared; + QCOMPARE(mAlarmCleared.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAlarmActiveListReq + Model::MAlarmActiveListReq mAlarmActiveListReq; + QVERIFY(mAlarmActiveListReq.toString() == "UI,AlarmActiveList"); + + Model::MAlarmActiveListResponse mAlarmActiveListResponse; + QCOMPARE(mAlarmActiveListResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/data/treatment + // ----------------------------------- + // MTreatmentTime + Model::MTreatmentTime mTreatmentTime; + QCOMPARE(mTreatmentTime.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentStop + Model::MTreatmentStop mTreatmentStop; + QCOMPARE(mTreatmentStop.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentStates + Model::MTreatmentStates mTreatmentStates; + QCOMPARE(mTreatmentStates.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentSaline + Model::MTreatmentSaline mTreatmentSaline; + QCOMPARE(mTreatmentSaline.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentRinseback + Model::MTreatmentRinseback mTreatmentRinseback; + QCOMPARE(mTreatmentRinseback.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentRecirculate + Model::MTreatmentRecirculate mTreatmentRecirculate; + QCOMPARE(mTreatmentRecirculate.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MPressureOcclusion + Model::MPressureOcclusion mPressureOcclusion; + QCOMPARE(mPressureOcclusion.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MOutletFlow + Model::MOutletFlow mOutletFlow; + QCOMPARE(mOutletFlow.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentHeparin + Model::MTreatmentHeparin mTreatmentHeparin; + QCOMPARE(mTreatmentHeparin.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MDialysateFlow + Model::MDialysateFlow mDialysateFlow; + QCOMPARE(mDialysateFlow.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentBloodPrime + Model::MTreatmentBloodPrime mTreatmentBloodPrime; + QCOMPARE(mTreatmentBloodPrime.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MBloodFlow + Model::MBloodFlow mBloodFlow; + QCOMPARE(mBloodFlow.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/data/pretreatment/ + // ----------------------------------- + // MPreTreatmentStates + Model::MPreTreatmentStates mPreTreatmentStates; + QCOMPARE(mPreTreatmentStates.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MPreTreatmentSelfTestNoCartridge + Model::MPreTreatmentSelfTestNoCartridge mPreTreatmentSelfTestNoCartridge; + QCOMPARE(mPreTreatmentSelfTestNoCartridge.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MPreTreatmentSelfTestDry + Model::MPreTreatmentSelfTestDry mPreTreatmentSelfTestDry; + QCOMPARE(mPreTreatmentSelfTestDry.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MPreTreatmentDisposablesPrime + Model::MPreTreatmentDisposablesPrime mPreTreatmentDisposablesPrime; + QCOMPARE(mPreTreatmentDisposablesPrime.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/data/treatmentlog/ + // ----------------------------------- + // MTreatmentLogEventData + Model::MTreatmentLogEventData mTreatmentLogEventData; + QCOMPARE(mTreatmentLogEventData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentLogAvrgeData + Model::MTreatmentLogAvrgeData mTreatmentLogAvrgeData; + QCOMPARE(mTreatmentLogAvrgeData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MTreatmentLogAlarmData + Model::MTreatmentLogAlarmData mTreatmentLogAlarmData; + QCOMPARE(mTreatmentLogAlarmData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/data/posttreatment/ + // ----------------------------------- + // MPostTreatmentStates + Model::MPostTreatmentStates mPostTreatmentStates2; + QCOMPARE(mPostTreatmentStates2.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/data/post/ + // ----------------------------------- + // MUIPostFinalResultHDRequest + Model::MUIPostFinalResultHDRequest mUIPostFinalResultHDRequest; + QCOMPARE(mUIPostFinalResultHDRequest.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MHDRTCEpochData + Model::MHDRTCEpochData mHDRTCEpochData; + QCOMPARE(mHDRTCEpochData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDPostSingleResult + Model::MHDPostSingleResult mHDPostSingleResult; + QCOMPARE(mHDPostSingleResult.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDPostFinalResult + Model::MHDPostFinalResult mHDPostFinalResult; + QCOMPARE(mHDPostFinalResult.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/data/ + // ----------------------------------- + // MTreatmentRanges + Model::MTreatmentRanges mTreatmentRanges; + QCOMPARE(mTreatmentRanges.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDUsageInfoResponse + Model::MHDUsageInfoResponse mHDUsageInfoResponse; + QCOMPARE(mHDUsageInfoResponse.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDSyringePump + Model::MHDSyringePump mHDSyringePump; + QCOMPARE(mHDSyringePump.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDOperationMode + Model::MHDOperationMode mHDOperationMode; + QCOMPARE(mHDOperationMode.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDGeneralEvent + Model::MHDGeneralEvent mHDGeneralEvent; + QCOMPARE(mHDGeneralEvent.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MHDSyringePump + Model::MHDDebugText mHDDebugText; + QCOMPARE(mHDDebugText.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDBloodLeakData + Model::MHDBloodLeakData mHDBloodLeakData; + QCOMPARE(mHDBloodLeakData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDAirTrapData + Model::MHDAirTrapData mHDAirTrapData; + QCOMPARE(mHDAirTrapData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDAirBubbleData + Model::MHDAirBubbleData mHDAirBubbleData; + QCOMPARE(mHDAirBubbleData.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // MHDAccelerometer + Model::MHDAccelerometer mHDAccelerometer; + QCOMPARE(mHDAccelerometer.typeText(), Model::MAbstract::Type_Enum::eDatum ); + + // ----------------------------------- + // FROM model/hd/adjustment/posttreatment + // ----------------------------------- + // MAdjustTreatmentLogResponse + Model::MAdjustTreatmentLogResponse mAdjustTreatmentLogResponse; + QCOMPARE(mAdjustTreatmentLogResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustPatientDisconnectionConfirmResponse + Model::MAdjustPatientDisconnectionConfirmResponse mAdjustPatientDisconnectionConfirmResponse; + QCOMPARE(mAdjustPatientDisconnectionConfirmResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDisposablesRemovalConfirmResponse + Model::MAdjustDisposablesRemovalConfirmResponse mAdjustDisposablesRemovalConfirmResponse; + QCOMPARE(mAdjustDisposablesRemovalConfirmResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/adjustment/pretreatment + // ----------------------------------- + // MAdjustWaterSampleResponse + Model::MAdjustWaterSampleResponse mAdjustWaterSampleResponse; + QCOMPARE(mAdjustWaterSampleResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustUltrafiltrationInitResponse + Model::MAdjustUltrafiltrationInitResponse mAdjustUltrafiltrationInitResponse; + QCOMPARE(mAdjustUltrafiltrationInitResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustStartTreatmentResponse + Model::MAdjustStartTreatmentResponse mAdjustStartTreatmentResponse; + QCOMPARE(mAdjustStartTreatmentResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustPatientConnectionConfirmResponse + Model::MAdjustPatientConnectionConfirmResponse mAdjustPatientConnectionConfirmResponse; + QCOMPARE(mAdjustPatientConnectionConfirmResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustPatientConnectionBeginResponse + Model::MAdjustPatientConnectionBeginResponse mAdjustPatientConnectionBeginResponse; + QCOMPARE(mAdjustPatientConnectionBeginResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustParametersValidationResponse + Model::MAdjustParametersValidationResponse mAdjustParametersValidationResponse; + QCOMPARE(mAdjustParametersValidationResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustInitTreatmentResponse + Model::MAdjustInitTreatmentResponse mAdjustInitTreatmentResponse; + QCOMPARE(mAdjustInitTreatmentResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDisposablesPrimeResponse + Model::MAdjustDisposablesPrimeResponse mAdjustDisposablesPrimeResponse; + QCOMPARE(mAdjustDisposablesPrimeResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDisposablesConfirmResponse + Model::MAdjustDisposablesConfirmResponse mAdjustDisposablesConfirmResponse; + QCOMPARE(mAdjustDisposablesConfirmResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/adjustment/settings + // ----------------------------------- + // MAdjustVersionsHDResponse + Model::MAdjustVersionsHDResponse mAdjustVersionsHDResponse; + QCOMPARE(mAdjustVersionsHDResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustVersionsHDRequest + Model::MAdjustVersionsHDRequest mAdjustVersionsHDRequest; + QCOMPARE(mAdjustVersionsHDRequest.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustServiceModeResponse + Model::MAdjustServiceModeResponse mAdjustServiceModeResponse; + QCOMPARE(mAdjustServiceModeResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustSerialNumberHDResponse + Model::MAdjustSerialNumberHDResponse mAdjustSerialNumberHDResponse; + QCOMPARE(mAdjustSerialNumberHDResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustHDDateTimeResponse + Model::MAdjustHDDateTimeResponse mAdjustHDDateTimeResponse; + QCOMPARE(mAdjustHDDateTimeResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustHDAlarmVolumeResponse + Model::MAdjustHDAlarmVolumeResponse mAdjustHDAlarmVolumeResponse; + QCOMPARE(mAdjustHDAlarmVolumeResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/adjustment/treatment + // ----------------------------------- + // MAdjustVersionsHDResponse + Model::MAdjustUltrafiltrationStateResponse mAdjustUltrafiltrationStateResponse; + QCOMPARE(mAdjustUltrafiltrationStateResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustSalineResponse + Model::MAdjustSalineResponse mAdjustSalineResponse; + QCOMPARE(mAdjustSalineResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustRinsebackResponse + Model::MAdjustRinsebackResponse mAdjustRinsebackResponse; + QCOMPARE(mAdjustRinsebackResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustRecirculateResponse + Model::MAdjustRecirculateResponse mAdjustRecirculateResponse; + QCOMPARE(mAdjustRecirculateResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustPressuresLimitsResponse + Model::MAdjustPressuresLimitsResponse mAdjustPressuresLimitsResponse; + QCOMPARE(mAdjustPressuresLimitsResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustHeparinResponse + Model::MAdjustHeparinResponse mAdjustHeparinResponse; + QCOMPARE(mAdjustHeparinResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustTreatmentEndResponse + Model::MAdjustTreatmentEndResponse mAdjustTreatmentEndResponse; + QCOMPARE(mAdjustTreatmentEndResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDurationResponse + Model::MAdjustDurationResponse mAdjustDurationResponse; + QCOMPARE(mAdjustDurationResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustBloodDialysateResponse + Model::MAdjustBloodDialysateResponse mAdjustBloodDialysateResponse; + QCOMPARE(mAdjustBloodDialysateResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/adjustment/disinfect/ + // ----------------------------------- + // MAdjustDisinfectStartResponse + Model::MAdjustDisinfectStartResponse mAdjustDisinfectStartResponse; + QCOMPARE(mAdjustDisinfectStartResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // MAdjustDisinfectModeResponse + Model::MAdjustDisinfectModeResponse mAdjustDisinfectModeResponse; + QCOMPARE(mAdjustDisinfectModeResponse.typeText(), Model::MAbstract::Type_Enum::eEvent ); + + // ----------------------------------- + // FROM model/hd/adjustment/ + // ----------------------------------- + // MPowerOff + Model::MPowerOff mPowerOff; + QCOMPARE(mPowerOff.typeText(), Model::MAbstract::Type_Enum::eEvent ); +} + +void tst_models::tst_modelsHeader_Coverage() +{ + QVERIFY(Model::MAbstract::typeText(Model::MAbstract::Type_Enum::eEvent) == "E"); + QVERIFY(Model::MAbstract::typeText(Model::MAbstract::Type_Enum::eDatum) == "D"); +} + +void tst_models::tst_MDisinfectAdjustModeRequests_ToStrings() +{ + // This is to do code coverage for the toString functions + // MAdjustDisinfectModeReq + Model::MAdjustDisinfectModeReq mMAdjustDisinfectModeReq; + QVERIFY(mMAdjustDisinfectModeReq.toString().contains("DisinfectMode")); + +} + +void tst_models::tst_MPostTreatmentAdjustRequests_ToStrings() +{ + // This is to do code coverage for the toString functions + // MAdjustPatientDisconnectionNotifyReq + Model::MAdjustPatientDisconnectionNotifyReq mMAdjustPatientDisconnectionNotifyReq; + QVERIFY(mMAdjustPatientDisconnectionNotifyReq.toString().contains("PatientDisconnectionNotify")); + + // MAdjustPatientDisconnectionConfirmReq + Model::MAdjustPatientDisconnectionConfirmReq mAdjustPatientDisconnectionConfirmReq; + QVERIFY(mAdjustPatientDisconnectionConfirmReq.toString().contains("PatientDisconnectionConfirm")); + + // MAdjustDisposablesRemovalConfirmReq + Model::MAdjustDisposablesRemovalConfirmReq mMAdjustDisposablesRemovalConfirmReq; + QVERIFY(mMAdjustDisposablesRemovalConfirmReq.toString().contains("DisposablesRemovalConfirm")); + + // MAdjustTreatmentLogReq + Model::MAdjustTreatmentLogReq mMAdjustTreatmentLogReq; + QVERIFY(mMAdjustTreatmentLogReq.toString().contains("TreatmentLog")); +} + + + + + + Index: unittests/tst_models.h =================================================================== diff -u --- unittests/tst_models.h (revision 0) +++ unittests/tst_models.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,496 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_models.h + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project + +class tst_models : public QObject +{ + Q_OBJECT + +public: + explicit tst_models(QObject *parent = nullptr); + +private slots: + void tst_MTreatmentRanges_data (); + void tst_MTreatmentRanges (); + + // Treatment Start / Stop + void tst_MAdjustInitTreatmentResponse_data(); + void tst_MAdjustInitTreatmentResponse(); + void tst_MInitTreatmentRequest(); + void tst_MEndTreatmentRequest(); + + // - Treatment Adjustments + void tst_MAdjustmentTreatmentParametersRequest(); + + // -- Treatment Duration + void tst_MAdjustDurationResponse_data (); + void tst_MAdjustDurationResponse (); + + // -- Treatment Blood/Dialysate Flow + void tst_MAdjustBloodDialysateResponse_data (); + void tst_MAdjustBloodDialysateResponse (); + + // -- Ultrafiltration + // --- Init + void tst_MAdjustUltrafiltrationInitResponse_data (); + void tst_MAdjustUltrafiltrationInitResponse (); + // --- State + void tst_MAdjustUltrafiltrationStateResponse_data (); + void tst_MAdjustUltrafiltrationStateResponse (); + // --- Edit + void tst_MAdjustUltrafiltrationEditResponse_data (); + void tst_MAdjustUltrafiltrationEditResponse (); + // --- Confirm + void tst_MAdjustUltrafiltrationConfirmResponse_data (); + void tst_MAdjustUltrafiltrationConfirmResponse (); + void tst_MConfirmTreatmentRequest(); + + // -- Treatment Inline pressures + void tst_MAdjustPressuresLimitsResponse_data (); + void tst_MAdjustPressuresLimitsResponse (); + + // -- Treatment Heparin + void tst_MHeparinResponse_data(); + void tst_MHeparinResponse(); + + // - Data Messages + void tst_DGROPumpData_data(); + void tst_DGROPumpData(); + void tst_DGPressuresData_data(); + void tst_DGPressuresData(); + void tst_DGDrainPumpData_data(); + void tst_DGDrainPumpData(); + void tst_DGOperationMode_data(); + void tst_DGOperationMode(); + void tst_DGReservoirData_data(); + void tst_DGReservoirData(); + void tst_DGValvesStates_data(); + void tst_DGValvesStates(); + void tst_DGHeatersData_data(); + void tst_DGHeatersData(); + void tst_DGLoadCellReadingsData_data(); + void tst_DGLoadCellReadingsData(); + void tst_DGTemperaturesData_data(); + void tst_DGTemperaturesData(); + void tst_MTreatmentStateData_data(); + void tst_MTreatmentStateData(); + void tst_MHDOperationModeData_data(); + void tst_MHDOperationModeData(); + void tst_MOutletFlowData_data(); + void tst_MOutletFlowData(); + void tst_MBloodFlowData_data(); + void tst_MBloodFlowData(); + void tst_MDialysateFlowData_data(); + void tst_MDialysateFlowData(); + void tst_MTreatmentTimeData_data(); + void tst_MTreatmentTimeData(); + void tst_MPressureOcclusionData_data(); + void tst_MPressureOcclusionData(); + void tst_MTreatmentSalineBolusData_data(); + void tst_MTreatmentSalineBolusData(); + void tst_MTreatmentHeparinData_data(); + void tst_MTreatmentHeparinData(); + void tst_MPowerOff_data(); + void tst_MPowerOff(); + void tst_MPreTreatmentPrime_data(); + void tst_MPreTreatmentPrime(); + + // Treatment Parameters + void tst_MTreatmentParametersResp_data(); + void tst_MTreatmentParametersResp(); + void tst_MAdjustTreatmentLogResponse_data(); + void tst_MAdjustTreatmentLogResponse(); + void tst_MHDSyringePump_data(); + void tst_MHDSyringePump(); + void tst_MHDAirTrapData_data(); + void tst_MHDAirTrapData(); + void tst_MHDBloodLeakData_data(); + void tst_MHDBloodLeakData(); + void tst_MHDAccelerometer_data(); + void tst_MHDAccelerometer(); + void tst_MHDUsageInfoResponse_data(); + void tst_MHDUsageInfoResponse(); + void tst_MHDAirBubbleData_data(); + void tst_MHDAirBubbleData(); + void tst_MPreTreatmentStates_data(); + void tst_MPreTreatmentStates(); + void tst_MPreTreatmentSelfTestNoCartridge_data(); + void tst_MPreTreatmentSelfTestNoCartridge(); + void tst_MPreTreatmentSelfTestDry_data(); + void tst_MPreTreatmentSelfTestDry(); + void tst_MPostTreatmentStates_data(); + void tst_MPostTreatmentStates(); + void tst_MTreatmentStop_data(); + void tst_MTreatmentStop(); + void tst_MTreatmentRinseback_data(); + void tst_MTreatmentRinseback(); + void tst_MTreatmentRecirculate_data(); + void tst_MTreatmentRecirculate(); + void tst_MTreatmentBloodPrime_data(); + void tst_MTreatmentBloodPrime(); + void tst_MTreatmentLogEventData_data(); + void tst_MTreatmentLogEventData(); + void tst_MTreatmentLogAvrgeData_data(); + void tst_MTreatmentLogAvrgeData(); + void tst_MTreatmentLogAlarmData_data(); + void tst_MTreatmentLogAlarmData(); + + // data post + void tst_MHDRTCEpochData_data(); + void tst_MHDRTCEpochData(); + void tst_MHDPostSingleResult_data(); + void tst_MHDPostSingleResult(); + void tst_MHDPostFinalResult_data(); + void tst_MHDPostFinalResult(); + + // hd/adjustments/settings + void tst_MAdjustHDAlarmVolumeResponse_data(); + void tst_MAdjustHDAlarmVolumeResponse(); + void tst_MAdjustHDDateTimeResponse_data(); + void tst_MAdjustHDDateTimeResponse(); + void tst_MAdjustServiceModeResponse_data(); + void tst_MAdjustServiceModeResponse(); + void tst_MAdjustVersionsHDResponse_data(); + void tst_MAdjustVersionsHDResponse(); + void tst_MAdjustServiceDatesHDResponse_data(); + void tst_MAdjustServiceDatesHDResponse(); + + // hd/adjustments/treatment + void tst_MAdjustRinsebackResponse_data(); + void tst_MAdjustRinsebackResponse(); + void tst_MAdjustRecirculateResponse_data(); + void tst_MAdjustRecirculateResponse(); + void tst_MAdjustTreatmentEndResponse_data(); + void tst_MAdjustTreatmentEndResponse(); + void tst_MAdjustSalineResponse_data(); + void tst_MAdjustSalineResponse(); + + // hd/adjustments/pretreatment + void tst_MAdjustWaterSampleResponse_data(); + void tst_MAdjustWaterSampleResponse(); + void tst_MAdjustStartTreatmentResponse_data(); + void tst_MAdjustStartTreatmentResponse(); + void tst_MAdjustPatientConnectionConfirmResponse_data(); + void tst_MAdjustPatientConnectionConfirmResponse(); + void tst_MAdjustPatientConnectionBeginResponse_data(); + void tst_MAdjustPatientConnectionBeginResponse(); + void tst_MAdjustDisposablesPrimeResponse_data(); + void tst_MAdjustDisposablesPrimeResponse(); + void tst_MAdjustDisposablesConfirmResponse_data(); + void tst_MAdjustDisposablesConfirmResponse(); + + // hd/adjustments/posttreatment + void tst_MAdjustPatientDisconnectionConfirmResponse_data(); + void tst_MAdjustPatientDisconnectionConfirmResponse(); + void tst_MAdjustDisposablesRemovalConfirmResponse_data(); + void tst_MAdjustDisposablesRemovalConfirmResponse(); + + // hd/adjustments/disinfect + void tst_MAdjustDisinfectStartResponse_data(); + void tst_MAdjustDisinfectStartResponse(); + void tst_MAdjustDisinfectModeResponse_data(); + void tst_MAdjustDisinfectModeResponse(); + + // hd/alarm/ + void tst_MAlarmActiveListResponse_data(); + void tst_MAlarmActiveListResponse(); + void tst_MAlarmClearedCondition_data(); + void tst_MAlarmClearedCondition(); + + // dg/adjustment/settings + void tst_MAdjustDGCleaningUsageResponse_data(); + void tst_MAdjustDGCleaningUsageResponse(); + void tst_MAdjustDGDateTimeResponse_data(); + void tst_MAdjustDGDateTimeResponse(); + void tst_MAdjustServiceDatesDGResponse_data(); + void tst_MAdjustServiceDatesDGResponse(); + void tst_MAdjustVersionsDGResponse_data(); + void tst_MAdjustVersionsDGResponse(); + void tst_MDGConductivityData_data(); + void tst_MDGConductivityData(); + void tst_MDuetRoWaterModeDGr_data(); + void tst_MDuetRoWaterModeDGr(); + + // dg/data + void tst_MDGAccelerometer_data(); + void tst_MDGAccelerometer(); + + // dg/data/pretreatment + void tst_MDGFilterFlush_data(); + void tst_MDGFilterFlush(); + + // dg/data/post + void tst_MDGPostSingleResult_data(); + void tst_MDGPostSingleResult(); + void tst_MDGPostFinalResult_data(); + void tst_MDGPostFinalResult(); + + // ui/data + void tst_MUIBloodPressure_data(); + void tst_MUIBloodPressure(); + + // confirm + void tst_MDuetConfirmHDi_data(); + void tst_MDuetConfirmHDi(); + + // Alarms + void tst_MAlarmStatus_text(); + void tst_MAlarmStatus_data(); + void tst_MAlarmStatus(); + void tst_MAlarmTriggered_data(); + void tst_MAlarmTriggered(); + void tst_MAbstractDynamic_data(); + void tst_MAbstractDynamic(); + void tst_MAlarmCleared_data(); + void tst_MAlarmCleared(); + void tst_MAlarmAcknowledgeRequest(); + + //Misc function code coverage + void tst_DG_headerCoverage(); + void tst_HD_headerCoverage(); + void tst_MDisinfectAdjustModeRequests_ToStrings(); + void tst_MPostTreatmentAdjustRequests_ToStrings(); + void tst_modelsHeader_Coverage(); +private: + class HelperFunctions_tstModel + { + protected: + explicit HelperFunctions_tstModel() {} + + public : + /* + * generateDataSet + * @params vDataNames - the list of string names of the data structure's member variable. + * + * @brief The main purpose of this function is to properly generate the QTest::newRow for data used in the testing + * This function is making use of two additional helper functions that will create the appropriate test data + * + * For example, if the Model::MSomeExampleModel has a data structure that is: + * struct { + * Types::U32 mAccepted ; + * Types::U32 mReason ; + * Types::U32 mBloodFlowRate ; + * Types::U32 mDialysateFlowRate ; + * } _data; + * + * We would expect the data set to be the following: + * QTest::addColumn("errorIndex"); + * QTest::addColumn("data"); + * QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + * QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray()); + * QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00")); + * QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + * QTest::newRow("mAccepted ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + * QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + * QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + * QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + * QTest::newRow("mReason ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + * QTest::newRow("mBloodFlowRate") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + * QTest::newRow("mBloodFlowRate") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + * QTest::newRow("mBloodFlowRate") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + * QTest::newRow("mBloodFlowRate") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + * QTest::newRow("mDialysateFlowRate") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + * QTest::newRow("mDialysateFlowRate") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + * QTest::newRow("mDialysateFlowRate") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + * QTest::newRow("mDialysateFlowRate") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + * + * This function is called as : + * HelperFunctions_tstModel::generate_ByteDataSet( { "mAccepted", "mReason", "mBloodFlowRate", "mDialysateFlowRate" } ); + * + * Overall Structure: + * - There are two columns: errorIndex and data. + * - The row with the dataTag as "msg complete" will contain the number of variables * 4 (bytes), which is a complete message with all the data elements + * - The first parameter is handled as a special case where it will contain a zero array, a one, two, three element array. + * - All the other parameters beyond the first one contains four rows, where each row contains one more element than the last to build up from an incomplete + * data element. + * - The errorIndex only incrementals with each set of four rows. + * + * - totalNameLength overrides the total length count of dataNames for the "msg complete" data set. default, it uses the length of the passed QStringList + */ + static int generate_ByteDataSet(const QStringList& vDataNames, int totalNameLength = -1 ) + { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + + int errorIndex = 0; + const int totalLengthForComplete = totalNameLength > 0 ? totalNameLength : vDataNames.length(); + QTest::newRow("msg complete") << errorIndex << QByteArray::fromHex(createByteDataArray(totalLengthForComplete*4)); + + // Special case for the first parameter of the data list: + errorIndex++; // increment vErrorIndex to 1 + QTest::newRow(vDataNames.at(0).toUtf8()) << errorIndex << QByteArray::fromHex(QByteArray()); + QTest::newRow(vDataNames.at(0).toUtf8()) << errorIndex << QByteArray::fromHex(QByteArray("00")); + QTest::newRow(vDataNames.at(0).toUtf8()) << errorIndex << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow(vDataNames.at(0).toUtf8()) << errorIndex << QByteArray::fromHex(QByteArray("00" "01" "02")); + + // do the newRow for the rest of the parameters + int lastElementCount = 3; // The number of elements in the last row + for(int dataNameIndex = 1; dataNameIndex < vDataNames.length(); dataNameIndex++) + { + errorIndex++; // increment the error index for each set of 4 rows + QString paramName = vDataNames.at(dataNameIndex); + lastElementCount = addRowsForByteData(paramName.toUtf8(), errorIndex, lastElementCount+1); + } + return errorIndex; + } + + + /* + * addBit_Data + * @params dataTag - the row tag + * @params errorIndexStart - the starting index for errorIndex variable/column + * @params flagStartAt - The initial starting point to set flag to true + * @params totalRows - the total number of rows to generate, default is 8 rows for 8-bits + * + * @brief The main purpose of this function is to properly generate the QTest::newRow for data used in the testing + * This function is making use of one additional helper function that will convert the bit array to a byte array before + * inserting into the row + * + * For example, if the Model::MSomeExampleModel has a data structure that is: + * struct { + * Types::U8 mAccepted ; + * } _data; + * + * We would expect the data set to be the following: + * QTest::addColumn("errorIndex"); + * QTest::addColumn("data"); + * QTest::newRow("mAccepted ") << 1 << converted_bitArray(one_byte_first_bit_set); + * QTest::newRow("mAccepted ") << 1 << converted_bitArray(one_byte_second_bit_set); + * QTest::newRow("mAccepted ") << 1 << converted_bitArray(one_byte_third_bit_set); + * ...and so on for 8 rows, since 8-bits = 1 byte + * + * This function is called as : + * HelperFunctions::addBit_Data( "mAccepted", 0, 0); // default 8-bits so 8 rows + * + * Overall Structure: + * - There are two columns: errorIndex and data. + * -- if vExpectedIndex is not negative, it is expected that there are three columns (errorIndex, data, and expectedIndex) + */ + static int addTestDataRow_bitRows(const QString& vDataTag, const int vErrorIndex, const int vBitCount, const int vExpectedIndex = -1) + { + int currentBitCount = vBitCount; + for(int i=0; i<8; i++) + { + if(vExpectedIndex < 0) + { + QTest::newRow(vDataTag.toUtf8()) << vErrorIndex << HelperFunctions_tstModel::makeByteArray(currentBitCount++); + } + else + { + QTest::newRow(vDataTag.toUtf8()) << vErrorIndex << HelperFunctions_tstModel::makeByteArray(currentBitCount++) << vExpectedIndex; + } + } + return currentBitCount; + } + + static int generate_bitDataRow(const QString& vDataTag, const int vErrorIndexStart, const int vFlagStartAt, const int vTotalRows = 8) + { + int currentFlags = 0; + for(int rowCountIndex = 0; rowCountIndex < vTotalRows; rowCountIndex++) + { + currentFlags = vFlagStartAt + rowCountIndex; + QTest::newRow(vDataTag.toUtf8()) << vErrorIndexStart << makeByteArray(currentFlags); + } + return currentFlags; + } + + static QByteArray makeByteArray(const int vNumberOfBits, bool vDefaultSet = true) + { + QBitArray flag(vNumberOfBits, vDefaultSet); + QByteArray dataByteArray = bitsToBytes(flag); + return dataByteArray; + } + + static QByteArray createByteDataArray(int vCount) + { + /* + * Based on the existing tests and test data, this helper function will reduce the need to copy-paste + * and creating data sets by hand. The function generates a QByteArray of elements "00"..."xx" up to + * vCount of them. + * + * Expected return for a vCount == 5 is: + * { "00" "01" "02" "03" "04" } + */ + QByteArray returnArray = {}; + for(int i = 0; i int expectedIndex + */ + int elementCount = vStartArrayCount; + if(vExpectedIndex < 0) + { + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)); elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)); elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)); elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)); + } else { + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)) << vExpectedIndex; elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)) << vExpectedIndex; elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)) << vExpectedIndex; elementCount++; + QTest::newRow(vKey) << vErrorIndex << QByteArray::fromHex(createByteDataArray(elementCount)) << vExpectedIndex; + } + return elementCount; // returns the last element count used + } + private: + static QByteArray bitsToBytes(QBitArray bits) { + /* + * Converts a QBitArray to a QByteArray + * + */ + QByteArray bytes; + + // Determine if there is a partially full byte + bool isPartialByteExist = (bits.count() % 8) > 0 ; + int addPartialByte = isPartialByteExist ? 1 : 0; + int fullBytesCount = bits.count() / 8 ; + + // Resize byte array to fit expected bytes for bits passed + bytes.resize(fullBytesCount + addPartialByte); + + // initialize with 0s + bytes.fill(0); + + // copy the bits into the byte array based on index + for(int bit = 0; bit < bits.count(); ++bit) + bytes[bit/8] = ( bytes.at(bit/8) | ((bits[bit]?1:0)<<(bit%8))); + + return bytes; + } + + }; +}; Index: unittests/tst_threads.cpp =================================================================== diff -u --- unittests/tst_threads.cpp (revision 0) +++ unittests/tst_threads.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,59 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_threads.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#include "tst_threads.h" + +// Qt + +// Project +#include "Threads.h" +#include "ApplicationController.h" +#include "GuiController.h" +#include "DeviceController.h" +#include "CanInterface.h" +#include "FrameInterface.h" +#include "MessageDispatcher.h" +#include "MessageAcknowModel.h" + +tst_threads::tst_threads(QObject *parent) : QObject(parent) { } + +void tst_threads::initTestCase() +{ + Threads::registerTypes(); +} + +void tst_threads::tst_Thread_init() +{ + QCOMPARE( _Logger .init(Threads::_Logger_Thread ), ! _Logger .init(Threads::_Logger_Thread )); + QCOMPARE( _DeviceController .init(Threads::_DeviceController_Thread ), ! _DeviceController .init(Threads::_DeviceController_Thread )); + QCOMPARE( _CanInterface .init(Threads::_CanFrame_Thread ), ! _CanInterface .init(Threads::_CanFrame_Thread )); + QCOMPARE( _FrameInterface .init(Threads::_CanFrame_Thread ), ! _FrameInterface .init(Threads::_CanFrame_Thread )); + QCOMPARE( _MessageAcknowModel .init(Threads::_CanAcknow_Thread ), ! _MessageAcknowModel .init(Threads::_CanAcknow_Thread )); + QCOMPARE( _MessageDispatcher .init(Threads::_CanMessage_Thread ), ! _MessageDispatcher .init(Threads::_CanMessage_Thread )); + QCOMPARE( _ApplicationController .init(Threads::_Application_Thread ), ! _ApplicationController .init(Threads::_Application_Thread )); + QCOMPARE( _GuiController .init(Threads::_Gui_Thread ), ! _GuiController .init(Threads::_Gui_Thread )); +} + +void tst_threads::tst_Thread_names() +{ + QCOMPARE( _Logger .thread()->objectName(), "Storage::Logger_Thread" ); + QCOMPARE( _DeviceController .thread()->objectName(), "Device::DeviceController_Thread" ); + QCOMPARE( _CanInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); + QCOMPARE( _FrameInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); + QCOMPARE( _MessageAcknowModel .thread()->objectName(), "Can::MessageAcknowModel_Thread" ); + QCOMPARE( _MessageDispatcher .thread()->objectName(), "Can::MessageDispatcher_Thread" ); + QCOMPARE( _ApplicationController .thread()->objectName(), "ApplicationController_Thread" ); + QCOMPARE( _GuiController .thread()->objectName(), "Gui::GuiController_Thread" ); +} + Index: unittests/tst_threads.h =================================================================== diff -u --- unittests/tst_threads.h (revision 0) +++ unittests/tst_threads.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,35 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_threads.h + * \author (last) Behrouz NematiPour + * \date (last) 01-Nov-2020 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project + +class tst_threads : public QObject +{ + Q_OBJECT + +public: + explicit tst_threads(QObject *parent = nullptr); + +private slots: + void initTestCase(); + + void tst_Thread_init(); + void tst_Thread_names(); +}; Index: unittests/tst_utilities.cpp =================================================================== diff -u --- unittests/tst_utilities.cpp (revision 0) +++ unittests/tst_utilities.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,317 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_utilities.cpp + * \author (last) Dara Navaei + * \date (last) 05-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 08-Jan-2020 + * + */ +#include "tst_utilities.h" + +// Qt + +// Project +#include "types.h" + +/*! + * \brief tst_utilities::tst_utilities + * \details Constructor + * \param parent - QObject parent owner object. + * Qt handles the children destruction by their parent objects life-cycle. + */ +tst_utilities::tst_utilities(QObject *parent) : QObject(parent) { } + +void tst_utilities::tst_floatCompare_noMatch() +{ + QVERIFY( ! Types::floatCompare(1.002,1.003)); +} + +void tst_utilities::tst_floatCompare_isMatch() +{ + QVERIFY( Types::floatCompare(1.354,1.354)); +} + +void tst_utilities::tst_getbits_NoError() +{ + QByteArray ba = QByteArray::fromHex("a5"); + Types::Flags flg; + int i = 0; + QVERIFY( Types::getBits(ba,i,flg,8)); +} + +void tst_utilities::tst_getbits_IsError() +{ + QByteArray ba = QByteArray::fromHex("a5"); + Types::Flags flg; + int i = 0; + QVERIFY( ! Types::getBits(ba,i,flg,9)); +} + +void tst_utilities::tst_fromvariant_NoString() +{ + char c = 64; + QByteArray ba; + ba += '@'; + ba += '\0'; + ba += '\0'; + ba += '\0'; + QCOMPARE(Format::fromVariant(c), ba); +} + +void tst_utilities::tst_fromvariant_IsString() +{ + QCOMPARE(Format::fromVariant("@"), "@"); +} + +void tst_utilities::tst_fromvariant_ByteArray() +{ + QByteArray ba; + ba += '@'; + ba += '\0'; + ba += '\0'; + ba += '\0'; + QVariant var(ba); + QCOMPARE(Format::fromVariant(var), ba); +} + +void tst_utilities::tst_fromvariant_Float() +{ + float f = 12.5; + QByteArray ba; + ba += '\0'; + ba += '\0'; + ba += 0x48; + ba += 0x41; + QCOMPARE(Format::fromVariant(f).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_UInt() +{ + quint32 ui = 65500; + QByteArray ba; + ba += 0xDC; + ba += 0xFF; + ba += '\0'; + ba += '\0'; + QCOMPARE(Format::fromVariant(ui).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_Int_Pos() +{ + qint32 pi = 32700; + QByteArray ba; + ba += 0xBC; + ba += 0x7F; + ba += '\0'; + ba += '\0'; + QCOMPARE(Format::fromVariant(pi).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_Int_Neg() +{ + qint32 ni = -32700; + QByteArray ba; + ba += 0x44; + ba += 0x80; + ba += 0xFF; + ba += 0xFF; + QCOMPARE(Format::fromVariant(ni).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_List() +{ + quint32 ui = 65500 ; + float f = 12.5 ; + qint32 pi = 32700 ; + qint32 ni = -32700 ; + QVariantList vl; + vl += 12.5; // float with no type is double in QVariant + vl += f; + vl += ui; + vl += pi; + vl += ni; + + QByteArray ba; + ba += '\0'; + ba += '\0'; + ba += 0x48; + ba += 0x41; + ba += '\0'; + ba += '\0'; + ba += 0x48; + ba += 0x41; + ba += 0xDC; + ba += 0xFF; + ba += '\0'; + ba += '\0'; + ba += 0xBC; + ba += 0x7F; + ba += '\0'; + ba += '\0'; + ba += 0x44; + ba += 0x80; + ba += 0xFF; + ba += 0xFF; + QCOMPARE(Format::fromVariant(vl).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_Bool_True() +{ + bool b = true; + QByteArray ba; + ba += 0x01; + QCOMPARE(Format::fromVariant(b).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_Bool_False() +{ + bool b = false; + QByteArray ba; + ba += '\0'; + QCOMPARE(Format::fromVariant(b).toHex(), ba.toHex()); +} + +void tst_utilities::tst_fromvariant_Undefined() +{ + QTime t; // Any undefined type which is not defined in the Format::fromVariant + QByteArray ba; + ba += '\0'; + QCOMPARE(Format::fromVariant(t.currentTime()).toHex(), ba.toHex()); +} + +void tst_utilities::tst_toStringList_Default() +{ + const QList data { + "A", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data); + QStringList mExpected = { + "A", + "B", + "C", + }; + QCOMPARE(mActual, mExpected); +} + +void tst_utilities::tst_toStringList_RemoveDuplicate() +{ + const QList data { + "A", + "B", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data, true); + QStringList mExpected = { + "A", + "B", + "C", + }; + QCOMPARE(mActual, mExpected); +} + +void tst_utilities::tst_toStringList_Prefix() +{ + const QList data { + "A", + "B", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data, true, "*"); + QStringList mExpected = { + "*A", + "*B", + "*C", + }; + QCOMPARE(mActual, mExpected); +} + +void tst_utilities::tst_getValue_len_log() +{ + bool ok = true; + int index = 0; + Types::S32 vFlowSetPoint; + QByteArray data; + data += 0xFF; + ok = ! GetValue( data, index, vFlowSetPoint ) && ok; + QVERIFY( ok ); +} + +void tst_utilities::tst_getValue_len_lt() +{ + bool ok = true; + int index = 0; + Types::S32 vP1; + QByteArray data; + data += 0x01; + data += 0x02; + data += 0x03; + data += 0x04; + data += 0x05; + ok = GetValue( data, index, vP1 ) && ( vP1.value == 67305985 ) && ok; + QVERIFY( ok ); +} + +void tst_utilities::tst_getValue_len_eq() +{ + bool ok = true; + int index = 0; + Types::S32 vP1; + Types::U08 vP2; + QByteArray data; + data += 0x01; + data += 0x02; + data += 0x03; + data += 0x04; + data += 0x05; + ok = GetValue( data, index, vP1 ) && ( vP1.value == 67305985 ) && ok; + ok = GetValue( data, index, vP2 ) && ( vP2.value == 5 ) && ok; + QVERIFY( ok ); +} + +void tst_utilities::tst_getValue_len_gt() +{ + bool ok = true; + int index = 0; + Types::S32 vP1; + Types::U16 vP2; + QByteArray data; + data += 0x01; + data += 0x02; + data += 0x03; + data += 0x04; + data += 0x05; + ok = GetValue( data, index, vP1 ) && ( vP1.value == 67305985 ) && ok; + ok = ! GetValue( data, index, vP2 ) && ( vP2.value == 0 ) && ok; + QVERIFY( ok ); +} + +void tst_utilities::tst_safeIncrement_StepZero() +{ + uchar c = 0; + Types::safeIncrement(c, 0); + QCOMPARE(c, 1); +} + +void tst_utilities::tst_safeIncrement_GtMaxValue_Step10() +{ + uchar c = 250; + Types::safeIncrement(c, 10); + QCOMPARE(c, 4); +} + +void tst_utilities::tst_safeIncrement_GtMaxValue_Step1() +{ + uchar c = 255; + Types::safeIncrement(c); + QCOMPARE(c, 0); +} Index: unittests/tst_utilities.h =================================================================== diff -u --- unittests/tst_utilities.h (revision 0) +++ unittests/tst_utilities.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,54 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_utilities.h + * \author (last) Dara Navaei + * \date (last) 03-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 08-Jan-2020 + * + */ +#pragma once + +#include +#include + +class tst_utilities : public QObject +{ + Q_OBJECT + +public: + explicit tst_utilities(QObject *parent = nullptr); + +private slots: + void tst_getValue_len_log(); + void tst_getValue_len_lt(); + void tst_getValue_len_eq(); + void tst_getValue_len_gt(); + void tst_floatCompare_noMatch(); + void tst_floatCompare_isMatch(); + void tst_getbits_NoError(); + void tst_getbits_IsError(); + void tst_fromvariant_NoString(); + void tst_fromvariant_IsString(); + void tst_fromvariant_ByteArray(); + void tst_fromvariant_Float(); + void tst_fromvariant_UInt(); + void tst_fromvariant_Int_Pos(); + void tst_fromvariant_Int_Neg(); + void tst_fromvariant_List(); + void tst_fromvariant_Bool_True(); + void tst_fromvariant_Bool_False(); + void tst_fromvariant_Undefined(); + void tst_toStringList_Default(); + void tst_toStringList_RemoveDuplicate(); + void tst_toStringList_Prefix(); + + void tst_safeIncrement_StepZero(); + void tst_safeIncrement_GtMaxValue_Step1 (); + void tst_safeIncrement_GtMaxValue_Step10(); +}; Index: unittests/tst_views.cpp =================================================================== diff -u --- unittests/tst_views.cpp (revision 0) +++ unittests/tst_views.cpp (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,761 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_views.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#include "tst_views.h" + +// Qt + +// Project +#include "VAdjustmentResponseBase.h" +#include "VTreatmentAdjustmentUltrafiltrationState.h" +#include "FileHandler.h" +#include "VPreTreatmentDisposablesPrimeData.h" +#include "VAlarmStatus.h" +#include "MsgDefs.h" +#include "GuiGlobals.h" + +tst_views::tst_views(QObject *parent) : QObject(parent) { } + +void tst_views::VTreatmentAdjustmentsResponse_text_NoReason() +{ + View::VAdjustmentResponseBase v; + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE); + QVERIFY(v.text().isEmpty()); +} + +void tst_views::VTreatmentAdjustmentsResponse_text_WAReason() +{ + View::VAdjustmentResponseBase v; + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE); + QVERIFY(! v.text().isEmpty()); +} + +void tst_views::tst_VTreatmentAdjustmentUltrafiltrationState_text() +{ + View::VTreatmentAdjustmentUltrafiltrationState v; + + // if accepted then return empty + v.adjustment_Accepted(true); + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE); + QCOMPARE(v.text(), ""); + + // try rejected + v.adjustment_Accepted(false); + + // if not accepted and a reason passed then the parent should translate it and return + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE); + QCOMPARE(v.text(), tr("REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE")); + + // if not accepted and not running + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_UF_NOT_IN_PROGESS); + QCOMPARE(v.text(), tr("REQUEST_REJECT_REASON_UF_NOT_IN_PROGESS")); + + // if not accepted and not paused + v.adjustment_Reason(Gui::GuiRequestReasons::REQUEST_REJECT_REASON_UF_NOT_PAUSED); + QCOMPARE(v.text(), tr("REQUEST_REJECT_REASON_UF_NOT_PAUSED")); +} + +/*! + * \brief tst_views::VCreateTreatment_validation + * Tests treatment parameter validation + */ +void tst_views::tst_createTreatment_validation() +{ + + for (int i = 0; i < 15; ++i) { + View::VTreatmentCreate view; + if (i != 0) view.bloodFlowRate(view.bloodFlowRate()); + if (i != 1) view.dialysateFlowRate(view.dialysateFlowRate()); + if (i != 2) view.treatmentDuration(view.treatmentDuration()); + if (i != 3) view.heparinDispensingRate(view.heparinDispensingRate()); + if (i != 4) view.heparinBolusVolume(view.heparinBolusVolume()); + if (i != 5) view.heparinStopTime(view.heparinStopTime()); + if (i != 6) view.salineBolusVolume(view.salineBolusVolume()); + + if (i != 7) view.acidConcentrate(view.acidConcentrate()); + if (i != 8) view.bicarbonateConcentrate(view.bicarbonateConcentrate()); + if (i != 9) view.dialyzerType(view.dialyzerType()); + + if (i != 10) view.dialysateTemp(view.dialysateTemp()); + if (i != 11) view.arterialPressureLimitWindow(view.arterialPressureLimitWindow()); + if (i != 12) view.venousPressureLimitWindow(view.venousPressureLimitWindow()); + + if (i != 13) view.bloodPressureMeasureInterval(view.bloodPressureMeasureInterval()); + if (i != 14) view.rinsebackFlowRate(view.rinsebackFlowRate()); + + if (i == 15) { +// QCOMPARE(view.isbloodFlowRateSet, true); +// QCOMPARE(view.isdialysateFlowRateSet, true); +// QCOMPARE(view.isdurationSet, true); +// QCOMPARE(view.isheparinDispensingRateSet, true); +// QCOMPARE(view.isheparinBolusVolumeSet, true); +// QCOMPARE(view.isheparinStopTimeSet, true); +// QCOMPARE(view.issalineBolusVolumeSet, true); +// QCOMPARE(view.isacidConcentrateSet, true); +// QCOMPARE(view.isbicarbonateConcentrateSet, true); +// QCOMPARE(view.isdialyzerTypeSet, true); +// QCOMPARE(view.isdialysateTempSet, true); +// QCOMPARE(view.isarterialPressureLimitWindowSet, true); +// QCOMPARE(view.isarterialPressureLimitHighSet, true); +// QCOMPARE(view.isvenousPressureLimitWindowSet, true); +// QCOMPARE(view.isvenousPressureLimitAsymtrcSet, true); +// QCOMPARE(view.isbloodPressureMeasureIntervalSet, true); +// QCOMPARE(view.isrinsebackFlowRateSet, true); +// QCOMPARE(view.validate(view.treatmentData), true); + + // check getters + QCOMPARE(view.bloodFlowRate(), view.bloodFlowRate()); + QCOMPARE(view.dialysateFlowRate(), view.dialysateFlowRate()); + QCOMPARE(view.treatmentDuration(), view.treatmentDuration()); + QCOMPARE(view.heparinDispensingRate(),view.heparinDispensingRate()); + + QCOMPARE(view.heparinBolusVolume(),view.heparinBolusVolume()); + QCOMPARE(view.heparinStopTime(),view.heparinStopTime()); + QCOMPARE(view.salineBolusVolume(), view.salineBolusVolume()); + QCOMPARE(view.acidConcentrate(), view.acidConcentrate()); + QCOMPARE(view.bicarbonateConcentrate(), view.bicarbonateConcentrate()); + + QCOMPARE(view.dialyzerType(), view.dialyzerType()); + QCOMPARE(view.dialysateTemp(), view.dialysateTemp()); + QCOMPARE(view.arterialPressureLimitWindow(),view.arterialPressureLimitWindow()); + QCOMPARE(view.venousPressureLimitWindow(), view.venousPressureLimitWindow()); + QCOMPARE(view.venousPressureLimitAsymtrc(), view.venousPressureLimitAsymtrc()); + QCOMPARE(view.bloodPressureMeasureInterval(), view.bloodPressureMeasureInterval()); + QCOMPARE(view.rinsebackFlowRate(), view.rinsebackFlowRate()); + + view.doValidation(); + } + else { +// QCOMPARE(view.validate(view.treatmentData), false); + } + } +} + +/*! + * \brief tst_views::VCreateTreatment_simulate_valid_parameters + * Simulates a user selection of valid parameters + * \param view VCreateTreatment object to be set with valid parameters + */ +void tst_views::VCreateTreatment_simulate_valid_parameters(View::VTreatmentCreate &view) +{ + view.bloodFlowRate(view.bloodFlowRate()); + view.dialysateFlowRate(view.dialysateFlowRate()); + view.treatmentDuration(view.treatmentDuration()); + view.heparinDispensingRate(view.heparinDispensingRate()); + + view.heparinBolusVolume(view.heparinBolusVolume()); + view.heparinStopTime(view.heparinStopTime()); + view.salineBolusVolume(view.salineBolusVolume()); + view.acidConcentrate(view.acidConcentrate()); + view.bicarbonateConcentrate(view.bicarbonateConcentrate()); + + view.dialyzerType(view.dialyzerType()); + view.dialysateTemp(view.dialysateTemp()); + view.arterialPressureLimitWindow(view.arterialPressureLimitWindow()); + view.venousPressureLimitWindow(view.venousPressureLimitWindow()); + view.venousPressureLimitAsymtrc(view.venousPressureLimitAsymtrc()); + + view.bloodPressureMeasureInterval(view.bloodPressureMeasureInterval()); + view.rinsebackFlowRate(view.rinsebackFlowRate()); +} + +/*! + * \brief tst_views::VCreateTreatment_init_ranges + * Initializes the treatment parameter ranges + * \param obj - QJsonObject to write the ranges to + */ +void tst_views::VCreateTreatment_init_ranges(QJsonObject &obj) +{ + obj["bloodFlowRate"] = 100; + obj["bloodFlowRate"] = 500; + obj["dialysateFlowRate"] = 100; + obj["dialysateFlowRate"] = 600; + obj["treatmentDuration"] = 60; + obj["heparinDispensingRate"] = 0; + obj["heparinDispensingRate"] = 1000; + obj["heparinBolusVolume"] = 100; + obj["heparinBolusVolume"] = 2000; + obj["heparinStopTime"] = 2000; + obj["salineBolusVolume"] = 100; + obj["salineBolusVolume"] = 300; +// obj["acidConcentrateOptions"] = QJsonArray({ +// "08-1251-1", +// "08-2251-0", +// "08-3251-9" +// }), +// obj["bicarbonateConcentrateOptions"] = QJsonArray({ +// "Dimesol - BC-201" +// }), +// obj["dialyzerTypeOptions"] = QJsonArray({ +// "Nipro Elisio-H 17", +// "Nipro Elisio-H 19", +// "Fresenius Optiflux F160NRe", +// "Fresenius Optiflux F180NRe" +// }); + obj["dialysateTemp"] = 35; + obj["dialysateTemp"] = 39; + obj["arterialPressureLimitWindow"] = -300; + obj["arterialPressureLimitWindow"] = 200; +// obj["arterialPressureLimitHigh"] = -300; +// obj["arterialPressureLimitHigh"] = 200; + obj["venousPressureLimitWindow"] = -100; + obj["venousPressureLimitWindow"] = 600; + obj["venousPressureLimitAsymtrc"] = 0; + obj["venousPressureLimitAsymtrc"] = 600; + obj["bloodPressureMeasureInterval"] = 0; + obj["bloodPressureMeasureInterval"] = 30; + obj["rinsebackFlowRate"] = 50; + obj["rinsebackFlowRate"] = 150; +} + +/*! + * \brief tst_views::VCreateTreatment_validation_ranges + * Tests the treatment parameter validation ranges are checked + */ +void tst_views::VCreateTreatment_validation_ranges() +{ + View::VTreatmentCreate v; + + // check resolutions + QCOMPARE(v.bloodFlowRate(), quint32(25)); + QCOMPARE(v.dialysateFlowRate(), quint32(50 )); + QCOMPARE(v.treatmentDuration(), quint32(15 )); + QCOMPARE(v.heparinDispensingRate(), qreal(0.1)); + QCOMPARE(v.heparinBolusVolume(), qreal(0.1)); + QCOMPARE(v.heparinStopTime(), quint32(10 )); + QCOMPARE(v.salineBolusVolume(), quint32(100)); + + QCOMPARE(v.acidConcentrate(), quint32(1)); + QCOMPARE(v.bicarbonateConcentrate(), quint32(1)); + QCOMPARE(v.dialyzerType(), quint32(1)); + + QCOMPARE(v.dialysateTemp(), qreal(0.5)); + QCOMPARE(v.arterialPressureLimitWindow(), qint32(10)); +// QCOMPARE(v.arterialPressureLimitHigh(), qint32(10)); + QCOMPARE(v.venousPressureLimitWindow(), qint32(10)); + QCOMPARE(v.venousPressureLimitAsymtrc(), qint32(10)); + QCOMPARE(v.bloodPressureMeasureInterval(), quint32(5)); + QCOMPARE(v.rinsebackFlowRate(), quint32(25)); + + v.bloodFlowRate (quint32(26)); + v.dialysateFlowRate (quint32(51)); + v.treatmentDuration (quint32(16)); + v.heparinDispensingRate (qreal(0.2)); + v.heparinBolusVolume (qreal(0.2)); + v.heparinStopTime (quint32(11)); + v.salineBolusVolume (quint32(101)); + + v.acidConcentrate (quint32(2)); + v.bicarbonateConcentrate (quint32(2)); + v.dialyzerType (quint32(2)); + + v.dialysateTemp (qreal(0.6)); + v.arterialPressureLimitWindow (qint32(11)); + v.venousPressureLimitWindow (qint32(11)); + v.venousPressureLimitAsymtrc (qint32(11)); + v.bloodPressureMeasureInterval (quint32(6)); + v.rinsebackFlowRate (quint32(26)); + + QCOMPARE(v.bloodFlowRate(), quint32(26)); + QCOMPARE(v.dialysateFlowRate(), quint32(51)); + QCOMPARE(v.treatmentDuration(), quint32(16)); + QCOMPARE(v.heparinDispensingRate(), qreal(0.2)); + QCOMPARE(v.heparinBolusVolume(), qreal(0.2)); + QCOMPARE(v.heparinStopTime(), quint32(11)); + QCOMPARE(v.salineBolusVolume(), quint32(101)); + + QCOMPARE(v.acidConcentrate(), quint32(2)); + QCOMPARE(v.bicarbonateConcentrate(), quint32(2)); + QCOMPARE(v.dialyzerType(), quint32(2)); + + QCOMPARE(v.dialysateTemp(), qreal(0.6)); + QCOMPARE(v.arterialPressureLimitWindow(), qint32(11)); + QCOMPARE(v.venousPressureLimitWindow(), qint32(11)); + QCOMPARE(v.venousPressureLimitAsymtrc(), qint32(11)); + QCOMPARE(v.bloodPressureMeasureInterval(), quint32(6)); + QCOMPARE(v.rinsebackFlowRate(), quint32(26)); + + View::VTreatmentCreate view; + + // adjust quint32 enums + view.bloodFlowRate(1); + view.dialysateFlowRate(1); + view.treatmentDuration(1); + view.heparinDispensingRate(2); + view.heparinBolusVolume(1); + view.salineBolusVolume(1); + view.acidConcentrate(1); + view.bicarbonateConcentrate(1); + view.dialyzerType(1); + + view.dialysateTemp(1); + view.arterialPressureLimitWindow(2); +// view.arterialPressureLimitHigh(2); + view.venousPressureLimitWindow(2); + view.venousPressureLimitAsymtrc(2); + view.bloodPressureMeasureInterval(2); + view.rinsebackFlowRate(1); + + // setters + view.bloodFlowRate(0); + view.dialysateFlowRate(0); + view.treatmentDuration(0); + view.heparinDispensingRate(1); + + view.heparinBolusVolume(0); + view.heparinStopTime(0); + view.salineBolusVolume(0); + view.acidConcentrate(view.acidConcentrate()); + view.bicarbonateConcentrate(view.bicarbonateConcentrate()); + + view.dialyzerType(view.dialyzerType()); + view.dialysateTemp(0); + view.arterialPressureLimitWindow(1); +// view.arterialPressureLimitHigh(1); + view.venousPressureLimitWindow(1); + view.venousPressureLimitAsymtrc(1); + + view.bloodPressureMeasureInterval(1); + view.rinsebackFlowRate(0); + +// view.setTreatmentData(); + +// QCOMPARE(view.isbloodFlowRateSet, true); +// QCOMPARE(view.isdialysateFlowRateSet, true); +// QCOMPARE(view.isdurationSet, true); +// QCOMPARE(view.isheparinDispensingRateSet, true); +// QCOMPARE(view.isheparinBolusVolumeSet, true); +// QCOMPARE(view.isheparinStopTimeSet, true); +// QCOMPARE(view.issalineBolusVolumeSet, true); +// QCOMPARE(view.isacidConcentrateSet, true); +// QCOMPARE(view.isbicarbonateConcentrateSet, true); +// QCOMPARE(view.isdialyzerTypeSet, true); +// QCOMPARE(view.isdialysateTempSet, true); +// QCOMPARE(view.isarterialPressureLimitWindowSet, true); +//// QCOMPARE(view.isarterialPressureLimitHighSet, true); +// QCOMPARE(view.isvenousPressureLimitWindowSet, true); +// QCOMPARE(view.isvenousPressureLimitAsymtrcSet, true); +// QCOMPARE(view.isbloodPressureMeasureIntervalSet, true); +// QCOMPARE(view.isrinsebackFlowRateSet, true); + +// QCOMPARE(view.validate(view.treatmentData), false); + + // edge case when pressure lows are set greater than the highs +// view.arterialPressureLimitWindow(view.arterialPressureLimitHigh()+1); + view.venousPressureLimitWindow(view.venousPressureLimitAsymtrc()+1); + +// QCOMPARE(view.validate(view.treatmentData), false); + +// view.doResetCreateTreatment(); + + for (int i = 0; i < 17; ++i) { + VCreateTreatment_simulate_valid_parameters(view); + + switch (i) { + case 0: view.bloodFlowRate(view.bloodFlowRate()+1); break; + case 1: view.dialysateFlowRate(view.dialysateFlowRate()+1); break; + case 2: view.treatmentDuration(view.treatmentDuration()+1); break; + case 3: view.heparinDispensingRate(view.heparinDispensingRate()+1); break; + + case 4: view.heparinBolusVolume(view.heparinBolusVolume()+1); break; + case 5: view.heparinStopTime(view.heparinStopTime()+1); break; + case 6: view.salineBolusVolume(view.salineBolusVolume()+1); break; +// case 7: view.acidConcentrate(view.acidConcentrateOptions().length()); break; +// case 8: view.bicarbonateConcentrate(view.bicarbonateConcentrateOptions().length()); break; + +// case 9: view.dialyzerType(view.dialyzerTypeOptions().length()); break; + case 10: view.dialysateTemp(view.dialysateTemp()+1); break; + case 11: view.arterialPressureLimitWindow(view.arterialPressureLimitWindow()+1); break; +// case 12: view.arterialPressureLimitHigh(view.arterialPressureLimitHigh()+1); break; + case 13: view.venousPressureLimitWindow(view.venousPressureLimitWindow()+1); break; + case 14: view.venousPressureLimitAsymtrc(view.venousPressureLimitAsymtrc()+1); break; + + case 15: view.bloodPressureMeasureInterval(view.bloodPressureMeasureInterval()+1); break; + case 16: view.rinsebackFlowRate(view.rinsebackFlowRate()+1); break; + default: break; + } + +// QCOMPARE(view.validate(view.treatmentData), false); + view.doValidation(); + } + view.dialyzerType(-1); +// QVERIFY(!(view.dialyzerTypeOptions().length() - 1 < (int)view.dialyzerType())); + QStringList result = view.doGetOperatingParameterValues(); + QCOMPARE(result.at(2), "None"); +} + +void tst_views::VCreateTreatment_check_init() +{ + View::VTreatmentCreate view; + quint32 val = 150; view.bloodFlowRate(val); ++val; + view.bloodFlowRate(val); + view.bloodFlowRate(val); + QCOMPARE(val, view.bloodFlowRate()); + + val = 501; view.bloodFlowRate(val); ++val; + view.bloodFlowRate(val); + view.bloodFlowRate(val); + QCOMPARE(val, view.bloodFlowRate()); + + val = 100; view.dialysateFlowRate(val); ++val; + view.dialysateFlowRate(val); + QCOMPARE(val, view.dialysateFlowRate()); + + val = 600; view.dialysateFlowRate(val); ++val; + view.dialysateFlowRate(val); + view.dialysateFlowRate(val); + QCOMPARE(val, view.dialysateFlowRate()); + + val = 60; view.treatmentDuration(val); ++val; + view.treatmentDuration(val); + QCOMPARE(val, view.treatmentDuration()); + + val = 480; view.treatmentDuration(val); ++val; + view.treatmentDuration(val); + view.treatmentDuration(val); + QCOMPARE(val, view.treatmentDuration()); + + val = 0; view.heparinDispensingRate(val); ++val; + view.heparinDispensingRate(val); + view.heparinDispensingRate(val); + QCOMPARE(val, view.heparinDispensingRate()); + + val = 1000; view.heparinDispensingRate(val); ++val; + view.heparinDispensingRate(val); + view.heparinDispensingRate(val); + QCOMPARE(val, view.heparinDispensingRate()); + + val = 100; view.heparinBolusVolume(val); ++val; + view.heparinBolusVolume(val); + view.heparinBolusVolume(val); + QCOMPARE(val, view.heparinBolusVolume()); + + val = 2000; view.heparinBolusVolume(val); ++val; + view.heparinBolusVolume(val); + view.heparinBolusVolume(val); + QCOMPARE(val, view.heparinBolusVolume()); + + val = 2000; view.heparinStopTime(val); ++val; + view.heparinStopTime(val); + view.heparinStopTime(val); + QCOMPARE(val, view.heparinStopTime()); + + val = 480; view.treatmentDuration(val); ++val; + view.treatmentDuration(val); + view.treatmentDuration(val); + QCOMPARE(val, view.treatmentDuration()); + + val = 300; view.salineBolusVolume(val); ++val; + view.salineBolusVolume(val); + view.salineBolusVolume(val); + QCOMPARE(val, view.salineBolusVolume()); + + QStringList options = QStringList() << "08-1251-1" << "08-2251-0" << "08-3251-9"; + // TODO need to update +// view.acidConcentrate(options); options.append(" "); +// view.acidConcentrate(view.acidConcentrate()+1); +// view.acidConcentrateOptions(options); +// view.acidConcentrateOptions(options); +// QCOMPARE(options, view.acidConcentrateOptions()); + + options = QStringList() << "Dimesol - BC-201"; + // TODO need to update +// view.bicarbonateConcentrateOptions(options); options.append(" "); +// view.bicarbonateConcentrate(view.bicarbonateConcentrate()+1); +// view.bicarbonateConcentrateOptions(options); +// view.bicarbonateConcentrateOptions(options); +// QCOMPARE(options, view.bicarbonateConcentrateOptions()); + + options = QStringList() << "Nipro Elisio-H 17" + << "Nipro Elisio-H 19" + << "Fresenius Optiflux F160NRe" + << "Fresenius Optiflux F180NRe"; + // TODO Need to update +// view.dialyzerTypeOptions(options); options.append(" "); +// view.dialyzerType(view.dialyzerType()+1); +// view.dialyzerTypeOptions(options); +// view.dialyzerTypeOptions(options); +// QCOMPARE(options, view.dialyzerTypeOptions()); + + + val = 37; view.dialysateTemp(val); ++val; + view.dialysateTemp(val); + view.dialysateTemp(val); + QCOMPARE(val, view.dialysateTemp()); + + qint32 v; + + v = 201; view.arterialPressureLimitWindow(v); ++v; + view.arterialPressureLimitWindow(v); + view.arterialPressureLimitWindow(v); + QCOMPARE(v, view.arterialPressureLimitWindow()); + + v = 601; view.venousPressureLimitWindow(v); ++v; + view.venousPressureLimitWindow(v); + view.venousPressureLimitWindow(v); + QCOMPARE(v, view.venousPressureLimitWindow()); + + v = 601; view.venousPressureLimitAsymtrc(v); ++v; + view.venousPressureLimitAsymtrc(v); + view.venousPressureLimitAsymtrc(v); + QCOMPARE(v, view.venousPressureLimitAsymtrc()); + + val = 31; view.bloodPressureMeasureInterval(val); ++val; + view.bloodPressureMeasureInterval(val); + view.bloodPressureMeasureInterval(val); + QCOMPARE(val, view.bloodPressureMeasureInterval()); + + + val = 149; view.rinsebackFlowRate(val); ++val; + view.rinsebackFlowRate(val); + view.rinsebackFlowRate(val); + QCOMPARE(val, view.rinsebackFlowRate()); + + bool b = false; view.continueEnabled(b); + view.continueEnabled(b); + QCOMPARE(b, view.continueEnabled()); + +} + +void tst_views::VCreateTreatment_save_csv() +{ + // TODO need to update +// View::VTreatmentCreate view; +// QString csvData = view.getParameterRangesDataCSV(); +// QString filename = QString("/tmp/out_%0.csv").arg(QDateTime::currentDateTime().toString(datetimeFormat)); + +// view.saveTreatmentRangesCSV(filename); + +// QString readCsvData; +// FileHandler::read(filename, readCsvData); + +// QCOMPARE(csvData, readCsvData); + +// QVERIFY(!FileHandler::read(filename + "invalid", readCsvData)); + +} + +/*! + * \brief tst_views::VCreateTreatment_save + * Tests that VCreateTreatment saves treatment profiles properly. + */ +void tst_views::VCreateTreatment_save() +{ + // TODO need to update +// View::VTreatmentCreate view; + +// QJsonObject objectWritten { +// {"bloodFlowRate", QString::number(view.bloodFlowRate)}, +// {"dialysateFlowRate", QString::number(view.dialysateFlowRate)}, +// {"treatmentDuration", QString::number(view.treatmentDuration)}, +// {"heparinDispensingRate", QString::number(view.heparinDispensingRate)}, +// {"heparinBolusVolume", QString::number(view.heparinBolusVolume)}, +// {"heparinStopTime", QString::number(view.heparinStopTime)}, +// {"acidConcentrate", QString::number(view.acidConcentrate)}, +// {"bicarbonateConcentrate", QString::number(view.bicarbonateConcentrate)}, +// {"dialyzerType", QString::number(view.dialyzerType)}, +// {"dialysateTemp", QString::number(view.dialysateTemp)}, +// {"arterialPressureLimitWindow", QString::number(view.arterialPressureLimitWindow)}, +//// {"arterialPressureLimitHigh", QString::number(view.arterialPressureLimitHigh)}, +// {"venousPressureLimitWindow", QString::number(view.venousPressureLimitWindow)}, +// {"venousPressureLimitAsymtrc", QString::number(view.venousPressureLimitAsymtrc)}, +// {"bloodPressureMeasureInterval",QString::number(view.bloodPressureMeasureInterval)}, +// {"rinsebackFlowRate", QString::number(view.rinsebackFlowRate)} +// }; + +// QString dir = QString("/tmp/newTreatment_%0.json").arg(QDateTime::currentDateTime().toString(datetimeFormat)); + +// QString oldFilename = view.saveNewTreatment(objectWritten, dir); +// QDateTime startTime = QDateTime::currentDateTime(); +// int elapsedSeconds = 0; +// while (!QFile(oldFilename).exists()) +// { +// elapsedSeconds = startTime.secsTo(QDateTime::currentDateTime()); +// } + +// startTime = QDateTime::currentDateTime(); +// QString filename = view.saveNewTreatment(objectWritten, dir); + +// QVERIFY(oldFilename != filename); +// QVERIFY(elapsedSeconds < 0.5); + +// elapsedSeconds = 0; +// QJsonObject objectReadTemp; +// while (!FileHandler::read(filename, objectReadTemp) || (objectWritten != objectReadTemp)) +// { +// elapsedSeconds = startTime.secsTo(QDateTime::currentDateTime()); +// } + +// QVERIFY(elapsedSeconds < 0.5); + +// QJsonObject objectRead; +// QVERIFY(FileHandler::read(filename, objectRead)); +// QCOMPARE(objectWritten, objectRead); + +} + +/*! + * \brief tst_views::VCreateTreatment_enums + * Tests that enums are handled properly + */ +void tst_views::VCreateTreatment_enums() +{ + View::VTreatmentCreate view; + + Gui::GuiRequestReasons reason = Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE; + QCOMPARE(view.enumToString(reason), "REQUEST_REJECT_REASON_NONE"); + + QCOMPARE(view.enumToString(static_cast(-1)), "[-1] Unknown Rejection Reason"); + QCOMPARE(view.enumToString(static_cast(Gui::GuiRequestReasons::NUM_OF_REQUEST_REJECT_REASONS + 1)), + QString("[%0] Unknown Rejection Reason").arg(Gui::GuiRequestReasons::NUM_OF_REQUEST_REJECT_REASONS + 1)); +} + +/*! + * \brief tst_views::VCreateTreatment_json + * Tests a helper function's conversion from QJsonArray to QStringList + */ +void tst_views::VCreateTreatment_json() +{ + // TODO need to update +// View::VTreatmentCreate view; + +// QJsonArray arr; +// QStringList list; + +// QCOMPARE(view.jsonArrayToStringList(arr), list); + +// arr << "1"; +// QVERIFY(view.jsonArrayToStringList(arr) != list); + +// list << "1"; + +// QCOMPARE(view.jsonArrayToStringList(arr), list); + +// arr << QJsonValue("1") << QJsonValue("2"); +// list << "1" << "2"; + +// QCOMPARE(view.jsonArrayToStringList(arr), list); + +// arr << 3 << 4; +// list << "3" << "4"; + +// QVERIFY(view.jsonArrayToStringList(arr) != list); + +} + +/*! + * \brief tst_views::VCreateTreatment_fw_validation_response + * Tests handling of a FW validation response and parameter integrity + */ +void tst_views::VCreateTreatment_fw_validation_response() +{ + // TODO need to update +// View::VTreatmentCreate view; +// GuiActionType action = GuiActionType::ID_AdjustParametersValidationRsp; + +// for (int i = 0; i < 18; ++i) +// { +// // 0 = OK, 1,2,3 ... parameter is not OK +// QVariantList messageData; +// AdjustParametersValidationResponseData respData; +// if (i == 0) respData.mAccepted = 1; else respData.mAccepted = 0; +// if (i == 1) respData.mBloodFlowRate = 1; else respData.mBloodFlowRate = 0; +// if (i == 2) respData.mDialysateFlowRate = 1; else respData.mDialysateFlowRate = 0; +// if (i == 3) respData.mDuration = 1; else respData.mDuration = 0; +// if (i == 4) respData.mHeparinStopTime = 1; else respData.mHeparinStopTime = 0; +// if (i == 5) respData.mSalineBolus = 1; else respData.mSalineBolus = 0; +// if (i == 6) respData.mAcidConcentrate = 1; else respData.mAcidConcentrate = 0; +// if (i == 7) respData.mBicarbonateConcentrate = 1; else respData.mBicarbonateConcentrate = 0; +// if (i == 8) respData.mDialyzerType = 1; else respData.mDialyzerType = 0; +// if (i == 9) respData.mBloodPressureMeasureInterval = 1; else respData.mBloodPressureMeasureInterval= 0; +// if (i == 10) respData.mRinsebackFlowRate = 1; else respData.mRinsebackFlowRate = 0; +// if (i == 11) respData.mArterialPressureLimitWindow = 1; else respData.mArterialPressureLimitWindow = 0; +// if (i == 12) respData.mVenousPressureLimitWindow = 1; else respData.mVenousPressureLimitWindow = 0; +// if (i == 13) respData.mVenousPressureLimitAsymtrc = 1; else respData.mVenousPressureLimitAsymtrc = 0; +// if (i == 14) respData.mHeparinBolusVolume = 1; else respData.mHeparinBolusVolume = 0; +// if (i == 15) respData.mDialysateTemp = 1; else respData.mDialysateTemp = 0; +//// QVERIFY(!view.onActionReceive(respData)); +// } + +// AdjustParametersValidationRequestData dataBackup = view.treatmentData; + +// AdjustParametersValidationResponseData respData; + +// QVERIFY(view.onActionReceive(respData)); + +// view.saveTreatmentProfile(false); +// QVERIFY(!view._saveTreatmentProfile); +// view.doConfirm(); + +// view.saveTreatmentProfile(true); +// QVERIFY(view._saveTreatmentProfile); +// view.doConfirm(); + +// view.doStartTreatment(); + +// QCOMPARE(view.bloodFlowRate, dataBackup.bloodFlowRate); +// QCOMPARE(view.dialysateFlowRate, dataBackup.dialysateFlowRate); +// QCOMPARE(view.treatmentDuration, dataBackup.treatmentDuration); +// QCOMPARE(view.heparinDispensingRate, dataBackup.heparinDispensingRate); +// QCOMPARE(view.heparinBolusVolume, dataBackup.heparinBolusVolume); +// QCOMPARE(view.heparinStopTime, dataBackup.heparinStopTime); +// QCOMPARE(view.salineBolus, dataBackup.salineBolus); +// QCOMPARE(view.acidConcentrate, dataBackup.acidConcentrate); +// QCOMPARE(view.bicarbonateConcentrate, dataBackup.bicarbonateConcentrate); +// QCOMPARE(view.dialyzerType, dataBackup.dialyzerType); +// QCOMPARE(view.dialysateTemp, dataBackup.dialysateTemp); +// QCOMPARE(view.arterialPressureLimitWindow, dataBackup.arterialPressureLimitWindow); +// QCOMPARE(view.venousPressureLimitWindow, dataBackup.venousPressureLimitWindow); +// QCOMPARE(view.venousPressureLimitAsymtrc, dataBackup.venousPressureLimitWindow); +// QCOMPARE(view.bloodPressureMeasureInterval, dataBackup.bloodPressureMeasureInterval); +// QCOMPARE(view.rinsebackFlowRate, dataBackup.rinsebackFlowRate); +} + +/*! + * \brief tst_views::VCreateTreatment_load_parameter_ranges + * Tests that parameter ranges are loaded correctly from disk. + */ +void tst_views::VCreateTreatment_load_parameter_ranges() +{ + // TODO need to update +// View::VTreatmentCreate view; + +// QJsonObject obj; + +// VCreateTreatment_init_ranges(obj); + +// obj["UnexpectedParameter"] = 123; + +// QJsonDocument document(obj); + +// QString path = QString("/tmp/ranges_%0.json").arg(QDateTime::currentDateTime().toString(datetimeFormat));; + +// _FileSaver.onConcurrentSave(path, document.toJson(), false); + +// int elapsedSeconds = 0; +// QDateTime startTime = QDateTime::currentDateTime(); +// while (view.loadTreatmentParameterRanges(path) != obj) +// elapsedSeconds += startTime.secsTo(QDateTime::currentDateTime()); + +// QJsonObject readObj = view.loadTreatmentParameterRanges(path); + +// QCOMPARE(obj, readObj); +// QVERIFY(elapsedSeconds < 2); + +// readObj = view.loadTreatmentParameterRanges(QString("/tmp/wrong_path_%0.json") +// .arg(QDateTime::currentDateTime().toString(datetimeFormat))); + +// QVERIFY(obj != readObj); +} + Index: unittests/tst_views.h =================================================================== diff -u --- unittests/tst_views.h (revision 0) +++ unittests/tst_views.h (revision 0ec11323cb0a379804d3623893c5823baaaf80a4) @@ -0,0 +1,50 @@ +/*! + * + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_views.h + * \author (last) Behrouz NematiPour + * \date (last) 22-Feb-2024 + * \author (original) Behrouz NematiPour + * \date (original) 21-Apr-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project +#include "VTreatmentCreate.h" + +class tst_views : public QObject +{ + Q_OBJECT +public: + explicit tst_views(QObject *parent = nullptr); +private: + QString datetimeFormat = "MM.dd.yyyy_HH.mm.ss"; + + void VCreateTreatment_init_ranges(QJsonObject &obj); + void VCreateTreatment_simulate_valid_parameters(View::VTreatmentCreate &view); + +private slots: + void VTreatmentAdjustmentsResponse_text_NoReason(); + void VTreatmentAdjustmentsResponse_text_WAReason(); + + void tst_VTreatmentAdjustmentUltrafiltrationState_text(); + + void tst_createTreatment_validation(); + void VCreateTreatment_validation_ranges(); + void VCreateTreatment_save(); + void VCreateTreatment_json(); + void VCreateTreatment_save_csv(); + void VCreateTreatment_enums(); + void VCreateTreatment_fw_validation_response(); + void VCreateTreatment_load_parameter_ranges(); + void VCreateTreatment_check_init(); +};