Created
April 19, 2014 12:23
-
-
Save chrissie1/11082976 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package org.humanizer.jvm | |
import org.junit.Test as Test | |
import kotlin.test.assertEquals | |
import java.util.Calendar | |
import java.util.Date | |
public class DateHumanizerTests() { | |
fun humanizeDatAssert(difference: Int, expected: String) | |
{ | |
val cal = Calendar.getInstance() | |
val current = cal.getTime() | |
cal.add(Calendar.SECOND,difference) | |
val result = cal.getTime().humanize(current) | |
assertEquals(expected, result) | |
} | |
Test | |
public fun ifMinus1SecondIsHumanizedTo1SecondAgo() | |
{ | |
humanizeDatAssert(-1,"one second ago") | |
} | |
Test | |
public fun ifMinus10SecondIsHumanizedTo10SecondsAgo() | |
{ | |
humanizeDatAssert(-10,"10 seconds ago") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment