-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Month.daysIn() and Year.isLeap()
- Loading branch information
1 parent
f6a2022
commit 76ddeab
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") | ||
} | ||
} |