diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-08-06 15:03:26 +0300 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@digia.com> | 2014-08-11 20:20:20 +0200 |
commit | d03927f373b62fffe5e4e94780888174205c0964 (patch) | |
tree | b4a86c9e5f9cfea29bf94e79dc1873f61c910c43 /src/plugins/diffeditor/diffeditorplugin.cpp | |
parent | 121dfaec138e5eb819c1d8e0f02d09705010cfc7 (diff) | |
download | qt-creator-d03927f373b62fffe5e4e94780888174205c0964.tar.gz |
DiffEditor: Fix no newline handling
Change-Id: I3278ae80d7ee010942122723b3e8bb8c729e7182
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/diffeditor/diffeditorplugin.cpp')
-rw-r--r-- | src/plugins/diffeditor/diffeditorplugin.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 6c6346998a..655f39bff1 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -299,6 +299,25 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data() rows.clear(); rows << RowData(_("ABCD")); + rows << RowData(_(""), TextLineData::Separator); + rows << RowData(_(""), TextLineData::Separator); + chunk.rows = rows; + patchText = header + _("@@ -1,2 +1,1 @@\n" + "-ABCD\n" + "-\n" + "+ABCD\n" + "\\ No newline at end of file\n"); + + QTest::newRow("Two last EOLs removed") << chunk + << fileName + << fileName + << true + << patchText; + + /////////// + + rows.clear(); + rows << RowData(_("ABCD")); rows << RowData(TextLineData::Separator, _("")); chunk.rows = rows; patchText = header + _("@@ -1,1 +1,1 @@\n" @@ -418,6 +437,26 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data() << fileName << false << patchText; + + /////////// + + rows.clear(); + rows << RowData(_("ABCD")); + rows << RowData(TextLineData::Separator, _("")); + rows << RowData(_(""), _("EFGH")); + chunk.rows = rows; + patchText = header + _("@@ -1,1 +1,3 @@\n" + " ABCD\n" + "+\n" + "+EFGH\n" + "\\ No newline at end of file\n"); + + QTest::newRow("Blank line followed by No newline") + << chunk + << fileName + << fileName + << true + << patchText; } void DiffEditor::Internal::DiffEditorPlugin::testMakePatch() @@ -748,6 +787,37 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data() QTest::newRow("2 chunks - first ends with blank line") << patch << fileDataList4; + + ////////////// + + patch = _("diff --git a/file foo.txt b/file foo.txt\n" + "index 1234567..9876543 100644\n" + "--- a/file foo.txt\n" + "+++ b/file foo.txt\n" + "@@ -1,1 +1,3 @@ void DiffEditor::ctor()\n" + " ABCD\n" + "+\n" + "+EFGH\n" + "\\ No newline at end of file\n"); + + fileData1.leftFileInfo = DiffFileInfo(_("file foo.txt"), _("1234567")); + fileData1.rightFileInfo = DiffFileInfo(_("file foo.txt"), _("9876543")); + fileData1.fileOperation = FileData::ChangeFile; + chunkData1.leftStartingLineNumber = 0; + chunkData1.rightStartingLineNumber = 0; + rows1.clear(); + rows1 << RowData(_("ABCD")); + rows1 << RowData(TextLineData::Separator, _("")); + rows1 << RowData(_(""), _("EFGH")); + chunkData1.rows = rows1; + fileData1.chunks.clear(); + fileData1.chunks << chunkData1; + + QList<FileData> fileDataList5; + fileDataList5 << fileData1; + + QTest::newRow("Blank line followed by No newline") << patch + << fileDataList5; } void DiffEditor::Internal::DiffEditorPlugin::testReadPatch() |