8000 Added test for blobToBlob compare · dotdevelop/libgit2sharp@9733e74 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9733e74

Browse files
committed
Added test for blobToBlob compare
1 parent 3c777dc commit 9733e74

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System.IO;
1+
using LibGit2Sharp.Tests.TestHelpers;
2+
using System.IO;
23
using System.Linq;
34
using System.Text;
4-
using LibGit2Sharp.Tests.TestHelpers;
55
using Xunit;
66

77
namespace LibGit2Sharp.Tests
@@ -202,6 +202,34 @@ public void ComparingBlobsWithNoSpacesIndentHeuristicOptionMakesNoDifference()
202202
}
203203
}
204204

205+
[Fact]
206+
public void DiffSetsTheAddedAndDeletedLinesCorrectly()
207+
{
208+
var path = SandboxStandardTestRepoGitDir();
209+
210+
using (var repo = new Repository(path))
211+
{
212+
var oldContent =
213+
@"1
214+
2
215+
3
216+
4";
217+
218+
var newContent =
219+
@"1
220+
2
221+
3
222+
5";
223+
var oldBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(oldContent)));
224+
var newBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(newContent)));
225+
226+
ContentChanges changes = repo.Diff.Compare(oldBlob, newBlob);
227+
228+
Assert.Single(changes.AddedLines);
229+
Assert.Single(changes.DeletedLines);
230+
}
231+
}
232+
205233
static string CanonicalChangedLines(ContentChanges changes)
206234
{
207235
// Create an ordered representation of lines that have been added or removed

0 commit comments

Comments
 (0)
0