Search in sources :

Example 1 with ErrorProneScanner

use of com.google.errorprone.scanner.ErrorProneScanner in project error-prone by google.

the class CollectionIncompatibleTypeTest method testCastFixes.

@Test
public void testCastFixes() {
    CompilationTestHelper compilationHelperWithCastFix = CompilationTestHelper.newInstance(ScannerSupplier.fromScanner(new ErrorProneScanner(new CollectionIncompatibleType(FixType.CAST))), getClass());
    compilationHelperWithCastFix.addSourceLines("Test.java", "import java.util.Collection;", "public class Test {", "  public void doIt(Collection<String> c1, Collection<Integer> c2) {", "    // BUG: Diagnostic contains: c1.contains((Object) 1);", "    c1.contains(1);", "    // BUG: Diagnostic contains: c1.containsAll((Collection<?>) c2);", "    c1.containsAll(c2);", "  }", "}").doTest();
}
Also used : CompilationTestHelper(com.google.errorprone.CompilationTestHelper) ErrorProneScanner(com.google.errorprone.scanner.ErrorProneScanner) Test(org.junit.Test)

Aggregations

CompilationTestHelper (com.google.errorprone.CompilationTestHelper)1 ErrorProneScanner (com.google.errorprone.scanner.ErrorProneScanner)1 Test (org.junit.Test)1