Skip to content

Commit 2ae104e

Browse files
committed
test for uyghur
1 parent 84c9913 commit 2ae104e

1 file changed

Lines changed: 231 additions & 0 deletions

File tree

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
package org.ocpsoft.prettytime;
2+
3+
import org.junit.After;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
7+
import java.text.SimpleDateFormat;
8+
import java.util.Date;
9+
import java.util.Locale;
10+
11+
import static org.junit.Assert.assertEquals;
12+
13+
/**
14+
* Created by edward_chiang on 13/6/27.
15+
*/
16+
public class PrettyTimeI18n_uy_Test
17+
{
18+
private final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
19+
private Locale locale;
20+
21+
@Before
22+
public void setUp() throws Exception
23+
{
24+
locale = new Locale("uy");
25+
Locale.setDefault(locale);
26+
}
27+
28+
@Test
29+
public void testPrettyTime()
30+
{
31+
PrettyTime p = new PrettyTime(locale);
32+
assertEquals("ھېلىلا", p.format(new Date()));
33+
}
34+
35+
@Test
36+
public void testPrettyTimeCenturies()
37+
{
38+
PrettyTime p = new PrettyTime(new Date(3155692597470L * 3L), locale);
39+
assertEquals("3 ئەسىر ئىلگىرى", p.format(new Date(0)));
40+
41+
p = new PrettyTime(new Date(0), locale);
42+
assertEquals("3 ئەسىر كىيىن", p.format(new Date(3155692597470L * 3L)));
43+
}
44+
45+
@Test
46+
public void testCeilingInterval() throws Exception
47+
{
48+
Date then = format.parse("20/5/2009");
49+
Date ref = format.parse("17/6/2009");
50+
PrettyTime t = new PrettyTime(ref, locale);
51+
assertEquals("1 ئاي ئىلگىرى", t.format(then));
52+
}
53+
54+
@Test
55+
public void testNullDate() throws Exception
56+
{
57+
PrettyTime t = new PrettyTime(locale);
58+
Date date = null;
59+
assertEquals("ھېلىلا", t.format(date));
60+
}
61+
62+
@Test
63+
public void testRightNow() throws Exception
64+
{
65+
PrettyTime t = new PrettyTime(locale);
66+
assertEquals("ھېلىلا", t.format(new Date()));
67+
}
68+
69+
@Test
70+
public void testRightNowVariance() throws Exception
71+
{
72+
PrettyTime t = new PrettyTime(new Date(0), locale);
73+
assertEquals("ھېلىلا", t.format(new Date(600)));
74+
}
75+
76+
@Test
77+
public void testMinutesFromNow() throws Exception
78+
{
79+
PrettyTime t = new PrettyTime(new Date(0), locale);
80+
assertEquals("12 مىنۇت كىيىن", t.format(new Date(1000 * 60 * 12)));
81+
}
82+
83+
@Test
84+
public void testHoursFromNow() throws Exception
85+
{
86+
PrettyTime t = new PrettyTime(new Date(0), locale);
87+
assertEquals("3 سائەت كىيىن", t.format(new Date(1000 * 60 * 60 * 3)));
88+
}
89+
90+
@Test
91+
public void testDaysFromNow() throws Exception
92+
{
93+
PrettyTime t = new PrettyTime(new Date(0), locale);
94+
assertEquals("3 كۈن كىيىن", t.format(new Date(1000 * 60 * 60 * 24 * 3)));
95+
}
96+
97+
@Test
98+
public void testWeeksFromNow() throws Exception
99+
{
100+
PrettyTime t = new PrettyTime(new Date(0), locale);
101+
assertEquals("3 ھەپتە كىيىن", t.format(new Date(1000 * 60 * 60 * 24 * 7 * 3)));
102+
}
103+
104+
@Test
105+
public void testMonthsFromNow() throws Exception
106+
{
107+
PrettyTime t = new PrettyTime(new Date(0), locale);
108+
assertEquals("3 ئاي كىيىن", t.format(new Date(2629743830L * 3L)));
109+
}
110+
111+
@Test
112+
public void testYearsFromNow() throws Exception
113+
{
114+
PrettyTime t = new PrettyTime(new Date(0), locale);
115+
assertEquals("3 يىل كىيىن", t.format(new Date(2629743830L * 12L * 3L)));
116+
}
117+
118+
@Test
119+
public void testDecadesFromNow() throws Exception
120+
{
121+
PrettyTime t = new PrettyTime(new Date(0), locale);
122+
assertEquals("3 0 يىل كىيىن", t.format(new Date(315569259747L * 3L)));
123+
}
124+
125+
@Test
126+
public void testCenturiesFromNow() throws Exception
127+
{
128+
PrettyTime t = new PrettyTime(new Date(0), locale);
129+
assertEquals("3 ئەسىر كىيىن", t.format(new Date(3155692597470L * 3L)));
130+
}
131+
132+
/*
133+
* Past
134+
*/
135+
@Test
136+
public void testMomentsAgo() throws Exception
137+
{
138+
PrettyTime t = new PrettyTime(new Date(6000), locale);
139+
assertEquals("ھېلىلا", t.format(new Date(0)));
140+
}
141+
142+
@Test
143+
public void testMinutesAgo() throws Exception
144+
{
145+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 12), locale);
146+
assertEquals("12 مىنۇت ئىلگىرى", t.format(new Date(0)));
147+
}
148+
149+
@Test
150+
public void test1HourAgo() throws Exception
151+
{
152+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 1), locale);
153+
assertEquals("1 سائەت ئىلگىرى", t.format(new Date(0)));
154+
}
155+
156+
@Test
157+
public void test3HoursAgo() throws Exception
158+
{
159+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 3), locale);
160+
assertEquals("3 سائەت ئىلگىرى", t.format(new Date(0)));
161+
}
162+
163+
@Test
164+
public void test6HoursAgo() throws Exception
165+
{
166+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 6), locale);
167+
assertEquals("6 سائەت ئىلگىرى", t.format(new Date(0)));
168+
}
169+
170+
@Test
171+
public void testDaysAgo() throws Exception
172+
{
173+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 3), locale);
174+
assertEquals("3 كۈن ئىلگىرى", t.format(new Date(0)));
175+
}
176+
177+
@Test
178+
public void testWeeksAgo() throws Exception
179+
{
180+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 7 * 3), locale);
181+
assertEquals("3 ھەپتە ئىلگىرى", t.format(new Date(0)));
182+
}
183+
184+
@Test
185+
public void testMonthsAgo() throws Exception
186+
{
187+
PrettyTime t = new PrettyTime(new Date(2629743830L * 3L), locale);
188+
assertEquals("3 ئاي ئىلگىرى", t.format(new Date(0)));
189+
}
190+
191+
@Test
192+
public void testYearsAgo() throws Exception
193+
{
194+
PrettyTime t = new PrettyTime(new Date(2629743830L * 12L * 3L), locale);
195+
assertEquals("3 يىل ئىلگىرى", t.format(new Date(0)));
196+
}
197+
198+
@Test
199+
public void test8YearsAgo() throws Exception
200+
{
201+
PrettyTime t = new PrettyTime(new Date(2629743830L * 12L * 8L), locale);
202+
assertEquals("8 يىل ئىلگىرى", t.format(new Date(0)));
203+
}
204+
205+
@Test
206+
public void testDecadesAgo() throws Exception
207+
{
208+
PrettyTime t = new PrettyTime(new Date(315569259747L * 3L), locale);
209+
assertEquals("3 0 يىل ئىلگىرى", t.format(new Date(0)));
210+
}
211+
212+
@Test
213+
public void test8DecadesAgo() throws Exception
214+
{
215+
PrettyTime t = new PrettyTime(new Date(315569259747L * 8L), locale);
216+
assertEquals("8 0 يىل ئىلگىرى", t.format(new Date(0)));
217+
}
218+
219+
@Test
220+
public void testCenturiesAgo() throws Exception
221+
{
222+
PrettyTime t = new PrettyTime(new Date(3155692597470L * 3L), locale);
223+
assertEquals("3 ئەسىر ئىلگىرى", t.format(new Date(0)));
224+
}
225+
226+
@After
227+
public void tearDown() throws Exception
228+
{
229+
Locale.setDefault(locale);
230+
}
231+
}

0 commit comments

Comments
 (0)