@@ -56,6 +56,29 @@ public void testRightNowVariance() throws Exception
5656 assertEquals ("今からすぐ" , t .format (new Date (600 )));
5757 }
5858
59+ @ Test
60+ public void testMillisecondsFromNow () throws Exception
61+ {
62+ PrettyTime t = new PrettyTime (new Date (0 ), locale );
63+ t .removeUnit (org .ocpsoft .prettytime .units .JustNow .class );
64+ // 450 milliseconds from now
65+ assertEquals ("450 milliseconds from now" , "今から450ミリ秒後" , t .format (new Date (450L )));
66+ }
67+
68+ @ Test
69+ public void testSecondsFromNow () throws Exception
70+ {
71+ PrettyTime t = new PrettyTime (new Date (0 ), locale );
72+ t .removeUnit (org .ocpsoft .prettytime .units .JustNow .class );
73+ // 36 seconds from now
74+ assertEquals ("36 seconds from now" , "今から36秒後" , t .format (new Date (1000L * 36L )));
75+ t .removeUnit (org .ocpsoft .prettytime .units .Millisecond .class );
76+ // 1 second from now
77+ assertEquals ("1 second from now" , "今から1秒後" , t .format (new Date (10 )));
78+ // 1 second from now
79+ assertEquals ("1 second from now" , "今から1秒後" , t .formatUnrounded (new Date (10 )));
80+ }
81+
5982 @ Test
6083 public void testMinutesFromNow () throws Exception
6184 {
@@ -139,6 +162,27 @@ public void testMomentsAgo() throws Exception
139162 assertEquals ("たった今" , t .format (new Date (0 )));
140163 }
141164
165+ @ Test
166+ public void testMillisecondsAgo () throws Exception
167+ {
168+ PrettyTime t = new PrettyTime (new Date (450L ), locale );
169+ t .removeUnit (org .ocpsoft .prettytime .units .JustNow .class );
170+ // 450 milliseconds ago
171+ assertEquals ("450 milliseconds ago" , "450ミリ秒前" , t .format (new Date (0 )));
172+ }
173+
174+ @ Test
175+ public void testSecondsAgo () throws Exception
176+ {
177+ PrettyTime t = new PrettyTime (new Date (1000 * 36 ), locale );
178+ t .removeUnit (org .ocpsoft .prettytime .units .JustNow .class );
179+ // 36 seconds ago
180+ assertEquals ("36 seconds ago" , "36秒前" , t .format (new Date (0 )));
181+ t .setReference (new Date (10 )).removeUnit (org .ocpsoft .prettytime .units .Millisecond .class );
182+ // 1 second ago
183+ assertEquals ("1 second ago" , "1秒前" , t .format (new Date (0 )));
184+ }
185+
142186 @ Test
143187 public void testMinutesAgo () throws Exception
144188 {
0 commit comments