mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[ai-completion] ML-3971 add a test case for preProcessLines
GitOrigin-RevId: 5a050504c56542aabdafe5d3b4a8fc11ce3d1150
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d61150f7b8
commit
5eba1ea80b
@@ -4,14 +4,42 @@ import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class RelaxedExactMatchTest {
|
||||
@Test
|
||||
fun `test line pre-processing`() {
|
||||
val processed = RelaxedSimilarityUtils.preProcessLines(
|
||||
completion = "turn main\ndef fun",
|
||||
private data class ProcessingTestCase(
|
||||
val prefix: String,
|
||||
val completion: String,
|
||||
val suffix: String,
|
||||
val strip: Boolean,
|
||||
)
|
||||
private val processingCases = listOf(
|
||||
ProcessingTestCase(
|
||||
prefix = "hi\nre",
|
||||
completion = "turn main\ndef fun",
|
||||
suffix = "ction()::\nendfun",
|
||||
stripChars = false,
|
||||
)
|
||||
Assertions.assertEquals(listOf("return main", "def function()::"), processed)
|
||||
strip = false,
|
||||
) to listOf("return main", "def function()::"),
|
||||
ProcessingTestCase(
|
||||
prefix = "class MyClas",
|
||||
completion = "s:\ndef __init__(self):\npass\n",
|
||||
suffix = "\n def method(self):\n pass\n",
|
||||
strip = false,
|
||||
) to listOf("class MyClass:", "def __init__(self):", "pass"),
|
||||
ProcessingTestCase(
|
||||
prefix = "class MyClas",
|
||||
completion = "s:\ndef __init__(self):\npass\n",
|
||||
suffix = "",
|
||||
strip = true,
|
||||
) to listOf("classMyClass", "def__init__self", "pass"),
|
||||
)
|
||||
|
||||
private fun ProcessingTestCase.process(): List<String> = RelaxedSimilarityUtils.preProcessLines(
|
||||
completion = completion,
|
||||
prefix = prefix,
|
||||
suffix = suffix,
|
||||
stripChars = strip,
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `test line pre-processing`() = processingCases.forEach {
|
||||
(inputs, outputs) -> Assertions.assertEquals(outputs, inputs.process())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user