diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/February31.java b/java/java-tests/testData/inspection/dataFlow/fixture/February31.java new file mode 100644 index 000000000000..935df06e899e --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/February31.java @@ -0,0 +1,31 @@ +import java.util.*; + +public class February31 { + private static final int[] kDaysInMonth = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + + boolean ValidateDateTime(DateTime time) { + if (time.year < 1 || time.year > 9999 || + time.month < 1 || time.month > 12 || + time.day < 1 || time.day > 31 || + time.hour < 0 || time.hour > 23 || + time.minute < 0 || time.minute > 59 || + time.second < 0 || time.second > 59) { + return false; + } + if (time.month == 2 && IsLeapYear(time.year)) { + return time.month <= kDaysInMonth[time.month] + 1; + } else { + return time.month <= kDaysInMonth[time.month]; + } + } + + static boolean IsLeapYear(int year) { + return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); + } + + static class DateTime { + int year, month, day, hour, minute, second; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowRangeAnalysisTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowRangeAnalysisTest.java index b7ecfb4feedd..731dc1c248d6 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowRangeAnalysisTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowRangeAnalysisTest.java @@ -70,4 +70,5 @@ public class DataFlowRangeAnalysisTest extends DataFlowInspectionTestCase { public void testLongRangeMod() { doTest(); } public void testLongRangeAdd() { doTest(); } + public void testFebruary31() { doTest(); } }