Index: unittests/tst_models.cpp =================================================================== diff -u -rbf645acccabb7b5a84801620c4f7fa0b0e6878e0 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- unittests/tst_models.cpp (.../tst_models.cpp) (revision bf645acccabb7b5a84801620c4f7fa0b0e6878e0) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -47,6 +47,9 @@ #include "MAlarmTriggered.h" #include "MAlarmCleared.h" +#include "mtreatmentparameters.h" +#include "mtreatmentparametersresp.h" + // #define CONSOLEOUT /*! @@ -1247,8 +1250,8 @@ } QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(0)), tr("")); - QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(-1)), tr("Alarm Not Recognized.")); - QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(599)), tr("Alarm Not Recognized.")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(-1)), tr("ALARM_ID_UNDEFINED [-1]")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(599)), tr("ALARM_ID_UNDEFINED [599]")); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1376,3 +1379,78 @@ break; } } + +void tst_models::tst_MTreatmentParametersResp_data() +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("requestValid") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("bloodFlowRate") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("dialysateFlowRate") << 1 << QByteArray::fromHex(QByteArray("00" "00")); + QTest::newRow("duration") << 1 << QByteArray::fromHex(QByteArray("00" "00" "00")); + QTest::newRow("heparinDispensingRate") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00")); + QTest::newRow("heparinBolusVolume") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00")); + QTest::newRow("heparinStopTime") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00")); + QTest::newRow("salineBolus") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("acidConcentrate") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("bicarbonateConcentrate") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("dialyzerType") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("dialysateTemp") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("arterialPressureLimitLow") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("arterialPressureLimitHigh") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("venousPressureLimitLow") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("venousPressureLimitHigh") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("bloodPressureMeasureInterval") << 5 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("rinsebackFlowRate") << 5 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); +} + + +void tst_models::tst_MTreatmentParametersResp() +{ + Model::TreatmentParametersResp 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.requestValid ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 2: { index = index * sizeof mData._data.bloodFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 3: { index = index * sizeof mData._data.dialysateFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 4: { index = index * sizeof mData._data.duration ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 5: { index = index * sizeof mData._data.heparinDispensingRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 6: { index = index * sizeof mData._data.heparinBolusVolume ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 7: { index = index * sizeof mData._data.heparinStopTime ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 8: { index = index * sizeof mData._data.salineBolus ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 9: { index = index * sizeof mData._data.acidConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 10: { index = index * sizeof mData._data.bicarbonateConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 11: { index = index * sizeof mData._data.dialyzerType ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 12: { index = index * sizeof mData._data.dialysateTemp ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 13: { index = index * sizeof mData._data.arterialPressureLimitLow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 14: { index = index * sizeof mData._data.arterialPressureLimitHigh ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 15: { index = index * sizeof mData._data.venousPressureLimitLow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 16: { index = index * sizeof mData._data.venousPressureLimitHigh ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 17: { index = index * sizeof mData._data.bloodPressureMeasureInterval; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 18: { index = index * sizeof mData._data.rinsebackFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +}