MCPcopy Create free account
hub / github.com/KDE/kdiff3 / runTest

Function runTest

test/alignmenttest.cpp:255–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255bool runTest(QString file1, QString file2, QString file3, QString expectedResultFile, QString actualResultFile, qsizetype maxLength)
256{
257 gOptions = std::make_unique <Options>();
258 Diff3LineList actualDiff3LineList, expectedDiff3LineList;
259 QByteArray encoding="UTF-8";
260 QTextStream out(stdout);
261
262 gOptions->m_bIgnoreCase = false;
263 gOptions->m_bDiff3AlignBC = true;
264
265 SourceData m_sd1, m_sd2, m_sd3;
266
267 QString msgprefix = "Running test with ";
268 QString filepattern = QString(file1).replace("_base.", "_*.");
269 QString msgsuffix = QString("...%1").arg("", maxLength - filepattern.length());
270 out << msgprefix << filepattern << msgsuffix;
271 if(verbose)
272 {
273 out << endl;
274 }
275 out.flush();
276
277 m_sd1.setFilename(file1);
278 m_sd1.readAndPreprocess(encoding, false);
279
280 m_sd2.setFilename(file2);
281 m_sd2.readAndPreprocess(encoding, false);
282
283 m_sd3.setFilename(file3);
284 m_sd3.readAndPreprocess(encoding, false);
285
286 determineFileAlignment(m_sd1, m_sd2, m_sd3, actualDiff3LineList);
287
288 loadExpectedAlignmentFile(expectedResultFile, expectedDiff3LineList);
289
290 Diff3LineList::iterator p_actual = actualDiff3LineList.begin();
291 Diff3LineList::iterator p_expected = expectedDiff3LineList.begin();
292 bool equal = true;
293 bool sequenceError = false;
294 bool consistencyError = false;
295
296 equal = (actualDiff3LineList.size() == expectedDiff3LineList.size());
297
298 int latestLineA = -1;
299 int latestLineB = -1;
300 int latestLineC = -1;
301 while(equal && (p_actual != actualDiff3LineList.end()))
302 {
303 /* Check if all line numbers are in sequence */
304 if(p_actual->getLineA().isValid())
305 {
306 if(p_actual->getLineA() <= latestLineA)
307 {
308 sequenceError = true;
309 }
310 else
311 {
312 latestLineA = p_actual->getLineA();

Callers 1

mainFunction · 0.85

Calls 15

determineFileAlignmentFunction · 0.85
getLineFromSourceDataFunction · 0.85
dataIsConsistentFunction · 0.85
printDiff3ListFunction · 0.85
writeActualAlignmentFileFunction · 0.85
setFilenameMethod · 0.80
readAndPreprocessMethod · 0.80
endMethod · 0.80
getLineAMethod · 0.80
getLineBMethod · 0.80
getLineCMethod · 0.80

Tested by

no test coverage detected