Debian Codegraph @

test/uk/me/parabola/imgfmt/app/labelenc/TableTransliteratorTest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.labelenc;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.*;
18
19 public class TableTransliteratorTest {
20
21 /**
22 * Basic test to ascii.
23 */
24 @Test
25 public void testToAscii() {
26 TableTransliterator tr = new TableTransliterator("ascii");
27
28 String s = tr.transliterate("aéćsõ\u0446");
29 assertEquals("to ascii", "aecsots", s);
30 }
31
32 /**
33 * Quick check that the latin characters on input survive in the output
34 * when latin1 is requested.
35 */
36 @Test
37 public void testToLatin() {
38 TableTransliterator tr = new TableTransliterator("latin1");
39
40 String s = tr.transliterate("aéćsõ\u0446");
41 assertEquals("to latin", "aécsõts", s);
42 }
43
44 /**
45 * Characters in the latin table override those in the ascii table, when
46 * it is requested.
47 */
48 @Test
49 public void testLatinOverride() {
50 TableTransliterator tr = new TableTransliterator("latin1");
51
52 String s = tr.transliterate("\u0401");
53 assertEquals("to latin with override", "Ë", s);
54 }
55
56 /**
57 * Not overridden by latin, when it is not requested.
58 */
59 @Test
60 public void testNotOverriden() {
61 TableTransliterator tr = new TableTransliterator("ascii");
62
63 String s = tr.transliterate("\u0401");
64 assertEquals("to latin with override", "Yo", s);
65 }
66 }