-
Notifications
You must be signed in to change notification settings - Fork 256
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
Show differences when only end-of-line changes #878
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...ysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/VerifierExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Testing | ||
{ | ||
public class VerifierExtensionsTests | ||
{ | ||
[Fact] | ||
[WorkItem(876, "https://github.com/dotnet/roslyn-sdk/issues/876")] | ||
public void VerifyContentWithMixedLineEndings1() | ||
{ | ||
var baseline = | ||
"Line 1\r\n" | ||
+ "Line 2\r\n" | ||
+ "Line 3\r\n" | ||
+ "Line 4\r\n" | ||
+ "Line 5\r\n" | ||
+ "Line 6\r\n"; | ||
var modified = | ||
"Line 1\r" | ||
+ "Line 2\r\n" | ||
+ "Line 3\n" | ||
+ "Line 4\r" | ||
+ "Line 5\r\n" | ||
+ "Line 6\n"; | ||
|
||
var exception = Assert.Throws<InvalidOperationException>(() => new DefaultVerifier().EqualOrDiff(baseline, modified)); | ||
Assert.Equal( | ||
$"Actual and expected values differ. Expected shown in baseline of diff:{Environment.NewLine}" | ||
+ $"-Line 1<CR><LF>{Environment.NewLine}" | ||
+ $"+Line 1<CR>{Environment.NewLine}" | ||
+ $" Line 2<CR><LF>{Environment.NewLine}" | ||
+ $"-Line 3<CR><LF>{Environment.NewLine}" | ||
+ $"-Line 4<CR><LF>{Environment.NewLine}" | ||
+ $"+Line 3<LF>{Environment.NewLine}" | ||
+ $"+Line 4<CR>{Environment.NewLine}" | ||
+ $" Line 5<CR><LF>{Environment.NewLine}" | ||
+ $"-Line 6<CR><LF>{Environment.NewLine}" | ||
+ $"+Line 6<LF>{Environment.NewLine}", | ||
exception.Message); | ||
} | ||
|
||
[Fact] | ||
[WorkItem(876, "https://github.com/dotnet/roslyn-sdk/issues/876")] | ||
public void VerifyContentWithMixedLineEnding2() | ||
{ | ||
var baseline = | ||
"Line 1\n" | ||
+ "Line 2\n" | ||
+ "Line 3\n" | ||
+ "Line 4\n" | ||
+ "Line 5\n" | ||
+ "Line 6\n"; | ||
var modified = | ||
"Line 1\r" | ||
+ "Line 2\r\n" | ||
+ "Line 3\n" | ||
+ "Line 4\r" | ||
+ "Line 5\r\n" | ||
+ "Line 6\n"; | ||
|
||
var exception = Assert.Throws<InvalidOperationException>(() => new DefaultVerifier().EqualOrDiff(baseline, modified)); | ||
Assert.Equal( | ||
$"Actual and expected values differ. Expected shown in baseline of diff:{Environment.NewLine}" | ||
+ $"-Line 1<LF>{Environment.NewLine}" | ||
+ $"-Line 2<LF>{Environment.NewLine}" | ||
+ $"+Line 1<CR>{Environment.NewLine}" | ||
+ $"+Line 2<CR><LF>{Environment.NewLine}" | ||
+ $" Line 3<LF>{Environment.NewLine}" | ||
+ $"-Line 4<LF>{Environment.NewLine}" | ||
+ $"-Line 5<LF>{Environment.NewLine}" | ||
+ $"+Line 4<CR>{Environment.NewLine}" | ||
+ $"+Line 5<CR><LF>{Environment.NewLine}" | ||
+ $" Line 6<LF>{Environment.NewLine}", | ||
exception.Message); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
didn't review. i trust you :)
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.
I made a mistake originally but the tests caught it 👍