Skip to content

Commit

Permalink
Merge pull request Kotlin#93 from romanmikhailov/feature/tests/28_for…
Browse files Browse the repository at this point in the history
…_loop_corner_cases

Add new corner test cases to 28 (For Loop) suite.
  • Loading branch information
svtk authored Jul 7, 2017
2 parents 76a6845 + 5c2b079 commit 3e5c382
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/iii_conventions/_28_For_Loop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,26 @@ class _28_For_Loop {
iterateOverDateRange(MyDate(2014, 1, 1), MyDate(2013, 1, 1), { invoked = true })
assertFalse("Handler was invoked on an empty range", invoked)
}

@Test fun testIterateOverLeapYearEndOfFebruary() {
val actualDateRange = ArrayList<MyDate>()
iterateOverDateRange(MyDate(2016, 1, 26), MyDate(2016, 2, 1), {
date: MyDate -> actualDateRange.add(date)
})
val expectedDateRange = arrayListOf(
MyDate(2016, 1, 26), MyDate(2016, 1, 27), MyDate(2016, 1, 28), MyDate(2016, 1, 29), MyDate(2016, 2, 1))
assertEquals("Incorrect iteration over nice end of February of Leap-Year",
expectedDateRange, actualDateRange)
}

@Test fun testIterateOverTheNewYear() {
val actualDateRange = ArrayList<MyDate>()
iterateOverDateRange(MyDate(2016, 11, 31), MyDate(2017, 0, 1), {
date: MyDate -> actualDateRange.add(date)
})
val expectedDateRange = arrayListOf(
MyDate(2016, 11, 31), MyDate(2017, 0, 1))
assertEquals("Incorrect iteration over nice end of February of Leap-Year",
expectedDateRange, actualDateRange)
}
}

0 comments on commit 3e5c382

Please sign in to comment.