/*
 * 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.bm;

import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 * Tests guessLanguages API.
 *
 * @since 1.6
 */
@RunWith(Parameterized.class)
public class LanguageGuessingTest {

    private static String EXACT = "exact";
    private static String ONE_OF = "one of";

    @Parameterized.Parameters(name = "{0}-{1}-{2}")
    public static List<Object[]> data() {
        return Arrays.asList(new Object[][] {
                { "Renault", "french", EXACT },
                { "Mickiewicz", "polish", EXACT },
                { "Thompson", "english", ONE_OF }, // this also hits german and greeklatin
                { "Nu\u00f1ez", "spanish", EXACT }, // Nuñez
                { "Carvalho", "portuguese", EXACT },
                { "\u010capek", "czech", EXACT }, // Čapek
                { "Sjneijder", "dutch", EXACT },
                { "Klausewitz", "german", EXACT },
                { "K\u00fc\u00e7\u00fck", "turkish", EXACT }, // Küçük
                { "Giacometti", "italian", EXACT },
                { "Nagy", "hungarian", EXACT },
                { "Ceau\u015fescu", "romanian", EXACT }, // Ceauşescu
                { "Angelopoulos", "greeklatin", EXACT },
                { "\u0391\u03b3\u03b3\u03b5\u03bb\u03cc\u03c0\u03bf\u03c5\u03bb\u03bf\u03c2", "greek", EXACT }, // Αγγελόπουλος
                { "\u041f\u0443\u0448\u043a\u0438\u043d", "cyrillic", EXACT }, // Пушкин
                { "\u05db\u05d4\u05df", "hebrew", EXACT }, // כהן
                { "\u00e1cz", "any", EXACT }, // ácz
                { "\u00e1tz", "any", EXACT } }); // átz
    }

    private final Lang lang = Lang.instance(NameType.GENERIC);
    private final String language;
    private final String name;

    public LanguageGuessingTest(final String name, final String language) {
        this.name = name;
        this.language = language;
    }

    @Test
    public void testLanguageGuessing() {
        final Languages.LanguageSet guesses = this.lang.guessLanguages(this.name);

        assertTrue("language predicted for name '" + this.name + "' is wrong: " + guesses + " should contain '" + this.language + "'",
                guesses.contains(this.language));

    }
}

@@ -1421,23 +1421,16 @@
 %22french%22
-, EXACT
  %7D,%0A    
@@ -1465,23 +1465,16 @@
 %22polish%22
-, EXACT
  %7D,%0A    
@@ -1512,16 +1512,8 @@
 ish%22
-, ONE_OF
  %7D, 
@@ -1589,31 +1589,24 @@
 %22, %22spanish%22
-, EXACT
  %7D, // Nu%C3%B1ez
@@ -1648,23 +1648,16 @@
 tuguese%22
-, EXACT
  %7D,%0A    
@@ -1691,23 +1691,16 @@
  %22czech%22
-, EXACT
  %7D, // %C4%8C
@@ -1742,23 +1742,16 @@
  %22dutch%22
-, EXACT
  %7D,%0A    
@@ -1786,23 +1786,16 @@
 %22german%22
-, EXACT
  %7D,%0A    
@@ -1841,23 +1841,16 @@
 turkish%22
-, EXACT
  %7D, // K
@@ -1891,31 +1891,24 @@
 %22, %22italian%22
-, EXACT
  %7D,%0A        
@@ -1936,23 +1936,16 @@
 ngarian%22
-, EXACT
  %7D,%0A    
@@ -1986,23 +1986,16 @@
 omanian%22
-, EXACT
  %7D, // C
@@ -2049,23 +2049,16 @@
 eklatin%22
-, EXACT
  %7D,%0A    
@@ -2154,23 +2154,16 @@
  %22greek%22
-, EXACT
  %7D, // %CE%91
@@ -2242,23 +2242,16 @@
 yrillic%22
-, EXACT
  %7D, // %D0%9F
@@ -2304,23 +2304,16 @@
 %22hebrew%22
-, EXACT
  %7D, // %D7%9B
@@ -2350,23 +2350,16 @@
 %22, %22any%22
-, EXACT
  %7D, // %C3%A1
@@ -2400,15 +2400,8 @@
 any%22
-, EXACT
  %7D %7D

Remove unused field.