Index: unittests/tst_models.cpp =================================================================== diff -u -r68af13f9f6502069c79b7b63b5d9481abb2f270f -r97fc44f948bd39ed0b4238558a16bf99f750bf5e --- unittests/tst_models.cpp (.../tst_models.cpp) (revision 68af13f9f6502069c79b7b63b5d9481abb2f270f) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 97fc44f948bd39ed0b4238558a16bf99f750bf5e) @@ -1384,49 +1384,84 @@ { 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("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") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00")); - QTest::newRow("dialysateFlowRate") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" )); - QTest::newRow("duration") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); - QTest::newRow("heparinDispensingRate") << 5 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); - QTest::newRow("heparinBolusVolume") << 6 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); - QTest::newRow("heparinStopTime") << 7 << 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" )); - QTest::newRow("salineBolus") << 8 << 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" )); - QTest::newRow("acidConcentrate") << 9 << 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" )); - QTest::newRow("bicarbonateConcentrate") << 10 << 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" )); - QTest::newRow("dialyzerType") << 11 << 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" )); - QTest::newRow("dialysateTemp") << 12 << 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" )); - QTest::newRow("arterialPressureLimitLow") << 13 << 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" )); - QTest::newRow("arterialPressureLimitHigh") << 14 << 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" )); - QTest::newRow("venousPressureLimitLow") << 15 << 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" )); - QTest::newRow("venousPressureLimitHigh") << 16 << 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" )); - QTest::newRow("bloodPressureMeasureInterval") << 17 << 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" )); - QTest::newRow("rinsebackFlowRate") << 18 << 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" )); + + QTest::newRow("bloodFlowRate") << 2 << QByteArray::fromHex(QByteArray( + "00" "00" "00" "00")); + + QTest::newRow("dialysateFlowRate") << 3 << QByteArray::fromHex(QByteArray( + "00" "00" "00" "00" "00" "00" "00" "00" )); + + QTest::newRow("duration") << 4 << QByteArray::fromHex(QByteArray( + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); + + QTest::newRow("heparinDispensingRate") << 5 << QByteArray::fromHex(QByteArray( + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); + + QTest::newRow("heparinBolusVolume") << 6 << QByteArray::fromHex(QByteArray( + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" )); + + QTest::newRow("heparinStopTime") << 7 << 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" )); + QTest::newRow("salineBolus") << 8 << 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" )); + + QTest::newRow("acidConcentrate") << 9 << 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" )); + + QTest::newRow("bicarbonateConcentrate") << 10 << 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" )); + + QTest::newRow("dialyzerType") << 11 << 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" )); + + QTest::newRow("dialysateTemp") << 12 << 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" )); + + QTest::newRow("arterialPressureLimitLow") << 13 << 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" )); + + QTest::newRow("arterialPressureLimitHigh") << 14 << 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" )); + + QTest::newRow("venousPressureLimitLow") << 15 << 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")); + + QTest::newRow("venousPressureLimitHigh") << 16 << 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")); + + QTest::newRow("bloodPressureMeasureInterval") << 17 << 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" )); + + QTest::newRow("rinsebackFlowRate") << 18 << 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" )); } @@ -1451,25 +1486,62 @@ << "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; + 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; @@ -1530,3 +1602,59 @@ } } } + + +void tst_models::tst_MTreatmentParameters_fromVariantList() +{ + Model::TreatmentParameters mData; + + QVariantList list; + for (int i = 0; i < 20; ++i) + { + + list.append(QVariant(1)); + TreatmentData tempData = mData.fromVariantList(list); + if (i == 16) { + QVERIFY(1 == tempData.bloodFlowRate); + QVERIFY(1 == tempData.dialysateFlowRate); + QVERIFY(1 == tempData.duration); + QVERIFY(1 == tempData.heparinDispensingRate); + QVERIFY(1 == tempData.heparinBolusVolume); + QVERIFY(1 == tempData.heparinStopTime); + QVERIFY(1 == tempData.salineBolus); + QVERIFY(1 == tempData.acidConcentrate); + QVERIFY(1 == tempData.bicarbonateConcentrate); + QVERIFY(1 == tempData.dialyzerType); + QVERIFY(1 == tempData.dialysateTemp); + QVERIFY(1 == tempData.arterialPressureLimitLow); + QVERIFY(1 == tempData.arterialPressureLimitHigh); + QVERIFY(1 == tempData.venousPressureLimitLow); + QVERIFY(1 == tempData.venousPressureLimitHigh); + QVERIFY(1 == tempData.bloodPressureMeasureInterval); + QVERIFY(1 == tempData.rinsebackFlowRate); + } + else { + TreatmentData data; + QVERIFY(data.bloodFlowRate == tempData.bloodFlowRate); + QVERIFY(data.dialysateFlowRate == tempData.dialysateFlowRate); + QVERIFY(data.duration == tempData.duration); + QVERIFY(data.heparinDispensingRate == tempData.heparinDispensingRate); + QVERIFY(data.heparinBolusVolume == tempData.heparinBolusVolume); + QVERIFY(data.heparinStopTime == tempData.heparinStopTime); + QVERIFY(data.salineBolus == tempData.salineBolus); + QVERIFY(data.acidConcentrate == tempData.acidConcentrate); + QVERIFY(data.bicarbonateConcentrate == tempData.bicarbonateConcentrate); + QVERIFY(data.dialyzerType == tempData.dialyzerType); + QVERIFY(data.dialysateTemp == tempData.dialysateTemp); + QVERIFY(data.arterialPressureLimitLow == tempData.arterialPressureLimitLow); + QVERIFY(data.arterialPressureLimitHigh == tempData.arterialPressureLimitHigh); + QVERIFY(data.venousPressureLimitLow == tempData.venousPressureLimitLow); + QVERIFY(data.venousPressureLimitHigh == tempData.venousPressureLimitHigh); + QVERIFY(data.bloodPressureMeasureInterval== tempData.bloodPressureMeasureInterval); + QVERIFY(data.rinsebackFlowRate == tempData.rinsebackFlowRate); + + } + } + + +}