1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.mina.example.haiku;
20  
21  import junit.framework.TestCase;
22  
23  /**
24   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
25   */
26  public class PhraseUtilitiesTest extends TestCase {
27      public void testCountSyllablesInWord() throws Exception {
28          assertSyllableCount(1, "one");
29          assertSyllableCount(1, "I");
30          assertSyllableCount(1, "too");
31          assertSyllableCount(1, "why");
32          assertSyllableCount(1, "oh");
33          assertSyllableCount(1, "did");
34          assertSyllableCount(1, "sign");
35          assertSyllableCount(1, "up");
36          assertSyllableCount(1, "watch");
37          assertSyllableCount(1, "my");
38          assertSyllableCount(1, "what");
39          assertSyllableCount(1, "is");
40          assertSyllableCount(1, "wrong");
41          assertSyllableCount(1, "with");
42          assertSyllableCount(1, "me");
43          assertSyllableCount(1, "don't");
44          assertSyllableCount(1, "you");
45          assertSyllableCount(1, "love");
46          assertSyllableCount(2, "hassle");
47          assertSyllableCount(2, "oiling");
48          assertSyllableCount(2, "decide");
49          assertSyllableCount(2, "Michael");
50          assertSyllableCount(1, "I'm");
51          assertSyllableCount(1, "check");
52          assertSyllableCount(1, "out");
53          assertSyllableCount(1, "shirt");
54          assertSyllableCount(1, "bitch");
55          assertSyllableCount(1, "sucks");
56          assertSyllableCount(1, "James");
57          assertSyllableCount(2, "ex-wife");
58          assertSyllableCount(2, "airlines");
59          assertSyllableCount(3, "video");
60          assertSyllableCount(3, "fee-ee-ling");
61          assertSyllableCount(3, "unbuttoned");
62      }
63  
64      private static void assertSyllableCount(int count, String word) {
65          assertEquals("syllables in " + word, count, PhraseUtilities
66                  .countSyllablesInWord(word.toLowerCase()));
67      }
68  }