Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Cansdale <jcansdale@github.com>2018-12-19 21:25:17 +0300
committerJamie Cansdale <jcansdale@github.com>2018-12-19 21:25:17 +0300
commite0636802a901a57ed9a6498b2ee3220cf64ac951 (patch)
tree666526b99bac746d04d1c332f07562ff2a83056d
parent98be00ae5269f468d25394986e0e42716294cf7a (diff)
Test for when IndentHeuristic makes no difference
When compared files don't contain spaces, the --indent-heuristic option won't make a difference.
-rw-r--r--LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs37
1 files changed, 36 insertions, 1 deletions
diff --git a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs
index 9173674b..0107294a 100644
--- a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs
+++ b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs
@@ -128,7 +128,7 @@ namespace LibGit2Sharp.Tests
}
[Fact]
- public void ComparingBlobsWithIndentHeuristicOptionMakesADifference()
+ public void ComparingBlobsWithNoSpacesAndIndentHeuristicOptionMakesADifference()
{
var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path))
@@ -165,5 +165,40 @@ namespace LibGit2Sharp.Tests
Assert.NotEqual(changes0.Patch, changes1.Patch);
}
}
+
+
+ [Fact]
+ public void ComparingBlobsWithNoSpacesIndentHeuristicOptionMakesNoDifference()
+ {
+ var path = SandboxStandardTestRepoGitDir();
+ using (var repo = new Repository(path))
+ {
+ var oldContent =
+@" 1
+ 2
+ a
+ b
+ 3
+ 4";
+ var newContent =
+@" 1
+ 2
+ a
+ b
+ a
+ b
+ 3
+ 4";
+ var oldBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(oldContent)));
+ var newBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(newContent)));
+ var noIndentHeuristicOption = new CompareOptions { IndentHeuristic = false };
+ var indentHeuristicOption = new CompareOptions { IndentHeuristic = true };
+
+ ContentChanges changes0 = repo.Diff.Compare(oldBlob, newBlob, noIndentHeuristicOption);
+ ContentChanges changes1 = repo.Diff.Compare(oldBlob, newBlob, indentHeuristicOption);
+
+ Assert.Equal(changes0.Patch, changes1.Patch);
+ }
+ }
}
}