package com.btmura.android.reddit.text;


import android.test.AndroidTestCase;

public class RelativeTimeTest extends AndroidTestCase {

    private static final int MINUTE_SECONDS = 60;
    private static final int HOUR_SECONDS = MINUTE_SECONDS * 60;
    private static final int DAY_SECONDS = HOUR_SECONDS * 24;
    private static final int MONTH_SECONDS = DAY_SECONDS * 30;
    private static final int YEAR_SECONDS = MONTH_SECONDS * 12;
    private static final long NOW = YEAR_SECONDS * 3;
    private static final long NOW_MS = NOW * 1000;

    public void testFormat_seconds() {
        assertEquals("0 seconds", RelativeTime.format(mContext, NOW_MS, NOW));
        assertEquals("1 second", RelativeTime.format(mContext, NOW_MS, NOW - 1));
        assertEquals("20 seconds", RelativeTime.format(mContext, NOW_MS, NOW - 20));
        assertEquals("59 seconds", RelativeTime.format(mContext, NOW_MS, NOW - 59));
    }

    public void testFormat_minutes() {
        assertEquals("1 minute", RelativeTime.format(mContext, NOW_MS, NOW - MINUTE_SECONDS));
        assertEquals("20 minutes", RelativeTime.format(mContext, NOW_MS, NOW - MINUTE_SECONDS * 20));
        assertEquals("59 minutes", RelativeTime.format(mContext, NOW_MS, NOW - MINUTE_SECONDS * 59));
        assertEquals("59 minutes",
                RelativeTime.format(mContext, NOW_MS, NOW - MINUTE_SECONDS * 59 - 30));
    }

    public void testFormat_hours() {
        assertEquals("1 hour", RelativeTime.format(mContext, NOW_MS, NOW - HOUR_SECONDS));
        assertEquals("23 hours", RelativeTime.format(mContext, NOW_MS, NOW - HOUR_SECONDS * 23));
    }

    public void testFormat_days() {
        assertEquals("1 day", RelativeTime.format(mContext, NOW_MS, NOW - DAY_SECONDS));
        assertEquals("29 days", RelativeTime.format(mContext, NOW_MS, NOW - DAY_SECONDS * 29));
    }

    public void testFormat_months() {
        assertEquals("1 month", RelativeTime.format(mContext, NOW_MS, NOW - MONTH_SECONDS));
        assertEquals("11 months", RelativeTime.format(mContext, NOW_MS, NOW - MONTH_SECONDS * 11));
    }

    public void testFormat_years() {
        assertEquals("1 year", RelativeTime.format(mContext, NOW_MS, NOW - YEAR_SECONDS));
        assertEquals("2 years", RelativeTime.format(mContext, NOW_MS, NOW - YEAR_SECONDS * 2));
    }
}

@@ -34,17 +34,16 @@
 .text;%0A%0A
-%0A
 import a
@@ -601,34 +601,54 @@
 quals(%220 seconds
-%22,
+ ago%22,%0A               
  RelativeTime.fo
@@ -707,18 +707,38 @@
 1 second
-%22,
+ ago%22,%0A               
  Relativ
@@ -803,34 +803,54 @@
 uals(%2220 seconds
-%22,
+ ago%22,%0A               
  RelativeTime.fo
@@ -916,18 +916,38 @@
  seconds
-%22,
+ ago%22,%0A               
  Relativ
@@ -1065,18 +1065,38 @@
 1 minute
-%22,
+ ago%22,%0A               
  Relativ
@@ -1174,34 +1174,54 @@
 uals(%2220 minutes
-%22,
+ ago%22,%0A               
  RelativeTime.fo
@@ -1304,18 +1304,38 @@
  minutes
-%22,
+ ago%22,%0A               
  Relativ
@@ -1426,16 +1426,20 @@
  minutes
+ ago
 %22,%0A     
@@ -1593,18 +1593,38 @@
 (%221 hour
-%22,
+ ago%22,%0A               
  Relativ
@@ -1706,18 +1706,38 @@
 23 hours
-%22,
+ ago%22,%0A               
  Relativ
@@ -1864,18 +1864,38 @@
 s(%221 day
-%22,
+ ago%22,%0A               
  Relativ
@@ -1975,18 +1975,38 @@
 %2229 days
-%22,
+ ago%22,%0A               
  Relativ
@@ -2136,18 +2136,38 @@
 %221 month
-%22,
+ ago%22,%0A               
  Relativ
@@ -2251,18 +2251,38 @@
 1 months
-%22,
+ ago%22,%0A               
  Relativ
@@ -2412,18 +2412,38 @@
 (%221 year
-%22,
+ ago%22,%0A               
  Relativ
@@ -2524,18 +2524,38 @@
 %222 years
-%22,
+ ago%22,%0A               
  Relativ

Fix RelativeTimeTest