1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-25 02:46:01 +01:00

Move more tests to src

This commit is contained in:
Filipp Vakhitov 2023-12-10 00:49:38 +02:00 committed by lippfi
parent b4e831a81f
commit 6386770ff3
2 changed files with 37 additions and 32 deletions
src/test/java/org/jetbrains/plugins/ideavim/regex
vim-engine/src/test/kotlin/com/maddyhome/idea/vim/regexp/internal

View File

@ -8,8 +8,11 @@
package org.jetbrains.plugins.ideavim.regex
import com.intellij.openapi.editor.VisualPosition
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.CommandState
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.mark.VimMark
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.regexp.VimRegex
@ -117,4 +120,38 @@ class VimRegexEngineTest : VimTestCase() {
val result = findAll("\\%>'m...")
assertEquals(result, listOf(TextRange(6, 9)))
}
@Test
fun `test text is inside visual area`() {
configureByText("${c}Lorem Ipsum")
typeText("v$")
val result = findAll("\\%VLorem Ipsu\\%Vm")
assertEquals(result, listOf(TextRange(0, 11)))
}
@Test
fun `test text is not inside visual area`() {
configureByText("${c}Lorem Ipsum")
typeText("vw")
val result = findAll("\\%VLorem Ipsu\\%Vm")
assertEquals(result, emptyList())
}
@Test
fun `test cursor and visual belong to the same cursor`() {
configureByText("Lorem Ipsum")
val caretModel = fixture.editor.caretModel
typeText("v") // a workaround to trigger visual mode
caretModel.addCaret(VisualPosition(0, 2))
val caret = caretModel.getCaretAt(VisualPosition(0, 2))!!
caret.setSelection(0, 5)
caretModel.addCaret(VisualPosition(0, 0))
caretModel.addCaret(VisualPosition(0, 1))
caretModel.addCaret(VisualPosition(0, 3))
val result = findAll("\\%V.\\{-}\\%#.")
assertEquals(result, listOf(TextRange(0, 3)))
}
}

View File

@ -1614,24 +1614,6 @@ class VimRegexEngineTest {
)
}
@Test
fun `test text is inside visual area`() {
doTest(
"${START}${VISUAL_START}Lorem Ipsum$CARET${VISUAL_END}${END}",
"\\%VLorem Ipsu\\%Vm"
)
}
@Test
fun `test text is not inside visual area`() {
assertFailure(
"${VISUAL_START}Lorem $CARET${VISUAL_END}Ipsum",
"\\%VLorem Ipsu\\%Vm"
)
}
@Test
fun `test mark does not exist`() {
assertFailure(
@ -1640,20 +1622,6 @@ class VimRegexEngineTest {
)
}
@Test
fun `test cursor and visual belong to the same cursor`() {
doTest(
"${START}Lor${END}em Ipsum",
"\\%V.\\{-}\\%#.",
listOf(
mockCaret(0),
mockCaret(1),
mockCaret(2, Pair(0, 5)),
mockCaret(3),
)
)
}
@Test
fun `test pattern with multiple cursors at different indexes fails`() {
assertFailure(