OSDN Git Service

618cfe027f92808e05448b7d0fc75c1c71c48036
[mikutoga/TogaGem.git] / src / test / java / jp / sourceforge / mikutoga / typical / TypicalMorphTest.java
1 /*
2  */
3
4 package jp.sourceforge.mikutoga.typical;
5
6 import java.util.List;
7 import jp.sfjp.mikutoga.pmd.MorphType;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import static org.junit.Assert.*;
14
15 /**
16  *
17  */
18 public class TypicalMorphTest {
19
20     public TypicalMorphTest() {
21     }
22
23     @BeforeClass
24     public static void setUpClass() {
25     }
26
27     @AfterClass
28     public static void tearDownClass() {
29     }
30
31     @Before
32     public void setUp() {
33     }
34
35     @After
36     public void tearDown() {
37     }
38
39     /**
40      * Test of getTypedMorphList method, of class TypicalMorph.
41      */
42     @Test
43     public void testGetTypedMorphList() {
44         System.out.println("getTypedMorphList");
45
46         List<TypicalMorph> morphList;
47
48         morphList = TypicalMorph.getTypedMorphList(MorphType.EYEBROW);
49         assertEquals(6, morphList.size());
50
51         morphList = TypicalMorph.getTypedMorphList(MorphType.EYE);
52         assertEquals(7, morphList.size());
53
54         morphList = TypicalMorph.getTypedMorphList(MorphType.LIP);
55         assertEquals(12, morphList.size());
56
57         morphList = TypicalMorph.getTypedMorphList(MorphType.EXTRA);
58         assertEquals(2, morphList.size());
59
60         return;
61     }
62
63     /**
64      * Test of findWithPrimary method, of class TypicalMorph.
65      */
66     @Test
67     public void testFindWithPrimary() {
68         System.out.println("findWithPrimary");
69
70         TypicalMorph result;
71
72         result = TypicalMorph.findWithPrimary("あ");
73         assertNotNull(result);
74         assertEquals(MorphType.LIP, result.getMorphType());
75         assertEquals("あ", result.getTopPrimaryName());
76         assertEquals("a", result.getTopGlobalName());
77         assertEquals(1, result.getPrimaryList().size());
78         assertEquals("あ", result.getPrimaryList().get(0));
79         assertEquals(1, result.getGlobalList().size());
80         assertEquals("a", result.getGlobalList().get(0));
81
82         TypicalMorph result1;
83         TypicalMorph result2;
84
85         result1 = TypicalMorph.findWithPrimary("べー");
86         result2 = TypicalMorph.findWithPrimary("ぺろっ");
87         assertSame(result1, result2);
88         assertEquals(MorphType.EXTRA, result1.getMorphType());
89         assertEquals("べー", result1.getTopPrimaryName());
90         assertEquals("tongue", result1.getTopGlobalName());
91         assertEquals(2, result1.getPrimaryList().size());
92         assertEquals("べー", result1.getPrimaryList().get(0));
93         assertEquals("ぺろっ", result1.getPrimaryList().get(1));
94         assertEquals(1, result1.getGlobalList().size());
95         assertEquals("tongue", result1.getGlobalList().get(0));
96
97         return;
98     }
99
100     /**
101      * Test of findWithGlobal method, of class TypicalMorph.
102      */
103     @Test
104     public void testFindWithGlobal() {
105         System.out.println("findWithGlobal");
106
107         TypicalMorph result;
108
109         result = TypicalMorph.findWithGlobal("a");
110         assertNotNull(result);
111
112         TypicalMorph result2;
113         result2 = TypicalMorph.findWithPrimary("あ");
114
115         assertSame(result, result2);
116
117         return;
118     }
119
120     /**
121      * Test of primary2global method, of class TypicalMorph.
122      */
123     @Test
124     public void testPrimary2global() {
125         System.out.println("primary2global");
126
127         String result;
128
129         result = TypicalMorph.primary2global("あ");
130         assertEquals("a", result);
131
132         String result1;
133         String result2;
134
135         result1 = TypicalMorph.primary2global("べー");
136         result2 = TypicalMorph.primary2global("ぺろっ");
137         assertSame(result1, result2);
138
139         result1 = TypicalMorph.primary2global("ウィンク");
140         result2 = TypicalMorph.primary2global("ウィンク");
141         assertSame(result1, result2);
142
143         result = TypicalMorph.primary2global("XXX");
144         assertNull(result);
145
146         return;
147     }
148
149     /**
150      * Test of global2primary method, of class TypicalMorph.
151      */
152     @Test
153     public void testGlobal2primary() {
154         System.out.println("global2primary");
155
156         String result;
157
158         result = TypicalMorph.global2primary("a");
159         assertEquals("あ", result);
160
161         result = TypicalMorph.global2primary("tongue");
162         assertEquals("べー", result);
163
164         result = TypicalMorph.global2primary("XXX");
165         assertNull(result);
166
167         return;
168     }
169
170     /**
171      * Test of getMorphType method, of class TypicalMorph.
172      */
173     @Test
174     public void testGetMorphType() {
175         System.out.println("getMorphType");
176
177         List<TypicalMorph> morphList;
178
179         morphList = TypicalMorph.getTypedMorphList(MorphType.EYEBROW);
180
181         for(TypicalMorph morph : morphList){
182             MorphType type = morph.getMorphType();
183             assertEquals(MorphType.EYEBROW, type);
184         }
185
186         morphList = TypicalMorph.getTypedMorphList(MorphType.EYE);
187
188         for(TypicalMorph morph : morphList){
189             MorphType type = morph.getMorphType();
190             assertEquals(MorphType.EYE, type);
191         }
192
193         morphList = TypicalMorph.getTypedMorphList(MorphType.LIP);
194
195         for(TypicalMorph morph : morphList){
196             MorphType type = morph.getMorphType();
197             assertEquals(MorphType.LIP, type);
198         }
199
200         morphList = TypicalMorph.getTypedMorphList(MorphType.EXTRA);
201
202         for(TypicalMorph morph : morphList){
203             MorphType type = morph.getMorphType();
204             assertEquals(MorphType.EXTRA, type);
205         }
206
207         return;
208     }
209
210 }