Skip to content

Commit e063680

Browse files
committed
Test for when IndentHeuristic makes no difference
When compared files don't contain spaces, the --indent-heuristic option won't make a difference.
1 parent 98be00a commit e063680

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void ComparingTwoNullBlobsReturnsAnEmptyContentChanges()
128128
}
129129

130130
[Fact]
131-
public void ComparingBlobsWithIndentHeuristicOptionMakesADifference()
131+
public void ComparingBlobsWithNoSpacesAndIndentHeuristicOptionMakesADifference()
132132
{
133133
var path = SandboxStandardTestRepoGitDir();
134134
using (var repo = new Repository(path))
@@ -165,5 +165,40 @@ public void ComparingBlobsWithIndentHeuristicOptionMakesADifference()
165165
Assert.NotEqual(changes0.Patch, changes1.Patch);
166166
}
167167
}
168+
169+
170+
[Fact]
171+
public void ComparingBlobsWithNoSpacesIndentHeuristicOptionMakesNoDifference()
172+
{
173+
var path = SandboxStandardTestRepoGitDir();
174+
using (var repo = new Repository(path))
175+
{
176+
var oldContent =
177+
@" 1
178+
2
179+
a
180+
b
181+
3
182+
4";
183+
var newContent =
184+
@" 1
185+
2
186+
a
187+
b
188+
a
189+
b
190+
3
191+
4";
192+
var oldBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(oldContent)));
193+
var newBlob = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.UTF8.GetBytes(newContent)));
194+
var noIndentHeuristicOption = new CompareOptions { IndentHeuristic = false };
195+
var indentHeuristicOption = new CompareOptions { IndentHeuristic = true };
196+
197+
ContentChanges changes0 = repo.Diff.Compare(oldBlob, newBlob, noIndentHeuristicOption);
198+
ContentChanges changes1 = repo.Diff.Compare(oldBlob, newBlob, indentHeuristicOption);
199+
200+
Assert.Equal(changes0.Patch, changes1.Patch);
201+
}
202+
}
168203
}
169204
}

0 commit comments

Comments
 (0)