mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Complete tests for DateUtils, move internal functions to private
This commit is contained in:
@@ -214,13 +214,7 @@ abstract class DateUtils {
|
||||
@JvmStatic
|
||||
fun getStartOfTodayCalendarWithOffset(): GregorianCalendar = getCalendar(getStartOfTodayWithOffset())
|
||||
|
||||
@JvmStatic
|
||||
fun getTimeZone(): TimeZone {
|
||||
return fixedTimeZone ?: TimeZone.getDefault()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getTimezone(): TimeZone {
|
||||
private fun getTimeZone(): TimeZone {
|
||||
return fixedTimeZone ?: TimeZone.getDefault()
|
||||
}
|
||||
|
||||
@@ -236,8 +230,7 @@ abstract class DateUtils {
|
||||
startDayMinuteOffset = minuteOffset
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLocale(): Locale {
|
||||
private fun getLocale(): Locale {
|
||||
return fixedLocale ?: Locale.getDefault()
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,23 @@ class DateUtilsTest : BaseUnitTest() {
|
||||
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
|
||||
@Throws(Exception::class)
|
||||
fun testMillisecondsUntilTomorrow() {
|
||||
|
||||
Reference in New Issue
Block a user