View Javadoc

    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 static org.junit.Assert.assertEquals;
    22
    23  import org.junit.Test;
    24
    25  /**
    26   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
    27   */
    28  public class PhraseUtilitiesTest {
    29      @Test
    30      public void testCountSyllablesInWord() throws Exception {
    31          assertSyllableCount(1, "one");
    32          assertSyllableCount(1, "I");
    33          assertSyllableCount(1, "too");
    34          assertSyllableCount(1, "why");
    35          assertSyllableCount(1, "oh");
    36          assertSyllableCount(1, "did");
    37          assertSyllableCount(1, "sign");
    38          assertSyllableCount(1, "up");
    39          assertSyllableCount(1, "watch");
    40          assertSyllableCount(1, "my");
    41          assertSyllableCount(1, "what");
    42          assertSyllableCount(1, "is");
    43          assertSyllableCount(1, "wrong");
    44          assertSyllableCount(1, "with");
    45          assertSyllableCount(1, "me");
    46          assertSyllableCount(1, "don't");
    47          assertSyllableCount(1, "you");
    48          assertSyllableCount(1, "love");
    49          assertSyllableCount(2, "hassle");
    50          assertSyllableCount(2, "oiling");
    51          assertSyllableCount(2, "decide");
    52          assertSyllableCount(2, "Michael");
    53          assertSyllableCount(1, "I'm");
    54          assertSyllableCount(1, "check");
    55          assertSyllableCount(1, "out");
    56          assertSyllableCount(1, "shirt");
    57          assertSyllableCount(1, "bitch");
    58          assertSyllableCount(1, "sucks");
    59          assertSyllableCount(1, "James");
    60          assertSyllableCount(2, "ex-wife");
    61          assertSyllableCount(2, "airlines");
    62          assertSyllableCount(3, "video");
    63          assertSyllableCount(3, "fee-ee-ling");
    64          assertSyllableCount(3, "unbuttoned");
    65      }
    66
    67      private static void assertSyllableCount(int count, String word) {
    68          assertEquals("syllables in " + word, count, PhraseUtilities
    69                  .countSyllablesInWord(word.toLowerCase()));
    70      }
    71  }