mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Complete tests for DateUtils, move internal functions to private
This commit is contained in:
@@ -214,13 +214,7 @@ abstract class DateUtils {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getStartOfTodayCalendarWithOffset(): GregorianCalendar = getCalendar(getStartOfTodayWithOffset())
|
fun getStartOfTodayCalendarWithOffset(): GregorianCalendar = getCalendar(getStartOfTodayWithOffset())
|
||||||
|
|
||||||
@JvmStatic
|
private fun getTimeZone(): TimeZone {
|
||||||
fun getTimeZone(): TimeZone {
|
|
||||||
return fixedTimeZone ?: TimeZone.getDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun getTimezone(): TimeZone {
|
|
||||||
return fixedTimeZone ?: TimeZone.getDefault()
|
return fixedTimeZone ?: TimeZone.getDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,8 +230,7 @@ abstract class DateUtils {
|
|||||||
startDayMinuteOffset = minuteOffset
|
startDayMinuteOffset = minuteOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
private fun getLocale(): Locale {
|
||||||
fun getLocale(): Locale {
|
|
||||||
return fixedLocale ?: Locale.getDefault()
|
return fixedLocale ?: Locale.getDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,23 @@ class DateUtilsTest : BaseUnitTest() {
|
|||||||
assertThat(truncate(field, t2, firstWeekday), equalTo(expected))
|
assertThat(truncate(field, t2, firstWeekday), equalTo(expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testTruncate_timestamp() {
|
||||||
|
val field = DateUtils.TruncateField.YEAR
|
||||||
|
val nonTruncatedDate = unixTime(2016, Calendar.MAY, 30)
|
||||||
|
val expected = Timestamp(unixTime(2016, Calendar.JANUARY, 1))
|
||||||
|
assertThat(expected, equalTo(truncate(field, Timestamp(nonTruncatedDate), firstWeekday)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testGetUpcomingTimeInMillis() {
|
||||||
|
setFixedLocalTime(FIXED_LOCAL_TIME)
|
||||||
|
setFixedTimeZone(TimeZone.getTimeZone("GMT"))
|
||||||
|
val expected = unixTime(2015, Calendar.JANUARY, 25, 10, 1)
|
||||||
|
val upcomingTimeMillis = DateUtils.getUpcomingTimeInMillis(10, 1)
|
||||||
|
assertThat(expected, equalTo(upcomingTimeMillis))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testMillisecondsUntilTomorrow() {
|
fun testMillisecondsUntilTomorrow() {
|
||||||
|
|||||||
Reference in New Issue
Block a user