| 6 | #include "history.h" |
| 7 | |
| 8 | void TestIDE::testDiff() |
| 9 | { |
| 10 | QString origText = |
| 11 | "foo\n" |
| 12 | "bar\n" |
| 13 | "qux\n" |
| 14 | "baz"; |
| 15 | QString newText = |
| 16 | "foo\n" |
| 17 | "hello\n" |
| 18 | "bar\n" |
| 19 | "baz\n" |
| 20 | "world"; |
| 21 | FileDiff diff(origText, newText); |
| 22 | auto result = diff.diff(); |
| 23 | QCOMPARE(result.size(), 3); |
| 24 | QCOMPARE(result[0].kind, FileDiff::EntryType::Insertion); |
| 25 | QCOMPARE(result[0].line, 2); |
| 26 | QCOMPARE(result[0].text, "hello"); |
| 27 | QCOMPARE(result[1].kind, FileDiff::EntryType::Deletion); |
| 28 | QCOMPARE(result[1].line, 3); |
| 29 | QCOMPARE(result[1].text, "qux"); |
| 30 | QCOMPARE(result[2].kind, FileDiff::EntryType::Insertion); |
| 31 | QCOMPARE(result[2].line, 5); |
| 32 | QCOMPARE(result[2].text, "world"); |
| 33 | } |
| 34 | |
| 35 | void TestIDE::testDiffApply() |
| 36 | { |