Index: unittests/tst_models.cpp =================================================================== diff -u -rded9f686d2c96837cc4a23f54a917d04cd257bd4 -r7cf0f527887db611c2c7db88f88932e35fdd0785 --- unittests/tst_models.cpp (.../tst_models.cpp) (revision ded9f686d2c96837cc4a23f54a917d04cd257bd4) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 7cf0f527887db611c2c7db88f88932e35fdd0785) @@ -1711,42 +1711,49 @@ // TODO need to re-evaluate to fix void tst_models::tst_MAlarmTriggered_data () { QTest::addColumn("errorIndex"); - QTest::addColumn("_xata"); - QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); - 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")); + 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 ") << 1 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i ))) << 20; + QTest::newRow("mRank ") << 2 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i+4))) << 24; + QTest::newRow("mClearTop ") << 3 << QByteArray::fromHex(QByteArray().append(front20Bytes).append(HelperFunctions_tstModel::createByteDataArray(i+8))) << 28; + } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAlarmTriggered test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MAlarmTriggered() { Model::MAlarmTriggered mData; QFETCH(int , errorIndex ); - QFETCH(QByteArray, _xata ); + QFETCH(QByteArray, data ); + QFETCH(int , expectedIndex ); int startIndex = 0; int index = errorIndex - 1; - bool ok = mData.fromByteArray(_xata, &startIndex); + 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(_xata)); QCOMPARE( index, startIndex ); } break; - case 1: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(_xata)); QCOMPARE( index, startIndex ); } break; - case 2: { index = index * sizeof mData._xata.mRank ; QVERIFY (! mData.fromByteArray(_xata)); QCOMPARE( index, startIndex ); } break; - case 3: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(_xata)); QCOMPARE( index, startIndex ); } break; + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 1: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 2: { index = index * sizeof mData._xata.mRank ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; + case 3: { index = index * sizeof mData._xata.mPriority ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( expectedIndex, startIndex ); } break; default: QVERIFY2(false, "Incorrect Test"); @@ -3754,7 +3761,7 @@ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsDGResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAdjustVersionsDGResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // -void tst_models::tst_MAdjustVersionsDGResponse_data () { +void tst_models::tst_MAdjustVersionsDGResponse_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); QTest::addColumn("expectedIndex"); @@ -4224,3 +4231,5 @@ QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AdjustParametersValidationReq, vData, payload, canId)); } + +