Index: unittests/tst_models.cpp =================================================================== diff -u -re1315c140c18028c7771d56d72eeeaab8580eb3e -r51bfd04e3f843dd29f7171a678eb000434efd18c --- unittests/tst_models.cpp (.../tst_models.cpp) (revision e1315c140c18028c7771d56d72eeeaab8580eb3e) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 51bfd04e3f843dd29f7171a678eb000434efd18c) @@ -43,12 +43,14 @@ #include "MAdjustHDServiceDatesResponse.h" #include "MAdjustHDServiceModeResponse.h" #include "MAdjustHDAlarmVolumeResponse.h" +#include "MAdjustHDDateTimeResponse.h" // -- HD Data #include "MHDAccelerometerData.h" #include "MHDBloodLeakData.h" #include "MHDSyringePumpData.h" #include "MTreatmentRangesData.h" + // -- HD Treatment Data #include "MTreatmentStatesData.h" #include "MTreatmentBloodFlowData.h" @@ -58,6 +60,7 @@ #include "MTreatmentRinsebackData.h" #include "MTreatmentTimeData.h" #include "MTreatmentSalineData.h" + // -- HD PreTreatment Data #include "MPreTreatmentStatesData.h" //-- HD Treatment log averge Data @@ -75,8 +78,16 @@ #include "MAdjustDGVersionsResponse.h" #include "MAdjustDGDateTimeResponse.h" #include "MAdjustDGServiceDatesResponse.h" + //-- DG Disinfect Data #include "MDisinfectStatesData.h" + +//-- DG Post Data +#include "MDGPostSingleResultData.h" + +//-- DG Pretreatment Data +#include "MDGFilterFlushData.h" + //-- DG Data #include "MDGAccelerometerData.h" #include "MDGTemperaturesData.h" @@ -87,9 +98,9 @@ #include "MDGROPumpData.h" #include "MDGHeatersData.h" #include "MDGReservoirData.h" +#include "MDGOperationModeData.h" #include "MDGValvesStatesData.h"// -#include "MDGOperationModeData.h"// #include "MHDOperationModeData.h"// #include "MPreTreatmentDisposablesPrimeData.h"// @@ -795,6 +806,50 @@ } } +// -- Adjust HD Date Time Response +/* + * Teststatus + * Fail: None +*/ +void tst_models::tst_MAdjustHDDateTimeResponse_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")); +} + +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 << 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; + } +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD ADJUSTMENT TREATMENT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // -- Adjust Blood Dialysate Response /* @@ -1368,40 +1423,50 @@ // -- Alarm Triggered Data /* * Teststatus - * Fail: Cannot test + * Fail: msg complete, mrank,mclearTop */ -//void tst_models::tst_MAlarmTriggered_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")); -//} +void tst_models::tst_MAlarmTriggered_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" )); + QTest::newRow("mPriority ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mPriority ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mPriority ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mPriority ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mRank ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mRank ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mRank ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mRank ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mClearTop ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mClearTop ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mClearTop ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mClearTop ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} -//void tst_models::tst_MAlarmTriggered() { -// Model::MAlarmTriggered mData; +void tst_models::tst_MAlarmTriggered() { + Model::MAlarmTriggered mData; -// QFETCH(int , errorIndex ); -// QFETCH(QByteArray, data ); + 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 + 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.; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; -// default: -// QVERIFY2(false, "Incorrect Test"); -// break; -// } -//} + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._xata.mPriority; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._xata.mRank ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._xata.mClearTop; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD DATA MESSAGES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // -- HD Accelerometer data @@ -2731,6 +2796,94 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DG POST MESSAGES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// -- DG Post Single Result Data +/* +* Teststatus +* Fail: None +*/ +void tst_models::tst_MDGPostSingleResult_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("mResult ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mResult ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mResult ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mResult ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mIndex ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mIndex ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mIndex ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mIndex ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} + +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 << 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.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; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DG PRETREATMENT MESSAGES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// -- DG Filter Flush Data +/* +* Teststatus +* Fail: None +*/ +void tst_models::tst_MDGFilterFlush_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("mTimeout ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mTimeout ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mTimeout ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mTimeout ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mCountdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mCountdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mCountdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mCountdown ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} + +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 << 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; + } +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DG DATA MESSAGES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // -- DG Temperature Data /* @@ -2973,6 +3126,10 @@ } // -- Drain Pump Data +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGDrainPumpData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -2994,7 +3151,7 @@ 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")); } -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + void tst_models::tst_DGDrainPumpData() { Model::MDGDrainPump mData; @@ -3022,6 +3179,10 @@ } // -- Load Cell Readings +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGLoadCellReadingsData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -3070,7 +3231,11 @@ } } -// Pressures Data +// -- Pressures Data +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGPressuresData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -3120,6 +3285,10 @@ } // -- DG RO Pump data +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGROPumpData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -3169,6 +3338,10 @@ } // -- Heaters data +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGHeatersData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -3186,7 +3359,7 @@ QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); } -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + void tst_models::tst_DGHeatersData() { Model::MDGHeaters mData; @@ -3214,6 +3387,10 @@ // -- Reservoir Data +/* + * Teststatus + * Fail: None +*/ void tst_models::tst_DGReservoirData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); @@ -3231,7 +3408,7 @@ 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")); } -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // + void tst_models::tst_DGReservoirData() { Model::MDGReservoir mData; @@ -3256,3 +3433,42 @@ break; } } + +// -- DGOperationMode data +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")); +} + +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; + } +}