forked from VsVim/VsVim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnapshotLineUtilTest.cs
62 lines (53 loc) · 1.69 KB
/
SnapshotLineUtilTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Linq;
using EditorUtils.UnitTest;
using Microsoft.VisualStudio.Text;
using NUnit.Framework;
namespace Vim.UnitTest
{
[TestFixture]
public class SnapshotLineUtilTest : VimTestBase
{
static string[] s_lines = new string[]
{
"summary description for this line",
"some other line",
"running out of things to make up"
};
ITextBuffer _buffer = null;
ITextSnapshot _snapshot = null;
public void Create(params string[] lines)
{
_buffer = CreateTextBuffer(lines);
_snapshot = _buffer.CurrentSnapshot;
}
[TearDown]
public void TearDown()
{
_buffer = null;
_snapshot = null;
}
[Test]
public void GetPoints1()
{
Create("foo");
var points = SnapshotLineUtil.GetPoints(Path.Forward, _buffer.CurrentSnapshot.GetLineFromLineNumber(0));
var text = points.Select(x => x.GetChar().ToString()).Aggregate((x, y) => x + y);
Assert.AreEqual("foo",text);
}
[Test]
public void GetExtent1()
{
Create("foo");
var span = SnapshotLineUtil.GetExtent(_buffer.GetLine(0));
Assert.AreEqual("foo", span.GetText());
}
[Test]
public void GetExtentIncludingLineBreak1()
{
Create("foo", "baz");
var span = SnapshotLineUtil.GetExtentIncludingLineBreak(_buffer.GetLine(0));
Assert.AreEqual("foo" + Environment.NewLine, span.GetText());
}
}
}