| 131 | } |
| 132 | |
| 133 | void TestVariantData::testInsertRows() { |
| 134 | double expectedValue = 42.12309; |
| 135 | QVariant firstRow(expectedValue); |
| 136 | |
| 137 | QList<QVariant> secondRow; |
| 138 | secondRow << QVariant("kkoo") << QVariant(771) << QVariant(3.14); |
| 139 | |
| 140 | QStringList thirdRow; |
| 141 | thirdRow << "one" << "two" << "three"; |
| 142 | |
| 143 | QString stringOne("hey testing"); |
| 144 | |
| 145 | QtCSV::VariantData varData; |
| 146 | varData.insertRow(0, firstRow); |
| 147 | |
| 148 | QVERIFY2(1 == varData.rowCount(), "Wrong number of rows"); |
| 149 | QVERIFY2(1 == varData.rowValues(0).size(), |
| 150 | "Wrong number of elements in first row"); |
| 151 | |
| 152 | auto diff = expectedValue - varData.rowValues(0).at(0).toDouble(); |
| 153 | QVERIFY2(diff <= EPSILON, "Wrong number in first row"); |
| 154 | |
| 155 | varData.addEmptyRow(); |
| 156 | varData.addRow(stringOne); |
| 157 | varData.insertRow(1, secondRow); |
| 158 | varData.insertRow(100, thirdRow); |
| 159 | |
| 160 | QVERIFY2(5 == varData.rowCount(), "Wrong number of rows"); |
| 161 | |
| 162 | diff = expectedValue - varData.rowValues(0).at(0).toDouble(); |
| 163 | QVERIFY2(diff <= EPSILON, "Wrong data for first row"); |
| 164 | |
| 165 | QStringList resultSecondRow = varData.rowValues(1); |
| 166 | QVERIFY2(secondRow.at(0).toString() == resultSecondRow.at(0) && |
| 167 | secondRow.at(1).toString() == resultSecondRow.at(1) && |
| 168 | secondRow.at(2).toString() == resultSecondRow.at(2), |
| 169 | "Wrong data for second row"); |
| 170 | |
| 171 | QVERIFY2(QStringList() == varData.rowValues(2), "Wrong data for third row"); |
| 172 | |
| 173 | QVERIFY2((QStringList() << stringOne) == varData.rowValues(3), |
| 174 | "Wrong data for fourth row"); |
| 175 | |
| 176 | QVERIFY2(thirdRow == varData.rowValues(4), "Wrong data for fifth row"); |
| 177 | } |
| 178 | |
| 179 | void TestVariantData::testCompareForEquality() { |
| 180 | QStringList firstRow, secondRow; |
nothing calls this directly
no test coverage detected