PageRenderTime 62ms CodeModel.GetById 38ms app.highlight 5ms RepoModel.GetById 17ms app.codeStats 0ms

/java/src/test/java/SpellingCorrectorTest.java

https://github.com/kbaribeau/Spelling-Corrector
Java | 57 lines | 41 code | 16 blank | 0 comment | 0 complexity | ac4dfe8da953a19d0dda86fbf94b1ead MD5 | raw file
 1import java.util.HashSet;
 2import java.util.Set;
 3
 4import org.junit.Test;
 5import static org.junit.Assert.*;
 6
 7public class SpellingCorrectorTest {
 8	SpellingCorrector spellingCorrector = new SpellingCorrector();
 9
10	@Test
11	public void shouldReturnDeletions() throws Exception {
12		Set<String> words = new HashSet<String>();
13		words.add("he");
14		words.add("te");
15		words.add("th");
16	
17		assertEquals(words, spellingCorrector.applySingleCharacterDeletions("the"));
18	}
19
20	@Test
21	public void shouldReturnTranspositions() throws Exception {
22		Set<String> words = new HashSet<String>();
23		words.add("etst");
24		words.add("tset");
25		words.add("tets");
26
27		assertEquals(words, spellingCorrector.applyTranspositions("test"));
28	}
29	
30	@Test
31	public void shouldReturnAlterations() throws Exception {
32		assertEquals(101, spellingCorrector.applyOneLetterTypeos("test").size());
33	}
34	
35	
36	@Test
37	public void shouldReturnInserts() throws Exception {
38		assertEquals(126, spellingCorrector.applyInserts("test").size());
39	}
40	
41	@Test
42	public void shouldReturnTheCorrectWord() throws Exception {
43		assertEquals("access", spellingCorrector.correct("acess"));
44		assertEquals("access", spellingCorrector.correct("access"));
45		assertEquals("causing", spellingCorrector.correct("acesing"));
46		assertEquals("heard", spellingCorrector.correct("heare"));
47		assertEquals("carry", spellingCorrector.correct("carr"));
48		assertEquals("forbidden", spellingCorrector.correct("forbiden"));
49		assertEquals("house", spellingCorrector.correct("hoyse"));
50	}
51	
52
53	
54
55	
56
57}