mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
diff: cleanup tests
This commit is contained in:
@@ -223,12 +223,12 @@ abstract class DiffTestCase : UsefulTestCase() {
|
||||
|
||||
open class Trio<out T>(val data1: T, val data2: T, val data3: T) {
|
||||
companion object {
|
||||
fun <V : Any> from(f: (ThreeSide) -> V): Trio<V> = Trio(f(ThreeSide.LEFT), f(ThreeSide.BASE), f(ThreeSide.RIGHT))
|
||||
fun <V> from(f: (ThreeSide) -> V): Trio<V> = Trio(f(ThreeSide.LEFT), f(ThreeSide.BASE), f(ThreeSide.RIGHT))
|
||||
}
|
||||
|
||||
fun <V : Any> map(f: (T) -> V): Trio<V> = Trio(f(data1), f(data2), f(data3))
|
||||
fun <V> map(f: (T) -> V): Trio<V> = Trio(f(data1), f(data2), f(data3))
|
||||
|
||||
fun <V : Any> map(f: (T, ThreeSide) -> V): Trio<V> = Trio(f(data1, ThreeSide.LEFT), f(data2, ThreeSide.BASE), f(data3, ThreeSide.RIGHT))
|
||||
fun <V> map(f: (T, ThreeSide) -> V): Trio<V> = Trio(f(data1, ThreeSide.LEFT), f(data2, ThreeSide.BASE), f(data3, ThreeSide.RIGHT))
|
||||
|
||||
fun forEach(f: (T, ThreeSide) -> Unit): Unit {
|
||||
f(data1, ThreeSide.LEFT)
|
||||
|
||||
@@ -514,11 +514,7 @@ class ComparisonUtilAutoTest : DiffTestCase() {
|
||||
}
|
||||
|
||||
private fun countNonWhitespaceCharacters(line: CharSequence): Int {
|
||||
var count = 0
|
||||
for (i in 0 until line.length) {
|
||||
if (!StringUtil.isWhiteSpace(line[i])) count++
|
||||
}
|
||||
return count
|
||||
return (0 until line.length).count { !StringUtil.isWhiteSpace(line[it]) }
|
||||
}
|
||||
|
||||
private fun getFirstLastLines(text: Document, start: Int, end: Int): Couple<CharSequence>? {
|
||||
|
||||
@@ -198,7 +198,7 @@ class MergeResolveUtilTest : DiffTestCase() {
|
||||
}
|
||||
|
||||
private fun testGreedy(base: String, left: String, right: String, expected: String?) {
|
||||
test(base, left, right, expected, true);
|
||||
test(base, left, right, expected, true)
|
||||
}
|
||||
|
||||
private fun test(base: String, left: String, right: String, expected: String?, isGreedy: Boolean = false) {
|
||||
@@ -209,7 +209,7 @@ class MergeResolveUtilTest : DiffTestCase() {
|
||||
|
||||
private fun test(base: String, left: String, right: String, expectedSimple: String?, expectedGreedy: String?) {
|
||||
val simpleResult = MergeResolveUtil.tryResolve(left, base, right)
|
||||
val greedyResult = MergeResolveUtil.tryGreedyResolve(left, base, right);
|
||||
val greedyResult = MergeResolveUtil.tryGreedyResolve(left, base, right)
|
||||
|
||||
assertEquals(expectedSimple, simpleResult, "Simple")
|
||||
assertEquals(expectedGreedy, greedyResult, "Greedy")
|
||||
|
||||
@@ -32,7 +32,7 @@ class MergeAutoTest : MergeTestBase() {
|
||||
private fun doUndoTest(seed: Long, runs: Int, maxLength: Int) {
|
||||
doTest(seed, runs, maxLength) { text1, text2, text3, debugData ->
|
||||
testN(text1, text2, text3) {
|
||||
if (changes.size == 0) {
|
||||
if (changes.isEmpty()) {
|
||||
assertEquals(text1, text2)
|
||||
assertEquals(text1, text3)
|
||||
assertEquals(text2, text3)
|
||||
|
||||
@@ -99,7 +99,7 @@ abstract class MergeTestBase : DiffTestCase() {
|
||||
val editor: EditorEx = viewer.editor
|
||||
val document: Document = editor.document
|
||||
|
||||
private val textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
|
||||
private val textEditor = TextEditorProvider.getInstance().getTextEditor(editor)
|
||||
private val undoManager = UndoManager.getInstance(project!!)
|
||||
|
||||
fun change(num: Int): TextMergeChange {
|
||||
@@ -114,7 +114,7 @@ abstract class MergeTestBase : DiffTestCase() {
|
||||
//
|
||||
|
||||
fun runActionByTitle(name: String): Boolean {
|
||||
val action = actions.filter { name.equals(it.templatePresentation.text) }
|
||||
val action = actions.filter { name == it.templatePresentation.text }
|
||||
assertTrue(action.size == 1, action.toString())
|
||||
return runAction(action[0])
|
||||
}
|
||||
@@ -396,7 +396,7 @@ abstract class MergeTestBase : DiffTestCase() {
|
||||
if (other !is ViewerState) return false
|
||||
|
||||
if (!StringUtil.equals(content, other.content)) return false
|
||||
if (!changes.equals(other.changes)) return false
|
||||
if (changes != other.changes) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -411,9 +411,9 @@ abstract class MergeTestBase : DiffTestCase() {
|
||||
if (other !is ChangeState) return false
|
||||
|
||||
if (!StringUtil.equals(content, other.content)) return false
|
||||
if (!starts.equals(other.starts)) return false
|
||||
if (!ends.equals(other.ends)) return false
|
||||
if (!resolved.equals(other.resolved)) return false
|
||||
if (starts != other.starts) return false
|
||||
if (ends != other.ends) return false
|
||||
if (resolved != other.resolved) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -175,6 +175,7 @@ class LineNumberConvertorCorrectorTest : UsefulTestCase() {
|
||||
assertEquals(minimumMatched2, counter2)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun printMatchings() {
|
||||
for (i in 0..length * 2 - 1) {
|
||||
val value = convertor.convert1(i)
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ class UnifiedFragmentBuilderAutoTest : DiffTestCase() {
|
||||
doAutoTest(seed, runs) { debugData ->
|
||||
debugData.put("MaxLength", maxLength)
|
||||
|
||||
var text1 = DocumentImpl(generateText(maxLength))
|
||||
var text2 = DocumentImpl(generateText(maxLength))
|
||||
val text1 = DocumentImpl(generateText(maxLength))
|
||||
val text2 = DocumentImpl(generateText(maxLength))
|
||||
|
||||
debugData.put("Text1", textToReadableFormat(text1.charsSequence))
|
||||
debugData.put("Text2", textToReadableFormat(text2.charsSequence))
|
||||
|
||||
Reference in New Issue
Block a user