/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.commons.codec.language;
import junit.framework.Assert;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;
import org.apache.commons.codec.StringEncoderAbstractTest;
/**
* @author Apache Software Foundation
* @version $Id: CaverphoneTest.java 1078234 2011-03-05 04:25:51Z ggregory $
*/
public class CaverphoneTest extends StringEncoderAbstractTest {
public CaverphoneTest(String name) {
super(name);
}
protected StringEncoder createStringEncoder() {
return new Caverphone();
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* AT11111111 words: add, aid, at, art, eat, earth, head, hit, hot, hold, hard, heart, it, out, old
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderException {
this.checkEncodingVariations("AT11111111", new String[]{
"add",
"aid",
"at",
"art",
"eat",
"earth",
"head",
"hit",
"hot",
"hold",
"hard",
"heart",
"it",
"out",
"old"});
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedExamples() throws EncoderException {
String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}};
this.checkEncodings(data);
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderException {
this.checkEncodingVariations("KLN1111111", new String[]{
"Cailean",
"Calan",
"Calen",
"Callahan",
"Callan",
"Callean",
"Carleen",
"Carlen",
"Carlene",
"Carlin",
"Carline",
"Carlyn",
"Carlynn",
"Carlynne",
"Charlean",
"Charleen",
"Charlene",
"Charline",
"Cherlyn",
"Chirlin",
"Clein",
"Cleon",
"Cline",
"Cohleen",
"Colan",
"Coleen",
"Colene",
"Colin",
"Colleen",
"Collen",
"Collin",
"Colline",
"Colon",
"Cullan",
"Cullen",
"Cullin",
"Gaelan",
"Galan",
"Galen",
"Garlan",
"Garlen",
"Gaulin",
"Gayleen",
"Gaylene",
"Giliane",
"Gillan",
"Gillian",
"Glen",
"Glenn",
"Glyn",
"Glynn",
"Gollin",
"Gorlin",
"Kalin",
"Karlan",
"Karleen",
"Karlen",
"Karlene",
"Karlin",
"Karlyn",
"Kaylyn",
"Keelin",
"Kellen",
"Kellene",
"Kellyann",
"Kellyn",
"Khalin",
"Kilan",
"Kilian",
"Killen",
"Killian",
"Killion",
"Klein",
"Kleon",
"Kline",
"Koerlin",
"Kylen",
"Kylynn",
"Quillan",
"Quillon",
"Qulllon",
"Xylon"});
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderException {
this.checkEncodingVariations("TN11111111", new String[]{
"Dan",
"Dane",
"Dann",
"Darn",
"Daune",
"Dawn",
"Ddene",
"Dean",
"Deane",
"Deanne",
"DeeAnn",
"Deeann",
"Deeanne",
"Deeyn",
"Den",
"Dene",
"Denn",
"Deonne",
"Diahann",
"Dian",
"Diane",
"Diann",
"Dianne",
"Diannne",
"Dine",
"Dion",
"Dione",
"Dionne",
"Doane",
"Doehne",
"Don",
"Donn",
"Doone",
"Dorn",
"Down",
"Downe",
"Duane",
"Dun",
"Dunn",
"Duyne",
"Dyan",
"Dyane",
"Dyann",
"Dyanne",
"Dyun",
"Tan",
"Tann",
"Teahan",
"Ten",
"Tenn",
"Terhune",
"Thain",
"Thaine",
"Thane",
"Thanh",
"Thayne",
"Theone",
"Thin",
"Thorn",
"Thorne",
"Thun",
"Thynne",
"Tien",
"Tine",
"Tjon",
"Town",
"Towne",
"Turne",
"Tyne"});
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderException {
this.checkEncodingVariations("TTA1111111", new String[]{
"Darda",
"Datha",
"Dedie",
"Deedee",
"Deerdre",
"Deidre",
"Deirdre",
"Detta",
"Didi",
"Didier",
"Dido",
"Dierdre",
"Dieter",
"Dita",
"Ditter",
"Dodi",
"Dodie",
"Dody",
"Doherty",
"Dorthea",
"Dorthy",
"Doti",
"Dotti",
"Dottie",
"Dotty",
"Doty",
"Doughty",
"Douty",
"Dowdell",
"Duthie",
"Tada",
"Taddeo",
"Tadeo",
"Tadio",
"Tati",
"Teador",
"Tedda",
"Tedder",
"Teddi",
"Teddie",
"Teddy",
"Tedi",
"Tedie",
"Teeter",
"Teodoor",
"Teodor",
"Terti",
"Theda",
"Theodor",
"Theodore",
"Theta",
"Thilda",
"Thordia",
"Tilda",
"Tildi",
"Tildie",
"Tildy",
"Tita",
"Tito",
"Tjader",
"Toddie",
"Toddy",
"Torto",
"Tuddor",
"Tudor",
"Turtle",
"Tuttle",
"Tutto"});
}
/**
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
*
* @throws EncoderException
*/
public void testCaverphoneRevisitedRandomWords() throws EncoderException {
this.checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"});
this.checkEncoding("SSA1111111", "social");
this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"});
}
public void testEndMb() throws EncoderException {
String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
this.checkEncodings(data);
}
// Caverphone Revisited
public void testIsCaverphoneEquals() {
Caverphone caverphone = new Caverphone();
Assert.assertFalse("Caverphone encodings should not be equal", caverphone.isCaverphoneEqual("Peter", "Stevenson"));
Assert.assertTrue("Caverphone encodings should be equal", caverphone.isCaverphoneEqual("Peter", "Peady"));
}
public void testSpecificationExamples() throws EncoderException {
String[][] data = {
{"Peter", "PTA1111111"},
{"ready", "RTA1111111"},
{"social", "SSA1111111"},
{"able", "APA1111111"},
{"Tedder", "TTA1111111"},
{"Karleen", "KLN1111111"},
{"Dyun", "TN11111111"}};
this.checkEncodings(data);
}
}