From 1c01e36b0515a21098be5d0988ddc6d8b6d8326a Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Tue, 27 Aug 2013 16:29:03 +0100 Subject: [PATCH] eSpeakTests: Add VoiceVariantTest to test the VoiceVariant class. --- .../espeak/test/VoiceVariantTest.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 android/eSpeakTests/src/com/reecedunn/espeak/test/VoiceVariantTest.java diff --git a/android/eSpeakTests/src/com/reecedunn/espeak/test/VoiceVariantTest.java b/android/eSpeakTests/src/com/reecedunn/espeak/test/VoiceVariantTest.java new file mode 100644 index 00000000..b991f525 --- /dev/null +++ b/android/eSpeakTests/src/com/reecedunn/espeak/test/VoiceVariantTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Reece H. Dunn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.reecedunn.espeak.test; + +import android.test.AndroidTestCase; + +import com.reecedunn.espeak.SpeechSynthesis; +import com.reecedunn.espeak.VoiceVariant; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + +public class VoiceVariantTest extends AndroidTestCase +{ + public void testMaleVoiceVariant() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("male"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_ANY)); + assertThat(variant.toString(), is("male")); + } + + public void testFemaleVoiceVariant() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("female"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_ANY)); + assertThat(variant.toString(), is("female")); + } + + public void testNamedVoiceVariant() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt1"); + assertThat(variant.variant, is("klatt1")); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED)); + assertThat(variant.age, is(SpeechSynthesis.AGE_ANY)); + assertThat(variant.toString(), is("klatt1")); + } + + public void testMaleVoiceVariantYoung() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("male-young"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG)); + assertThat(variant.toString(), is("male-young")); + } + + public void testFemaleVoiceVariantYoung() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("female-young"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG)); + assertThat(variant.toString(), is("female-young")); + } + + public void testNamedVoiceVariantYoung() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt2-young"); + assertThat(variant.variant, is("klatt2")); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED)); + assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG)); + assertThat(variant.toString(), is("klatt2-young")); + } + + public void testMaleVoiceVariantOld() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("male-old"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_OLD)); + assertThat(variant.toString(), is("male-old")); + } + + public void testFemaleVoiceVariantOld() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("female-old"); + assertThat(variant.variant, is(nullValue())); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE)); + assertThat(variant.age, is(SpeechSynthesis.AGE_OLD)); + assertThat(variant.toString(), is("female-old")); + } + + public void testNamedVoiceVariantOld() + { + VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt3-old"); + assertThat(variant.variant, is("klatt3")); + assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED)); + assertThat(variant.age, is(SpeechSynthesis.AGE_OLD)); + assertThat(variant.toString(), is("klatt3-old")); + } +}