mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert tests to kotlin
This commit is contained in:
-114
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.vcs.log.graph.impl.permanent;
|
||||
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
|
||||
import com.intellij.vcs.log.graph.GraphCommit;
|
||||
import com.intellij.vcs.log.graph.GraphPackage;
|
||||
import com.intellij.vcs.log.graph.impl.CommitIdManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public abstract class GraphBuilderTest<CommitId extends Comparable<CommitId>> extends AbstractTestWithTwoTextFile {
|
||||
public GraphBuilderTest() {
|
||||
super("graphBuilder/");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest(String in, String out) {
|
||||
List<GraphCommit<CommitId>> commits = getCommitIdManager().parseCommitList(in);
|
||||
|
||||
PermanentLinearGraphBuilder<CommitId> graphBuilder = PermanentLinearGraphBuilder.newInstance(commits);
|
||||
PermanentLinearGraphImpl graph = graphBuilder.build(new NotNullFunction<CommitId, Integer>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Integer fun(CommitId dom) {
|
||||
return - getCommitIdManager().toInt(dom);
|
||||
}
|
||||
});
|
||||
|
||||
String actual = GraphPackage.asString(graph, false);
|
||||
assertEquals(out, actual);
|
||||
}
|
||||
|
||||
protected abstract CommitIdManager<CommitId> getCommitIdManager();
|
||||
|
||||
@Test
|
||||
public void simple() throws IOException {
|
||||
doTest("simple");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manyNodes() throws IOException {
|
||||
doTest("manyNodes");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manyUpNodes() throws IOException {
|
||||
doTest("manyUpNodes");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manyDownNodes() throws IOException {
|
||||
doTest("manyDownNodes");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneNode() throws IOException {
|
||||
doTest("oneNode");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneNodeNotFullGraph() throws IOException {
|
||||
doTest("oneNodeNotFullGraph");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFullGraph() throws IOException {
|
||||
doTest("notFullGraph");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parentsOrder() throws IOException {
|
||||
doTest("parentsOrder");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void duplicateParents() throws IOException {
|
||||
doTest("duplicateParents");
|
||||
}
|
||||
|
||||
public static class StringTest extends GraphBuilderTest<String> {
|
||||
@Override
|
||||
protected CommitIdManager<String> getCommitIdManager() {
|
||||
return CommitIdManager.STRING_COMMIT_ID_MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntegerTest extends GraphBuilderTest<Integer> {
|
||||
@Override
|
||||
protected CommitIdManager<Integer> getCommitIdManager() {
|
||||
return CommitIdManager.INTEGER_COMMIT_ID_MANAGER;
|
||||
}
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.vcs.log.graph.impl.permanent
|
||||
|
||||
import com.intellij.util.NotNullFunction
|
||||
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile
|
||||
import com.intellij.vcs.log.graph.GraphCommit
|
||||
import com.intellij.vcs.log.graph.*
|
||||
import com.intellij.vcs.log.graph.impl.CommitIdManager
|
||||
import org.junit.Test
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
public abstract class GraphBuilderTest<CommitId : Comparable<CommitId>> : AbstractTestWithTwoTextFile("graphBuilder/") {
|
||||
|
||||
override fun runTest(`in`: String, out: String) {
|
||||
val commits = getCommitIdManager().parseCommitList(`in`)
|
||||
|
||||
val graphBuilder = PermanentLinearGraphBuilder.newInstance<CommitId>(commits)
|
||||
val graph = graphBuilder.build(object : NotNullFunction<CommitId, Int> {
|
||||
override fun `fun`(dom: CommitId): Int {
|
||||
return -getCommitIdManager().toInt(dom)
|
||||
}
|
||||
})
|
||||
|
||||
val actual = graph.asString(false)
|
||||
assertEquals(out, actual)
|
||||
}
|
||||
|
||||
protected abstract fun getCommitIdManager(): CommitIdManager<CommitId>
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun simple() {
|
||||
doTest("simple")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun manyNodes() {
|
||||
doTest("manyNodes")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun manyUpNodes() {
|
||||
doTest("manyUpNodes")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun manyDownNodes() {
|
||||
doTest("manyDownNodes")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun oneNode() {
|
||||
doTest("oneNode")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun oneNodeNotFullGraph() {
|
||||
doTest("oneNodeNotFullGraph")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun notFullGraph() {
|
||||
doTest("notFullGraph")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun parentsOrder() {
|
||||
doTest("parentsOrder")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun duplicateParents() {
|
||||
doTest("duplicateParents")
|
||||
}
|
||||
|
||||
public class StringTest : GraphBuilderTest<String>() {
|
||||
override fun getCommitIdManager(): CommitIdManager<String> {
|
||||
return CommitIdManager.STRING_COMMIT_ID_MANAGER
|
||||
}
|
||||
}
|
||||
|
||||
public class IntegerTest : GraphBuilderTest<Int>() {
|
||||
override fun getCommitIdManager(): CommitIdManager<Int> {
|
||||
return CommitIdManager.INTEGER_COMMIT_ID_MANAGER
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.vcs.log.graph.impl.print;
|
||||
|
||||
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
|
||||
import com.intellij.vcs.log.graph.GraphPackage;
|
||||
import com.intellij.vcs.log.graph.api.LinearGraph;
|
||||
import com.intellij.vcs.log.graph.parser.LinearGraphParser;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestGraphBuilderTest extends AbstractTestWithTwoTextFile {
|
||||
public TestGraphBuilderTest() {
|
||||
super("testParser");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest(String in, String out) {
|
||||
LinearGraph graph = LinearGraphParser.parse(in);
|
||||
assertEquals(out, GraphPackage.asString(graph, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specialElements() throws IOException {
|
||||
doTest("specialElements");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manyNodes() throws IOException {
|
||||
doTest("manyNodes");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notLoadNode() throws IOException {
|
||||
doTest("notLoadNode");
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.vcs.log.graph.impl.print
|
||||
|
||||
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile
|
||||
import com.intellij.vcs.log.graph.*
|
||||
import com.intellij.vcs.log.graph.api.LinearGraph
|
||||
import com.intellij.vcs.log.graph.parser.LinearGraphParser
|
||||
import org.junit.Test
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
|
||||
public class TestGraphBuilderTest : AbstractTestWithTwoTextFile("testParser") {
|
||||
|
||||
override fun runTest(`in`: String, out: String) {
|
||||
val graph = LinearGraphParser.parse(`in`)
|
||||
assertEquals(out, graph.asString(false))
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun specialElements() {
|
||||
doTest("specialElements")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun manyNodes() {
|
||||
doTest("manyNodes")
|
||||
}
|
||||
|
||||
Test
|
||||
throws(javaClass<IOException>())
|
||||
public fun notLoadNode() {
|
||||
doTest("notLoadNode")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user