Browse Source

Fix formatting tests on Windows with git autocrlf enabled.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
119bc9b564
  1. 2
      ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs
  2. 24
      ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs
  3. 8
      ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

2
ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs

@ -133,7 +133,7 @@ using (IDisposable b = null) { @@ -133,7 +133,7 @@ using (IDisposable b = null) {
int start = result.GetOffset (5, 1);
int end = result.GetOffset (result.LineCount - 1, 1);
string text = result.GetText (start, end - start).Trim ();
expectedOutput = expectedOutput.Replace ("\n", "\n\t\t");
expectedOutput = NormalizeNewlines(expectedOutput).Replace ("\n", "\n\t\t");
Assert.AreEqual (expectedOutput, text);
}

24
ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs

@ -1100,12 +1100,12 @@ return (Test)null; @@ -1100,12 +1100,12 @@ return (Test)null;
}
}");
Assert.AreEqual (@"class Test
Assert.AreEqual (NormalizeNewlines(@"class Test
{
Test ()
{
}
}", result.Text);
}"), result.Text);
}
[Test()]
@ -1290,13 +1290,13 @@ return (Test)null; @@ -1290,13 +1290,13 @@ return (Test)null;
}
}");
Assert.AreEqual (@"class FooBar
Assert.AreEqual (NormalizeNewlines(@"class FooBar
{
public void Foo ()
{
Test ();
}
}", result.Text);
}"), result.Text);
}
[Test()]
@ -1403,14 +1403,14 @@ return (Test)null; @@ -1403,14 +1403,14 @@ return (Test)null;
}
}
}");
Assert.AreEqual (@"class FooBar
Assert.AreEqual (NormalizeNewlines(@"class FooBar
{
public int this [int a, int b] {
get {
return a + b;
}
}
}", result.Text);
}"), result.Text);
}
[Test()]
@ -1489,13 +1489,13 @@ return (Test)null; @@ -1489,13 +1489,13 @@ return (Test)null;
this[0] = 5;
}
}");
Assert.AreEqual (@"class Test
Assert.AreEqual (NormalizeNewlines(@"class Test
{
void TestMe ()
{
this[ 0 ] = 5;
}
}", result.Text);
}"), result.Text);
}
@ -1513,13 +1513,13 @@ return (Test)null; @@ -1513,13 +1513,13 @@ return (Test)null;
this[0] = 5;
}
}");
Assert.AreEqual (@"class Test
Assert.AreEqual (NormalizeNewlines(@"class Test
{
void TestMe ()
{
this [0] = 5;
}
}", result.Text);
}"), result.Text);
}
@ -1574,11 +1574,11 @@ return (Test)null; @@ -1574,11 +1574,11 @@ return (Test)null;
int[][] b;
}");
Assert.AreEqual (@"class Test
Assert.AreEqual (NormalizeNewlines(@"class Test
{
int [] a;
int [][] b;
}", result.Text);
}"), result.Text);
}

8
ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

@ -51,6 +51,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -51,6 +51,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
protected static IDocument GetResult (CSharpFormattingOptions policy, string input)
{
input = NormalizeNewlines(input);
var adapter = new ReadOnlyDocument (input);
var visitor = new AstFormattingVisitor (policy, adapter, factory);
visitor.EolMarker = "\n";
@ -62,6 +63,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -62,6 +63,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
protected static IDocument Test (CSharpFormattingOptions policy, string input, string expectedOutput)
{
expectedOutput = NormalizeNewlines(expectedOutput);
IDocument doc = GetResult(policy, input);
if (expectedOutput != doc.Text) {
Console.WriteLine (doc.Text);
@ -69,9 +71,15 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -69,9 +71,15 @@ namespace ICSharpCode.NRefactory.FormattingTests
Assert.AreEqual (expectedOutput, doc.Text);
return doc;
}
protected static string NormalizeNewlines(string input)
{
return input.Replace("\r\n", "\n");
}
protected static void Continue (CSharpFormattingOptions policy, IDocument document, string expectedOutput)
{
expectedOutput = NormalizeNewlines(expectedOutput);
var visitior = new AstFormattingVisitor (policy, document, factory);
visitior.EolMarker = "\n";
var compilationUnit = new CSharpParser ().Parse (new StringReader (document.Text), "test.cs");

Loading…
Cancel
Save