Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new test with a large file #10619

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@
import com.sun.star.beans.PropertyValue;
import com.sun.star.lang.Locale;
import com.sun.star.linguistic2.ProofreadingResult;
import com.sun.star.uno.XComponentContext;
import org.junit.Test;
import org.languagetool.openoffice.OfficeTools.LoErrorType;
import org.languagetool.rules.Rule;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -456,4 +467,33 @@ public void testCleanFootnotes() {
assertEquals(expected, SingleCheck.cleanFootnotes(input));
}

@Test
public void testLargeTextHandling() throws IOException {
try {
// Load the large_text.txt from the classpath
URL url = getClass().getResource("/large_text.txt");
assertNotNull("large_text.txt not found in classpath", url);
URI uri = url.toURI();
Path largeTextPath = Paths.get(uri);
String largeText = Files.readString(largeTextPath);

// Create a Main instance and set test mode
Main main = new Main(null);
main.setTestMode(true);

// Set up the locale
Locale locale = new Locale("qlt", "ES", "ca-ES-valencia");

// Perform proofreading on the large text
ProofreadingResult proofreadingResult = main.doProofreading("1", largeText, locale, 0, largeText.length(), new PropertyValue[0]);

// Assert that the proofreading result is not null
assertNotNull(proofreadingResult);
} catch (NoSuchFileException e) {
fail("File not found: " + e.getMessage());
} catch (URISyntaxException e) {
fail("Invalid URI: " + e.getMessage());
}
}

}
Loading