-
Notifications
You must be signed in to change notification settings - Fork 899
Failing test: CanShowChangesForAFileWithWin1250EncodingContent #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,5 +560,36 @@ public void CallingCompareWithAnUnsupportedGenericParamThrows() | |
Assert.Throws<LibGit2SharpException>(() => repo.Diff.Compare<string>()); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void CanShowChangesForAFileWithWin1250EncodingContent() | ||
{ | ||
const string testFile = "windows1250.txt"; | ||
|
||
string repoPath = CloneStandardTestRepo(); | ||
using (var repo = new Repository(repoPath)) | ||
{ | ||
// Create the file in the workdir | ||
string testFileFullPath = Path.Combine(repo.Info.WorkingDirectory, testFile); | ||
Encoding win1250Encoding = Encoding.GetEncoding("windows-1250"); | ||
Assert.NotNull(win1250Encoding); | ||
const string testFileContent = "Content in windows-1250 encoding." | ||
+ "\u0105\u0119\u0107\u0142\u00F3\u015b\u017a\u017c" | ||
+ "\n"; | ||
File.WriteAllText(testFileFullPath, testFileContent, win1250Encoding); | ||
|
||
//compare changes | ||
var changes = repo.Diff.Compare<Patch>(repo.Head.Tip.Tree, | ||
DiffTargets.WorkingDirectory, | ||
new[] { testFile }).FirstOrDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can it be like that gitextensions@7d1348b? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but from the other hand we expect that patch contains the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hear you, but the test explicitly passes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I could believe that that happen, but I prefer to ensure that it actually happen. If by accident there exists other, but very similar file (name and content) and if there will be a bug in |
||
|
||
Assert.NotNull(changes); | ||
string expectedHunkHeader = "@@ -0,0 +1 @@\n+"; | ||
int hunkHeaderIdx = changes.Patch.IndexOf(expectedHunkHeader); | ||
Assert.True(hunkHeaderIdx > 0, "Hunk header expected: " + expectedHunkHeader); | ||
string fileContentFromPatch = changes.Patch.Substring(hunkHeaderIdx + expectedHunkHeader.Length); | ||
Assert.Equal(testFileContent, fileContentFromPatch); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Courtesy of M. @dahlbyk 😉