LongRangeKnownMethods: LocalDateTime test replaced with Integer/Long tests

LocalDateTime is not mocked in mockJDKs. Mocking it in source code results does not allow to use external annotations (see f8ad50f3). Instead Integer.bitCount and Long.numberOfLeadingZeroes are tested which are also annotated externally.
This commit is contained in:
Tagir Valeev
2018-01-15 17:44:49 +07:00
parent 0f265919bf
commit 7f2549213d
2 changed files with 7 additions and 12 deletions
@@ -1,4 +1,3 @@
import java.time.LocalDateTime;
import java.util.*;
public class LongRangeKnownMethods {
@@ -11,10 +10,13 @@ public class LongRangeKnownMethods {
}
}
void testLocalDateTime(LocalDateTime ldt) {
if(<warning descr="Condition 'ldt.getHour() == 24' is always 'false'">ldt.getHour() == 24</warning>) System.out.println(1);
if(<warning descr="Condition 'ldt.getMinute() >= 0' is always 'true'">ldt.getMinute() >= 0</warning>) System.out.println(2);
if(<warning descr="Condition 'ldt.getSecond() >= 60' is always 'false'">ldt.getSecond() >= 60</warning>) System.out.println(3);
void testExternalAnnotations(int i, long l) {
if(<warning descr="Condition 'Integer.bitCount(i) == -1' is always 'false'">Integer.bitCount(i) == -1</warning>) {
System.out.println("Impossible");
}
if(Long.<error descr="Cannot resolve method 'numberOfLeadingZeroes(long)'">numberOfLeadingZeroes</error>(l) <= 64) {
System.out.println("Always");
}
}
private static int twiceIndexOf(String text, int start, int end) {
@@ -57,13 +57,6 @@ public class DataFlowRangeAnalysisTest extends DataFlowInspectionTestCase {
}
public void testLongRangeKnownMethods() {
myFixture.addClass("package java.time;\n" +
"\n" +
"public interface LocalDateTime {\n" +
" int getHour();\n" +
" int getMinute();\n" +
" int getSecond();\n" +
"}");
doTest();
}