| 124 | |
| 125 | |
| 126 | void TestMIParser::doTestResult(const KDevMI::MI::Value& actualValue, const QVariant& expectedValue) |
| 127 | { |
| 128 | if (expectedValue.typeId() == qMetaTypeId<QString>()) { |
| 129 | QCOMPARE((int)actualValue.kind, (int)KDevMI::MI::Value::StringLiteral); |
| 130 | QCOMPARE(actualValue.literal(), expectedValue.toString()); |
| 131 | } else if (expectedValue.typeId() == qMetaTypeId<QVariantList>()) { |
| 132 | QCOMPARE(actualValue.kind, KDevMI::MI::Value::List); |
| 133 | |
| 134 | const auto expectedList = expectedValue.toList(); |
| 135 | QCOMPARE(actualValue.size(), expectedList.size()); |
| 136 | for (int i = 0; i < expectedList.size(); ++i) { |
| 137 | doTestResult(actualValue[i], expectedList[i]); |
| 138 | } |
| 139 | } else if (expectedValue.typeId() == qMetaTypeId<QVariantMap>()) { |
| 140 | QCOMPARE(actualValue.kind, KDevMI::MI::Value::Tuple); |
| 141 | |
| 142 | const auto expectedMap = expectedValue.toMap(); |
| 143 | |
| 144 | for (auto it = expectedMap.begin(), end = expectedMap.end(); it != end; ++it) { |
| 145 | const auto& expectedMapField = it.key(); |
| 146 | QVERIFY(actualValue.hasField(expectedMapField)); |
| 147 | const auto& expectedMapValue = it.value(); |
| 148 | doTestResult(actualValue[expectedMapField], expectedMapValue); |
| 149 | } |
| 150 | } else { |
| 151 | QFAIL("Using unexpected QVariant type"); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |
| 156 | void TestMIParser::testParseLine() |