Skip to content

Commit

Permalink
Added Month.daysIn() and Year.isLeap()
Browse files Browse the repository at this point in the history
  • Loading branch information
fluidsonic committed Jan 21, 2021
1 parent f6a2022 commit 76ddeab
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/MonthTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import io.fluidsonic.time.*
import kotlin.test.*
import kotlinx.datetime.*


class MonthTests {

@Test
fun testDaysIn() {
assertEquals(expected = 31, actual = Month.JANUARY.daysIn(2000))
assertEquals(expected = 29, actual = Month.FEBRUARY.daysIn(2000))
assertEquals(expected = 28, actual = Month.FEBRUARY.daysIn(2001))
assertEquals(expected = 31, actual = Month.MARCH.daysIn(2000))
assertEquals(expected = 30, actual = Month.APRIL.daysIn(2000))
assertEquals(expected = 31, actual = Month.MAY.daysIn(2000))
assertEquals(expected = 30, actual = Month.JUNE.daysIn(2000))
assertEquals(expected = 31, actual = Month.JULY.daysIn(2000))
assertEquals(expected = 31, actual = Month.AUGUST.daysIn(2000))
assertEquals(expected = 30, actual = Month.SEPTEMBER.daysIn(2000))
assertEquals(expected = 31, actual = Month.OCTOBER.daysIn(2000))
assertEquals(expected = 30, actual = Month.NOVEMBER.daysIn(2000))
assertEquals(expected = 31, actual = Month.DECEMBER.daysIn(2000))
}
}
20 changes: 20 additions & 0 deletions tests/YearTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import io.fluidsonic.time.*
import kotlin.test.*


class YearTests {

@Test
fun testIsLeap() {
val leapYears = listOf(
2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048,
2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096, 2104,
)

for (year in 1999 .. 2107)
if (leapYears.contains(year))
assertTrue(Year.isLeap(year), message = "Expected $year to be a leap year but it isn't.")
else
assertFalse(Year.isLeap(year), message = "Expected $year to not be a leap year but it is.")
}
}

0 comments on commit 76ddeab

Please sign in to comment.