Index: unittests/tst_models.cpp =================================================================== diff -u -r3b4fd62b510f6b09d663e35b0cadc93050e6a6f0 -r7edcaf054062754370e0abd165f17ca9941b7d07 --- unittests/tst_models.cpp (.../tst_models.cpp) (revision 3b4fd62b510f6b09d663e35b0cadc93050e6a6f0) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 7edcaf054062754370e0abd165f17ca9941b7d07) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file tst_models.cpp - * \author (last) Peter Lucia - * \date (last) 07-Jul-2020 + * \author (last) Behrouz NematiPour + * \date (last) 13-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 * @@ -38,10 +38,12 @@ #include "MTreatmentFlowsData.h" #include "MTreatmentTimeData.h" #include "MTreatmentPressureOcclusionData.h" +#include "MTreatmentSalineData.h" #include "MTreatmentAdjustUltrafiltrationStateResponse.h" #include "MTreatmentAdjustUltrafiltrationEditResponse.h" #include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" +#include "MTreatmentAdjustSalineResponse.h" #include "MAlarmStatusData.h" #include "MAlarmTriggered.h" @@ -691,7 +693,7 @@ 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("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")); @@ -915,7 +917,7 @@ 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")); + 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")); QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray()); QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00")); QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); @@ -981,7 +983,7 @@ 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")); + 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")); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); @@ -1047,7 +1049,7 @@ 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")); + 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")); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); @@ -1159,7 +1161,7 @@ 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")); + 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("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray()); QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00")); QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); @@ -1469,7 +1471,31 @@ { Model::TreatmentParametersResp mData; +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData 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")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentSalineBolusData() { + Model::MTreatmentSaline mData; + QFETCH(int , errorIndex ); QFETCH(QByteArray, data ); @@ -1479,69 +1505,14 @@ Q_UNUSED(ok) #ifdef CONSOLEOUT - qDebug() << "index: " << index << "\n" - << "errorIndex: " << errorIndex << "\n" - << "startIndex: " << startIndex << "\n" - << "ok: " << ok << "\n" - << "data: " << data; + 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.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; + 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; @@ -1654,5 +1625,48 @@ QVERIFY(data.rinsebackFlowRate == tempData.rinsebackFlowRate); } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MSalineBolusResponse_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("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MSalineBolusResponse() { + 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 << 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.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; } }