--- /dev/null
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.diff
+
+import com.intellij.testFramework.UsefulTestCase
+import junit.framework.TestCase
+
+public fun assertTrue(actual: Boolean, message: String = "") {
+ TestCase.assertTrue(message, actual)
+}
+
+public fun assertFalse(actual: Boolean, message: String = "") {
+ TestCase.assertFalse(message, actual)
+}
+
+public fun assertEquals(expected: Any?, actual: Any?, message: String = "") {
+ TestCase.assertEquals(message, expected, actual)
+}
+
+public fun assertEmpty(collection: Collection<*>, message: String = "") {
+ UsefulTestCase.assertEmpty(message, collection)
+}
+
+public fun assertOrderedEquals(expected: Collection<*>, actual: Collection<*>, message: String = "") {
+ UsefulTestCase.assertOrderedEquals(message, actual, expected)
+}
+
+public fun assertNull(actual: Any?, message: String = "") {
+ TestCase.assertNull(message, actual)
+}
+
+public fun assertNotNull(actual: Any?, message: String = "") {
+ TestCase.assertNotNull(message, actual)
+}
*/
package com.intellij.diff.comparison
+import com.intellij.diff.assertTrue
import com.intellij.openapi.util.text.StringUtil
import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.text.CharSequenceSubSequence
import java.util.Random
import java.util.concurrent.atomic.AtomicLong
-import kotlin.test.assertTrue
public abstract class AutoTestCase : UsefulTestCase() {
protected val RNG: Random = Random()
*/
package com.intellij.diff.comparison
+import com.intellij.diff.assertEquals
+import com.intellij.diff.assertFalse
+import com.intellij.diff.assertTrue
import com.intellij.diff.fragments.DiffFragment
import com.intellij.diff.fragments.LineFragment
import com.intellij.diff.util.DiffUtil
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.util.text.StringUtil
import com.intellij.util.containers.HashMap
-import kotlin.test.assertEquals
-import kotlin.test.assertFalse
-import kotlin.test.assertTrue
public class ComparisonUtilAutoTest : AutoTestCase() {
private var oldRegistryValue: Boolean = false
*/
package com.intellij.diff.comparison
+import com.intellij.diff.assertEquals
+import com.intellij.diff.assertOrderedEquals
+import com.intellij.diff.assertTrue
import com.intellij.diff.fragments.DiffFragment
import com.intellij.diff.fragments.LineFragment
import com.intellij.openapi.editor.Document
import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.containers.ContainerUtil
import java.util.BitSet
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
public abstract class ComparisonUtilTestBase : UsefulTestCase() {
private var oldRegistryValue: Boolean = false
// Impl
//
- private fun doLineTest(before: Document, after: Document, matchings: Couple<BitSet>?, expected: List<Change>?, policy: ComparisonPolicy) {
+ private fun doLineTest(before: Document, after: Document, expected: List<Change>?, policy: ComparisonPolicy) {
val fragments = MANAGER.compareLines(before.getCharsSequence(), after.getCharsSequence(), policy, INDICATOR)
checkConsistency(fragments, before, after)
- if (matchings != null) checkLineMatching(fragments, matchings)
if (expected != null) checkLineChanges(fragments, expected)
}
if (expected != null) checkDiffChanges(fragments, expected)
}
- private fun doSplitterTest(before: Document, after: Document, matchings: Couple<BitSet>?, expected: List<Change>?, policy: ComparisonPolicy) {
+ private fun doSplitterTest(before: Document, after: Document, expected: List<Change>?, policy: ComparisonPolicy) {
val fragments = MANAGER.compareLinesInner(before.getCharsSequence(), after.getCharsSequence(), policy, INDICATOR)
checkConsistency(fragments, before, after)
- if (matchings != null) checkLineMatching(fragments, matchings)
if (expected != null) checkLineChanges(fragments, expected)
}
private fun checkLineChanges(fragments: List<LineFragment>, expected: List<Change>) {
val changes = convertLineFragments(fragments)
- UsefulTestCase.assertOrderedEquals(changes, expected)
+ assertOrderedEquals(changes, expected)
}
private fun checkDiffChanges(fragments: List<DiffFragment>, expected: List<Change>) {
val changes = convertDiffFragments(fragments)
- UsefulTestCase.assertOrderedEquals(changes, expected)
- }
-
- private fun checkLineMatching(fragments: List<LineFragment>, matchings: Couple<BitSet>) {
- val set1 = BitSet()
- val set2 = BitSet()
- for (fragment in fragments) {
- set1.set(fragment.getStartLine1(), fragment.getEndLine1())
- set2.set(fragment.getStartLine2(), fragment.getEndLine2())
- }
-
- assertEquals(matchings.first, set1)
- assertEquals(matchings.second, set2)
+ assertOrderedEquals(changes, expected)
}
private fun checkDiffMatching(fragments: List<DiffFragment>, matchings: Couple<BitSet>) {
assertTrue(change != null || matchings != null)
when (type) {
- TestType.LINE -> doLineTest(before!!, after!!, matchings, change, policy)
+ TestType.LINE -> doLineTest(before!!, after!!, change, policy)
TestType.WORD -> doWordTest(before!!, after!!, matchings, change, policy)
TestType.CHAR -> doCharTest(before!!, after!!, matchings, change, policy)
- TestType.SPLITTER -> doSplitterTest(before!!, after!!, matchings, change, policy)
+ TestType.SPLITTER -> doSplitterTest(before!!, after!!, change, policy)
}
}
catch (e: Throwable) {
words {
("x .. z" - "x y .. z")
- (" " - " -- ").default() // TODO: looks wrong.default()
+ (" " - " -- ").default() // TODO: looks wrong
(" " - " - ").ignore()
testAll()
}
*/
package com.intellij.diff.tools.fragmented
+import com.intellij.diff.assertEquals
import com.intellij.diff.util.Side
import com.intellij.testFramework.UsefulTestCase
-import kotlin.test.assertEquals
public class LineNumberConvertorCorrectorTest : UsefulTestCase() {
public fun testUnmodified() {
*/
package com.intellij.diff.tools.fragmented
+import com.intellij.diff.assertEquals
import com.intellij.testFramework.UsefulTestCase
-import kotlin.test.assertEquals
public class LineNumberConvertorTest : UsefulTestCase() {
public fun testEmpty() {
*/
package com.intellij.diff.tools.fragmented
+import com.intellij.diff.assertEquals
+import com.intellij.diff.assertTrue
import com.intellij.diff.comparison.AutoTestCase
import com.intellij.diff.comparison.ComparisonManagerImpl
import com.intellij.diff.comparison.ComparisonPolicy
import com.intellij.openapi.progress.DumbProgressIndicator
import com.intellij.openapi.util.text.StringUtil
import com.intellij.util.containers.HashMap
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
public class UnifiedFragmentBuilderAutoTest : AutoTestCase() {
public fun test() {
*/
package com.intellij.diff.tools.fragmented
+import com.intellij.diff.assertEmpty
+import com.intellij.diff.assertEquals
+import com.intellij.diff.assertFalse
+import com.intellij.diff.assertTrue
import com.intellij.diff.comparison.ComparisonManagerImpl
import com.intellij.diff.comparison.ComparisonPolicy
import com.intellij.diff.util.LineRange
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.progress.DumbProgressIndicator
import com.intellij.testFramework.UsefulTestCase
-import kotlin.test.assertEquals
-import kotlin.test.assertFalse
-import kotlin.test.assertTrue
public class UnifiedFragmentBuilderTest : UsefulTestCase() {
public fun testEquals() {
assertTrue(builder.isEqual())
assertEquals(builder.getText().toString(), "A\nB\nC\n")
- UsefulTestCase.assertEmpty(builder.getChangedLines())
- UsefulTestCase.assertEmpty(builder.getBlocks())
+ assertEmpty(builder.getChangedLines())
+ assertEmpty(builder.getBlocks())
}
public fun testWrongEndLineTypoBug() {