Additional test for multiple comments in copyright updater

This commit is contained in:
Nikolay Krasko
2019-05-22 18:36:30 +03:00
parent 136cbd195b
commit 78569c62c0
3 changed files with 22 additions and 5 deletions
+8
View File
@@ -0,0 +1,8 @@
/* PRESENT 1 */
/* PRESENT 2 */
// PRESENT 3
/** ABSENT */
package/* ABSENT 1 */ normal
/* ABSENT 2 */
// COMMENTS: 3
@@ -29,10 +29,11 @@ abstract class AbstractUpdateKotlinCopyrightTest : KotlinLightCodeInsightFixture
val comments = UpdateKotlinCopyright.getExistentComments(myFixture.file)
for (comment in comments) {
val commentText = comment.text
when (commentText) {
"/* PRESENT */" -> {}
"/* ABSENT */" -> {
throw AssertionFailedError("Unexpected comment found")
when {
commentText.contains("PRESENT") -> {
}
commentText.contains("ABSENT") -> {
throw AssertionFailedError("Unexpected comment found: `$commentText`")
}
else -> {
throw AssertionFailedError("A comment with bad directive found: `$commentText`")
@@ -40,7 +41,10 @@ abstract class AbstractUpdateKotlinCopyrightTest : KotlinLightCodeInsightFixture
}
}
Assert.assertEquals("Wrong number of comments found", expectedNumberOfComments, comments.size)
Assert.assertEquals(
"Wrong number of comments found:\n${comments.joinToString(separator = "\n") { it.text }}\n",
expectedNumberOfComments, comments.size
)
}
override fun getTestDataPath() = File(PluginTestCaseBase.getTestDataPathBase(), "/copyright").path + File.separator
@@ -39,6 +39,11 @@ public class UpdateKotlinCopyrightTestGenerated extends AbstractUpdateKotlinCopy
runTest("idea/testData/copyright/Empty.kt");
}
@TestMetadata("MultiComments.kt")
public void testMultiComments() throws Exception {
runTest("idea/testData/copyright/MultiComments.kt");
}
@TestMetadata("NoPackage.kt")
public void testNoPackage() throws Exception {
runTest("idea/testData/copyright/NoPackage.kt");