public void DeleteToLineBoundary () { var mode = new TestViEditMode () { Text = @" aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll", }; //move 3 words, delete to line end mode.Input ("wwwd$"); Assert.AreEqual ( @" aaa bbb eee fff ggg hhh iii jjj kkk lll", mode.Text); //move down to 0 position, move 3 words, delete to home mode.Input ("j0wwwd^"); Assert.AreEqual ( @" aaa bbb ggg hhh iii jjj kkk lll", mode.Text); //move down to 0 position, move 3 words, delete to 0 mode.Input ("j0wwwd0"); Assert.AreEqual ( @" aaa bbb ggg hhh kkk lll", mode.Text); }
public void LineMotion() { var mode = new TestViEditMode() { Text = @"abc def ghy jklmn op qrstu vwxyz", }; mode.Caret.Offset = 0; Assert.AreEqual(0, mode.Line); mode.Input('j'); Assert.AreEqual(1, mode.Line); mode.Input('k'); Assert.AreEqual(0, mode.Line); mode.Input("jjjj"); Assert.AreEqual(3, mode.Line); mode.Caret.Line = 1; mode.Caret.Column = 11; mode.Input('j'); Assert.AreEqual(4, mode.Col); mode.Input('k'); Assert.AreEqual(11, mode.Col); }
public void YankInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input("yi)"); mode.Input("$p"); // HACK: I can't figure out how to test the register, so just paste at the end Assert.AreEqual("if (foo(baz) == bar) foo(baz) == bar", mode.Text); }
public void LineDeletePaste() { var mode = new TestViEditMode() { Text = @" aaa aaa bbb bbb ccc ccc eee eee fff fff ggg ggg hhh hhh", }; //move down, enter visual line mode, move down twice -> lines 2/3/4 selected -> delete mode.Input("jjVjjd"); Assert.AreEqual( @" aaa aaa bbb bbb ggg ggg hhh hhh", mode.Text); //enter visual line mode, move down once -> lines 1/2 selected -> delete mode.Input("Vkd"); Assert.AreEqual( @" aaa aaa hhh hhh", mode.Text); //paste last delete below current line (1) mode.Input("p"); Assert.AreEqual( @" aaa aaa hhh hhh bbb bbb ggg ggg", mode.Text); //paste last delete above current line (3) mode.Input("P"); Assert.AreEqual( @" aaa aaa hhh hhh bbb bbb bbb bbb ggg ggg ggg ggg", mode.Text); Assert.AreEqual(4, mode.Line); //movement to/across boundaries, check selection still okay by deleting lines 1/2/3 mode.Input("kVlllllhhhhhhhhhhjjjhhhhhjjjjkkkkkkkkkkkkjd"); Assert.AreEqual( @" aaa aaa ggg ggg ggg ggg", mode.Text); }
public void ChangeInnerBrace_IsntConfusedByQuotes(char startBrace, char endBrace, char quote) { var text = string.Format("if {0}{2}{1}{2} == bar{1} ", startBrace, endBrace, quote); var mode = new TestViEditMode { Text = text }; RepeatChar('l', 4, mode); // Validate that our setups work. Use a specific case (the rest proved correct via induction). if (startBrace == '(' && quote == '\'') { Assert.AreEqual("if (')' == bar) ", text, "Validating that our test input because it's a bit too generic to be easy to read."); var plusMinusOneCharContext = "" + mode.GetChar(mode.Caret.Offset - 1) + mode.GetChar(mode.Caret.Offset) + mode.GetChar(mode.Caret.Offset + 1); Assert.AreEqual("(')", plusMinusOneCharContext, "The cursor is where we expect it to be."); Assert.NotNull(mode.Document.BracketMatcher); Assert.IsInstanceOf <DefaultBracketMatcher>(mode.Document.BracketMatcher); var matchingParen = mode.Document.GetMatchingBracketOffset(3); Assert.AreEqual(14, matchingParen, "Validate setup correctly enabled mode.Document functionality."); } mode.Input("ci" + endBrace); var expectedText = string.Format("if {0}{1} ", startBrace, endBrace, quote); Assert.AreEqual(expectedText, mode.Text); }
public void VisualMotion () { var mode = new TestViEditMode () { Text = @" aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt", }; //move 2 lines down, 2 words in, enter visual mode mode.Input ("jjwwv"); mode.AssertSelection (3, 8, 3, 9); //2 letters to right mode.Input ("ll"); mode.AssertSelection (3, 8, 3, 11); //4 letters to left mode.Input ("hhhh"); mode.AssertSelection (3, 9, 3, 6); //1 line up mode.Input ("k"); mode.AssertSelection (3, 9, 2, 6); //1 line up mode.Input ("k"); mode.AssertSelection (3, 9, 1, 6); //5 letters to right mode.Input ("lllll"); mode.AssertSelection (3, 9, 1, 11); //3 lines down mode.Input ("jjj"); mode.AssertSelection (3, 8, 4, 12); }
static void RepeatChar(char c, int count, TestViEditMode mode) { string input = ""; for (int i = 0; i < count; i++) { input += c; } mode.Input(input); }
public void ChangeOuterParen() { var mode = new TestViEditMode { Text = "((hello))" }; RepeatChar('l', 3, mode); mode.Input("ca)"); Assert.That(mode.Text, Is.EqualTo("()")); }
public void ChangeOuterQuote() { var mode = new TestViEditMode { Text = "'hello'" }; RepeatChar('l', 3, mode); mode.Input("ca'"); Assert.That(mode.Text, Is.Empty); }
public string ChangeInnerQuote(int col, char quote) { var mode = new TestViEditMode { Text = @"'hello' 'world\'s' 'worlder\\'s'".Replace('\'', quote) }; RepeatChar('l', col, mode); mode.Input("ci" + quote); return(mode.Text); }
public void DeleteInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input("di)"); Assert.AreEqual("if () ", mode.Text); }
public void VisualInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input("vi)"); mode.AssertSelection(1, 5, 1, 20); }
public string ChangeInnerParen(int column) { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', column, mode); mode.Input("ci)"); return(mode.Text); }
public string ChangeInnerWord(int column) { var mode = new TestViEditMode { Text = "if foo.bar[20]->baz_bay" }; RepeatChar('l', column, mode); mode.Input("ciw"); return(mode.Text); }
public void ChangeOuterParen_Multiline() { var mode = new TestViEditMode { Text = "((\n\thello\n))" }; RepeatChar('j', 1, mode); RepeatChar('l', 4, mode); mode.Input("ca)"); Assert.That(mode.Text, Is.EqualTo("()")); }
public void DeleteWord () { var mode = new TestViEditMode () { Text = @"abc def ghy jklmn op qrstu", }; mode.Caret.Offset = 0; mode.Input ("jwlldw"); Assert.AreEqual ("ghy jkop", mode.GetLine ()); }
public void ChangeLine () { var mode = new TestViEditMode () { Text = @" aaa aaa bbb bbb ccc ccc", }; mode.Input ("jwllcceeee"); Assert.AreEqual ( @" aaa aaa eeee ccc ccc", mode.Text); }
public string ChangeInnerBrace(int row, int column) { var mode = new TestViEditMode { Text = @"do { foo } forever;" }; RepeatChar('j', row, mode); RepeatChar('l', column, mode); mode.Input("ci}"); return(mode.Text); }
public void LineMotion () { var mode = new TestViEditMode () { Text = @"abc def ghy jklmn op qrstu vwxyz", }; mode.Caret.Offset = 0; Assert.AreEqual (1, mode.Line); mode.Input ('j'); Assert.AreEqual (2, mode.Line); mode.Input ('k'); Assert.AreEqual (1, mode.Line); mode.Input ("jjjj"); Assert.AreEqual (4, mode.Line); mode.Caret.Line = 2; mode.Caret.Column = 12; mode.Input ('j'); Assert.AreEqual (5, mode.Col); mode.Input ('k'); Assert.AreEqual (12, mode.Col); }
public void DeleteLine () { var mode = new TestViEditMode () { Text = @" aaa aaa bbb bbb ccc ccc", }; mode.Input ("jwlldd"); Assert.AreEqual (2, mode.Line); Assert.AreEqual (4, mode.Col); Assert.AreEqual ( @" aaa aaa ccc ccc", mode.Text); }
public string ChangeInnerBrace_WithNestedMatchingBraces(int row, int column) { var mode = new TestViEditMode { Text = @"{ do { foo } do { bar } }" }; RepeatChar('j', row, mode); RepeatChar('l', column, mode); mode.Input("ci}"); return(mode.Text); }
public void ColumnMotion () { var mode = new TestViEditMode () { Text = "Test\nText" }; Assert.AreEqual (1, mode.Col); mode.Input ('l'); Assert.AreEqual (2, mode.Col); mode.Input ("ll"); Assert.AreEqual (4, mode.Col); mode.Input ('l'); Assert.AreEqual (4, mode.Col); mode.Input ("hh"); Assert.AreEqual (2, mode.Col); mode.Input ('h'); Assert.AreEqual (1, mode.Col); mode.Input ('h'); Assert.AreEqual (1, mode.Col); }
public void LineDeletePaste () { var mode = new TestViEditMode () { Text = @" aaa aaa bbb bbb ccc ccc eee eee fff fff ggg ggg hhh hhh", }; //move down, enter visual line mode, move down twice -> lines 2/3/4 selected -> delete mode.Input ("jjVjjd"); Assert.AreEqual ( @" aaa aaa bbb bbb ggg ggg hhh hhh", mode.Text); //enter visual line mode, move down once -> lines 1/2 selected -> delete mode.Input ("Vkd"); Assert.AreEqual ( @" aaa aaa hhh hhh", mode.Text); //paste last delete below current line (1) mode.Input ("p"); Assert.AreEqual ( @" aaa aaa hhh hhh bbb bbb ggg ggg", mode.Text); //paste last delete above current line (3) mode.Input ("P"); Assert.AreEqual ( @" aaa aaa hhh hhh bbb bbb bbb bbb ggg ggg ggg ggg", mode.Text); Assert.AreEqual (5, mode.Line); //movement to/across boundaries, check selection still okay by deleting lines 1/2/3 mode.Input ("kVlllllhhhhhhhhhhjjjhhhhhjjjjkkkkkkkkkkkkjd"); Assert.AreEqual ( @" aaa aaa ggg ggg ggg ggg", mode.Text); }
public void ChangeInnerBrace_IsntConfusedByQuotes (char startBrace, char endBrace, char quote) { var text = string.Format ("if {0}{2}{1}{2} == bar{1} ", startBrace, endBrace, quote); var mode = new TestViEditMode { Text = text }; RepeatChar ('l', 4, mode); // Validate that our setups work. Use a specific case (the rest proved correct via induction). if (startBrace == '(' && quote == '\'') { Assert.AreEqual ("if (')' == bar) ", text, "Validating that our test input because it's a bit too generic to be easy to read."); var plusMinusOneCharContext = "" + mode.GetChar(mode.Caret.Offset-1) + mode.GetChar(mode.Caret.Offset) + mode.GetChar(mode.Caret.Offset+1); Assert.AreEqual ("(')", plusMinusOneCharContext, "The cursor is where we expect it to be."); Assert.NotNull(mode.Document.BracketMatcher); Assert.IsInstanceOf<DefaultBracketMatcher>(mode.Document.BracketMatcher); var matchingParen = mode.Document.GetMatchingBracketOffset (3); Assert.AreEqual (14, matchingParen, "Validate setup correctly enabled mode.Document functionality."); } mode.Input ("ci" + endBrace); var expectedText = string.Format ("if {0}{1} ", startBrace, endBrace, quote); Assert.AreEqual (expectedText, mode.Text); }
public void ChangeOuterParen_Multiline() { var mode = new TestViEditMode { Text = "((\n\thello\n))" }; RepeatChar('j', 1, mode); RepeatChar('l', 4, mode); mode.Input ("ca)"); Assert.That (mode.Text, Is.EqualTo ("()")); }
static void RepeatChar(char c, int count, TestViEditMode mode) { string input = ""; for (int i = 0; i < count; i++) input += c; mode.Input(input); }
public void ChangeOuterQuote() { var mode = new TestViEditMode { Text = "'hello'" }; RepeatChar('l', 3, mode); mode.Input ("ca'"); Assert.That (mode.Text, Is.Empty); }
public void ChangeOuterParen() { var mode = new TestViEditMode { Text = "((hello))" }; RepeatChar('l', 3, mode); mode.Input ("ca)"); Assert.That (mode.Text, Is.EqualTo ("()")); }
public void YankInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input ("yi)"); mode.Input ("$p"); // HACK: I can't figure out how to test the register, so just paste at the end Assert.AreEqual ("if (foo(baz) == bar) foo(baz) == bar", mode.Text); }
public string ChangeInnerQuote (int col, char quote) { var mode = new TestViEditMode { Text = @"'hello' 'world\'s' 'worlder\\'s'".Replace ('\'', quote) }; RepeatChar('l', col, mode); mode.Input ("ci" + quote); return mode.Text; }
public string ChangeInnerWord(int column) { var mode = new TestViEditMode { Text = "if foo.bar[20]->baz_bay" }; RepeatChar('l', column, mode); mode.Input ("ciw"); return mode.Text; }
public void DeleteInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input ("di)"); Assert.AreEqual ("if () ", mode.Text); }
public string ChangeInnerBrace_WithNestedMatchingBraces(int row, int column) { var mode = new TestViEditMode { Text = @"{ do { foo } do { bar } }" }; RepeatChar('j', row, mode); RepeatChar('l', column, mode); mode.Input ("ci}"); return mode.Text; }
public string ChangeInnerBrace (int row, int column) { var mode = new TestViEditMode { Text = @"do { foo } forever;" }; RepeatChar ('j', row, mode); RepeatChar ('l', column, mode); mode.Input ("ci}"); return mode.Text; }
public string ChangeInnerParen(int column) { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', column, mode); mode.Input ("ci)"); return mode.Text; }
public void VisualInnerParen() { var mode = new TestViEditMode { Text = "if (foo(baz) == bar) " }; RepeatChar('l', 3, mode); mode.Input ("vi)"); mode.AssertSelection (1, 5, 1, 20); }