Java: convert test from parameterized to to regular inspection test

so that highlighting is tested as well and it is easier to run a single test

GitOrigin-RevId: 1dab45eaaf98897c6a76500c0daa00c178b31d76
This commit is contained in:
Bas Leijdekkers
2024-01-27 11:44:40 +00:00
committed by intellij-monorepo-bot
parent 2f4d825f20
commit b744d62219
37 changed files with 155 additions and 166 deletions
@@ -1,5 +1,3 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -0,0 +1,8 @@
class Foo {
void test() {
String colors = """
red<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
""";
}
}
@@ -1,5 +1,3 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -0,0 +1,7 @@
class Foo {
void test() {
String colors = """
red<warning descr="Trailing whitespace characters inside text block"><caret> </warning> """;
}
}
@@ -1,5 +1,3 @@
// "Escape trailing whitespace characters" "true"
class Foo {
void test() {
String text = """
@@ -0,0 +1,6 @@
class Foo {
void test() {
String text = """
hello<warning descr="Trailing whitespace characters inside text block"><caret> </warning> """;
}
}
@@ -1,5 +1,3 @@
// "Escape trailing whitespace characters" "true"
class StringTemplate1 {
String s = STR."""
\{}one\s
@@ -0,0 +1,6 @@
class StringTemplate1 {
String s = STR."""
\{}one<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
two
four" """;
}
@@ -0,0 +1,5 @@
class StringTemplate2 {
String s = STR."""
yes<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
\{}one""";
}
@@ -2,6 +2,6 @@
class StringTemplate2 {
String s = STR."""
before\{}<caret>
before\{}<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
\{}after""";
}
@@ -1,5 +1,3 @@
// "Escape trailing whitespace characters" "true"
class StringTemplate1 {
String s = STR."""
\{}one\s
@@ -0,0 +1,5 @@
class StringTemplate1 {
String s = STR."""
\{}one<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
""";
}
@@ -1,5 +1,3 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -8,3 +6,4 @@ class Foo {
""";
}
}
@@ -0,0 +1,9 @@
class Foo {
void test() {
String colors = """
red<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
green
""";
}
}
@@ -1,5 +1,3 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -8,4 +6,3 @@ class Foo {
""";
}
}
@@ -0,0 +1,8 @@
class Foo {
void test() {
String colors = """
red<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
green
""";
}
}
@@ -1,5 +1,3 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -0,0 +1,20 @@
class Foo {
void test() {
String colors = """
red
green<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
blue
orange """;<EOLError descr="'}' expected"></EOLError>
<EOLError descr="'}' expected"></EOLError>
@@ -1,4 +1,3 @@
// "Fix all 'Trailing whitespace in text block' problems in file" "true"
class Foo {
void test() {
String text = """
@@ -0,0 +1,32 @@
class Foo {
void test() {
String text = """
text"<warning descr="Trailing whitespace characters inside text block"><caret> </warning>""";
String text2 = """
"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text3 = """
test\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text4 = """
test\\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text5 = """
\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text6 = """
\\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text7 = """
\\\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text8 = """
\\\\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text9 = """
\\\\\"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text10 = """
\u005C"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text11 = """
\u005C\u005C"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text12 = """
\u005C\u005C\u005C"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text13 = """
<error descr="Illegal escape character in string literal">\u005C</error> "<warning descr="Trailing whitespace characters inside text block"> </warning>""";
String text14 = """
\u005C\u005C\u005C\u005C"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
}
}
@@ -1,5 +1,3 @@
// "Escape trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
@@ -0,0 +1,8 @@
class Foo {
void test() {
String colors = """
red\040\t<warning descr="Trailing whitespace characters inside text block"><caret> </warning>
green
""";
}
}
@@ -1,5 +1,3 @@
// "Fix all 'Trailing whitespace in text block' problems in file" "false"
class Foo {
void test() {
String colors = """
@@ -1,10 +0,0 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red<caret>
""";
}
}
@@ -1,9 +0,0 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red<caret> """;
}
}
@@ -1,8 +0,0 @@
// "Escape trailing whitespace characters" "true"
class Foo {
void test() {
String text = """
hello<caret> """;
}
}
@@ -1,8 +0,0 @@
// "Escape trailing whitespace characters" "true"
class StringTemplate1 {
String s = STR."""
\{}one<caret>
two
four" """;
}
@@ -1,7 +0,0 @@
// "Escape trailing whitespace characters" "true"
class StringTemplate2 {
String s = STR."""
yes<caret>
\{}one""";
}
@@ -1,7 +0,0 @@
// "Escape trailing whitespace characters" "true"
class StringTemplate1 {
String s = STR."""
\{}one<caret>
""";
}
@@ -1,11 +0,0 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red<caret>
green
""";
}
}
@@ -1,10 +0,0 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red<caret>
green
""";
}
}
@@ -1,21 +0,0 @@
// "Remove trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red
green<caret>
blue
orange """;
@@ -1,33 +0,0 @@
// "Fix all 'Trailing whitespace in text block' problems in file" "true"
class Foo {
void test() {
String text = """
text"<caret> """;
String text2 = """
" """;
String text3 = """
test\" """;
String text4 = """
test\\" """;
String text5 = """
\" """;
String text6 = """
\\" """;
String text7 = """
\\\" """;
String text8 = """
\\\\" """;
String text9 = """
\\\\\" """;
String text10 = """
\u005C" """;
String text11 = """
\u005C\u005C" """;
String text12 = """
\u005C\u005C\u005C" """;
String text13 = """
\u005C " """;
String text14 = """
\u005C\u005C\u005C\u005C" """;
}
}
@@ -1,10 +0,0 @@
// "Escape trailing whitespace characters" "true"
class Foo {
void test() {
String colors = """
red\040\t<caret>
green
""";
}
}
@@ -1,19 +1,51 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeInspection;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.TrailingWhitespacesInTextBlockInspection;
import com.intellij.testFramework.LightProjectDescriptor;
import com.siyeh.ig.LightJavaInspectionTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TrailingWhitespacesInTextBlockInspectionTest extends LightJavaInspectionTestCase {
public void testEmptyLastLine() { doTestAll(); }
public void testOneLineBlock() { doTestAll(); }
public void testReplaceAtTheEnd() { doTestEscape(); }
public void testStringTemplate1Java21Preview() { doTestEscape(); }
public void testStringTemplate2Java21Preview() { doTestEscape(); }
public void testStringTemplate3Java21Preview() { doTestEscape(); }
public void testStringTemplate4Java21Preview() { doTestEscape(); }
public void testTrailingSpaces() { doTestAll(); }
public void testTrailingTabs() { doTestAll(); }
public void testWithBlankLines() { doTestAll(); }
public void testWithEndQuotes() { doTestAll(); }
public void testWithoutTrailingSpaces() { doTest(); }
public void testWithUnicodeEscapes() { doTestEscape(); }
public class TrailingWhitespacesInTextBlockInspectionTest extends LightQuickFixParameterizedTestCase {
@Override
protected LocalInspectionTool @NotNull [] configureLocalInspectionTools() {
return new LocalInspectionTool[]{new TrailingWhitespacesInTextBlockInspection()};
protected @Nullable InspectionProfileEntry getInspection() {
return new TrailingWhitespacesInTextBlockInspection();
}
@Override
protected String getBasePath() {
return "/inspection/trailingWhitespacesInTextBlock";
return "/java/java-tests/testData/inspection/trailingWhitespacesInTextBlock";
}
private void doTestEscape() {
doTest();
checkQuickFix("Escape trailing whitespace characters");
}
private void doTestAll() {
doTest();
checkQuickFixAll();
}
@Override
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
return JAVA_21;
}
}