/test/spelling/corrector/SpellingCorrectorTest.java

https://github.com/juliengrenier/java-spelling-corrector · Java · 29 lines · 23 code · 6 blank · 0 comment · 0 complexity · bd079eb0a9e84b09b936a82fc7526770 MD5 · raw file

  1. package spelling.corrector;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.util.Locale;
  5. import junit.framework.TestCase;
  6. import spelling.dictionary.Dictionary;
  7. public abstract class SpellingCorrectorTest extends TestCase {
  8. public final void testCorrect(){
  9. try {
  10. Dictionary.load(Locale.ENGLISH, new File("holmes.txt"));
  11. SpellingCorrector sp = getSpellingCorrector();
  12. String correction = sp.correct("speling");
  13. assertEquals("spelling", correction);
  14. correction = sp.correct(null);
  15. assertEquals("", correction);
  16. correction = sp.correct("");
  17. assertEquals("", correction);
  18. } catch (IOException e) {
  19. fail(e.getMessage());
  20. }
  21. }
  22. abstract protected SpellingCorrector getSpellingCorrector();
  23. }