Skip to content

Instantly share code, notes, and snippets.

@chrissie1
Created April 19, 2014 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrissie1/11082976 to your computer and use it in GitHub Desktop.
Save chrissie1/11082976 to your computer and use it in GitHub Desktop.
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