Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mikkrg@microsoft.com>2017-11-10 18:30:32 +0300
committerMike Krüger <mikkrg@microsoft.com>2017-11-10 18:30:32 +0300
commit0213869a5a6add2a1f561fa127eb8dbd636e8a48 (patch)
treec3a88659037f09d1332257937ff0e060af60f798 /main/src/core/MonoDevelop.TextEditor.Tests
parentddb43559d5bcc83b095a1b521e4cfd987073837f (diff)
[TextEditor] Fixed bug in segment tree.
Interesting issue only happens at the end of the document.
Diffstat (limited to 'main/src/core/MonoDevelop.TextEditor.Tests')
-rw-r--r--main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SegmentTreeTests.cs17
-rw-r--r--main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs5
2 files changed, 18 insertions, 4 deletions
diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SegmentTreeTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SegmentTreeTests.cs
index 9cf425b09b..1790d2a684 100644
--- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SegmentTreeTests.cs
+++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SegmentTreeTests.cs
@@ -88,8 +88,8 @@ namespace Mono.TextEditor.Tests
collection.Add (new TreeSegment (92, 51));
collection.Add (new TreeSegment (42, 77));
collection.Add (new TreeSegment (36, 128));
- collection.UpdateOnTextReplace (this, new TextChangeEventArgs (0, 0, new string(' ', 355), null));
-
+ collection.UpdateOnTextReplace (this, new TextChangeEventArgs (0, 0, new string (' ', 355), null));
+
Assert.AreEqual (0, collection.Count);
}
@@ -110,5 +110,18 @@ namespace Mono.TextEditor.Tests
collection.Remove (seg4);
Assert.AreEqual (2, collection.Segments.Count ());
}
+
+ [Test ()]
+ public void TestInsertAtEnd ()
+ {
+ var collection = new SegmentTree<TreeSegment> ();
+
+ collection.Add (new TreeSegment (10, 0));
+
+ collection.UpdateOnTextReplace (this, new TextChangeEventArgs (10, 10, null, "\n"));
+ var seg = collection.Segments.First ();
+ Assert.AreEqual (10, seg.Offset);
+ }
+
}
}
diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
index 0604de5c3d..84a1e188b3 100644
--- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
+++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs
@@ -29,6 +29,7 @@ using NUnit.Framework;
using Mono.TextEditor.Highlighting;
using MonoDevelop.Ide.Editor.Highlighting;
using System.Text;
+using System.Threading.Tasks;
namespace Mono.TextEditor.Tests
{
@@ -147,7 +148,7 @@ namespace Mono.TextEditor.Tests
}
[Test]
- public void TestChunkValidity()
+ public async Task TestChunkValidity()
{
const string text = @"System.Console.WriteLine();";
var data = new TextEditorData (new TextDocument (@"namespace FooBar
@@ -160,7 +161,7 @@ namespace Mono.TextEditor.Tests
//data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode (data.Document, "text/x-csharp");
//data.ColorStyle = SyntaxModeService.GetColorStyle ("Light");
var line = data.GetLine (5);
- var chunks = data.GetChunks (line, line.Offset + 3, line.Length - 3);
+ var chunks = await data.GetChunks (line, line.Offset + 3, line.Length - 3);
StringBuilder sb = new StringBuilder ();
foreach (var chunk in chunks)
sb.Append (data.GetTextAt (chunk));