package de.danielnaber.languagetool.openoffice;

import junit.framework.TestCase;

import com.sun.star.lang.Locale;
import com.sun.star.linguistic2.ProofreadingResult;
import com.sun.star.beans.PropertyValue;

public class MainTest extends TestCase {
  
  public void testDoProofreading() {
    Main prog = new Main(null);
    final String testString = "To jest trudne zdanie. A to następne.  A to przedostatnie jest.\u0002 Test ostatniego.";
    final Locale plLoc = new Locale("pl", "PL", "");
    final PropertyValue[] prop = new PropertyValue[0];
    for (int i = 0; i<=testString.length(); i++) {
      ProofreadingResult paRes = prog.doProofreading("1", testString, plLoc, i, testString.length(), prop);
      assertEquals("1", paRes.aDocumentIdentifier);
      assertTrue(paRes.nStartOfNextSentencePosition >= i);
      if (i < "To jest trudne zdanie. ".length()) {
        assertEquals("To jest trudne zdanie. ".length(), paRes.nStartOfNextSentencePosition);
        assertEquals(0, paRes.nStartOfSentencePosition);
      }
    }
    ProofreadingResult paRes = prog.doProofreading("1", testString, plLoc, 0, testString.length(), prop);
    assertEquals("1", paRes.aDocumentIdentifier);
    assertEquals(23, paRes.nStartOfNextSentencePosition);
    assertEquals(0, paRes.nStartOfSentencePosition);
  }

}

@@ -1298,15 +1298,402 @@
 ition);%0A
+    //that was causing NPE but not anymore:%0A    String testString2 = %22To jest %E2%80%9Enowy problem%E2%80%9D. A to inny jeszcze( %E2%80%9Eproblem. Co jest %E2%80%9E?%22; %0A    paRes = prog.doProofreading(%221%22, testString2, plLoc, 0, testString2.length(), prop);%0A    assertEquals(%221%22, paRes.aDocumentIdentifier);%0A    assertEquals(24, paRes.nStartOfNextSentencePosition);%0A    assertEquals(0, paRes.nStartOfSentencePosition);%0A
   %7D%0A%0A%7D%0A

add test for this bug