/* LanguageTool, a natural language style checker
 * Copyright (C) 2017 Daniel Naber (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.rules.de;

import org.junit.Test;
import org.languagetool.JLanguageTool;
import org.languagetool.Language;
import org.languagetool.Languages;
import org.languagetool.TestTools;

import java.io.IOException;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

public class GermanWordRepeatRuleTest {
  
  @Test
  public void testRule() throws IOException {
    Language german = Languages.getLanguageForShortCode("de");
    GermanWordRepeatRule rule = new GermanWordRepeatRule(TestTools.getEnglishMessages(), german);
    JLanguageTool lt = new JLanguageTool(german);
    assertThat(rule.match(lt.getAnalyzedSentence("Das ist gut so.")).length, is(0));
    assertThat(rule.match(lt.getAnalyzedSentence("Das ist ist gut so.")).length, is(1));
    assertThat(rule.match(lt.getAnalyzedSentence("Der der Mann")).length, is(1));
    assertThat(rule.match(lt.getAnalyzedSentence("Warum fragen Sie sie nicht selbst?")).length, is(0));
    assertThat(rule.match(lt.getAnalyzedSentence("Er will nur sein Leben leben.")).length, is(0));
    assertThat(rule.match(lt.getAnalyzedSentence("Wie bei Honda, die die Bezahlung erhöht haben.")).length, is(0));
    assertThat(rule.match(lt.getAnalyzedSentence("Dann warfen sie sie weg.")).length, is(0));
    assertThat(rule.match(lt.getAnalyzedSentence("Dann konnte sie sie sehen.")).length, is(0));
  }

}
@@ -2231,14 +2231,280 @@
 is(0));%0A
+    assertThat(rule.match(lt.getAnalyzedSentence(%22Hat sie sie%22)).length, is(1));  // used to crash, issue #1010%0A    assertThat(rule.match(lt.getAnalyzedSentence(%22Hat hat%22)).length, is(1));%0A    assertThat(rule.match(lt.getAnalyzedSentence(%22hat hat%22)).length, is(1));%0A
   %7D%0A%0A%7D

add test for fix for #1010