001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.mina.example.haiku;
020
021import static org.junit.Assert.assertEquals;
022
023import org.junit.Test;
024
025/**
026 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
027 */
028public class PhraseUtilitiesTest {
029    @Test
030    public void testCountSyllablesInWord() throws Exception {
031        assertSyllableCount(1, "one");
032        assertSyllableCount(1, "I");
033        assertSyllableCount(1, "too");
034        assertSyllableCount(1, "why");
035        assertSyllableCount(1, "oh");
036        assertSyllableCount(1, "did");
037        assertSyllableCount(1, "sign");
038        assertSyllableCount(1, "up");
039        assertSyllableCount(1, "watch");
040        assertSyllableCount(1, "my");
041        assertSyllableCount(1, "what");
042        assertSyllableCount(1, "is");
043        assertSyllableCount(1, "wrong");
044        assertSyllableCount(1, "with");
045        assertSyllableCount(1, "me");
046        assertSyllableCount(1, "don't");
047        assertSyllableCount(1, "you");
048        assertSyllableCount(1, "love");
049        assertSyllableCount(2, "hassle");
050        assertSyllableCount(2, "oiling");
051        assertSyllableCount(2, "decide");
052        assertSyllableCount(2, "Michael");
053        assertSyllableCount(1, "I'm");
054        assertSyllableCount(1, "check");
055        assertSyllableCount(1, "out");
056        assertSyllableCount(1, "shirt");
057        assertSyllableCount(1, "bitch");
058        assertSyllableCount(1, "sucks");
059        assertSyllableCount(1, "James");
060        assertSyllableCount(2, "ex-wife");
061        assertSyllableCount(2, "airlines");
062        assertSyllableCount(3, "video");
063        assertSyllableCount(3, "fee-ee-ling");
064        assertSyllableCount(3, "unbuttoned");
065    }
066
067    private static void assertSyllableCount(int count, String word) {
068        assertEquals("syllables in " + word, count, PhraseUtilities
069                .countSyllablesInWord(word.toLowerCase()));
070    }
071}