Browse Source

Fixed bug in formatting unit tests.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
836e17859c
  1. 3
      ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs
  2. 11
      ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs
  3. 1
      ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs

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

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

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

@ -35,6 +35,11 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -35,6 +35,11 @@ namespace ICSharpCode.NRefactory.FormattingTests
Offset = offset;
Length = length;
}
public override string ToString ()
{
return string.Format ("[Delimiter: Offset={0}, Length={1}]", Offset, Length);
}
}
static IEnumerable<Delimiter> FindDelimiter (string text)
@ -74,6 +79,11 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -74,6 +79,11 @@ namespace ICSharpCode.NRefactory.FormattingTests
this.Length = length;
this.DelimiterLength = delimiterLength;
}
public override string ToString ()
{
return string.Format ("[Segment: Offset={0}, Length={1}, DelimiterLength={2}]", Offset, Length, DelimiterLength);
}
}
Segment Get (int number)
@ -101,6 +111,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -101,6 +111,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
foreach (var change in changes) {
text = text.Substring (0, change.Offset) + change.InsertedText + text.Substring (change.Offset + change.RemovedChars);
}
delimiters = new List<Delimiter> (FindDelimiter (text));
}
#region ITextEditorAdapter implementation

1
ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs

@ -94,7 +94,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -94,7 +94,6 @@ namespace ICSharpCode.NRefactory.CSharp
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < blankLines; i++)
sb.Append (data.EolMarker);
Console.WriteLine (loc.Line + "--- " + line);
int removedChars = line < data.LineCount ? data.GetLineOffset (line) - start : 0;
AddChange (start, removedChars, sb.ToString ());
}

Loading…
Cancel
Save