1 |
alfonx |
1097 |
package skrueger.i8n; |
2 |
|
|
|
3 |
|
|
import static org.junit.Assert.assertEquals; |
4 |
|
|
import static org.junit.Assert.assertFalse; |
5 |
|
|
import static org.junit.Assert.assertTrue; |
6 |
|
|
|
7 |
|
|
import java.util.ArrayList; |
8 |
|
|
import java.util.List; |
9 |
|
|
|
10 |
|
|
import org.junit.BeforeClass; |
11 |
|
|
import org.junit.Test; |
12 |
|
|
|
13 |
|
|
public class I8NUtilTest { |
14 |
|
|
|
15 |
|
|
final static String oneLineCoded = "de{Baum}en{tree}"; |
16 |
|
|
final static List<String> langs4 = new ArrayList<String>(); |
17 |
|
|
|
18 |
|
|
@BeforeClass |
19 |
|
|
public static void setup() { |
20 |
|
|
langs4.add("de"); |
21 |
|
|
langs4.add("en"); |
22 |
|
|
langs4.add("xx"); |
23 |
|
|
langs4.add("yy"); |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
@Test |
27 |
|
|
public void testCreateFromOneLine() { |
28 |
|
|
Translation t = I8NUtil.createFromOneLine(oneLineCoded); |
29 |
|
|
assertEquals("Baum", t.toString("de")); |
30 |
|
|
assertEquals("tree", t.toString("en")); |
31 |
|
|
assertEquals(oneLineCoded, t.toOneLine()); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
@Test |
35 |
|
|
public void testIsValidISOLangCode() { |
36 |
|
|
assertTrue(I8NUtil.isValidISOLangCode("de")); |
37 |
|
|
assertTrue(I8NUtil.isValidISOLangCode("ar")); |
38 |
|
|
assertFalse(I8NUtil.isValidISOLangCode("äü")); |
39 |
|
|
assertFalse(I8NUtil.isValidISOLangCode("ara")); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
@Test |
43 |
|
|
public void testMitUmlaute() { |
44 |
|
|
assertEquals("öäü", I8NUtil.mitUmlaute("oeaeue")); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
@Test |
48 |
|
|
public void testQmTranslation() { |
49 |
|
|
Translation t = I8NUtil.createFromOneLine(oneLineCoded); |
50 |
|
|
assertEquals(0.5, I8NUtil.qmTranslation(langs4, t), .00000000001); |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
} |