Index: trunk/lucene-search-2/test/org/wikimedia/lsearch/spell/SuggestUnitTest.java |
— | — | @@ -1,17 +1,17 @@ |
2 | 2 | package org.wikimedia.lsearch.spell; |
3 | 3 | |
4 | 4 | import java.io.IOException; |
5 | | -import java.util.HashMap; |
6 | 5 | import java.util.Map; |
7 | 6 | import java.util.TreeMap; |
8 | 7 | |
9 | 8 | import org.wikimedia.lsearch.config.IndexId; |
10 | 9 | import org.wikimedia.lsearch.search.NamespaceFilter; |
11 | | -import org.wikimedia.lsearch.search.SearcherCache; |
12 | 10 | import org.wikimedia.lsearch.spell.dist.EditDistance; |
13 | 11 | import org.wikimedia.lsearch.test.WikiTestCase; |
14 | 12 | |
15 | | -public class SuggestUnitTest extends WikiTestCase { |
| 13 | +public class SuggestUnitTest extends WikiTestCase |
| 14 | +{ |
| 15 | + |
16 | 16 | public void testMakeNamespaces() throws IOException { |
17 | 17 | IndexId iid = IndexId.get("entest"); |
18 | 18 | Suggest sug = new Suggest(iid); |
— | — | @@ -21,18 +21,37 @@ |
22 | 22 | assertEquals("[0, 100, 2, 4]",sug.makeNamespaces(new NamespaceFilter("0,2,4,100")).namespaces.toString()); |
23 | 23 | } |
24 | 24 | |
25 | | - public Map<Integer,Integer> getSpaceMap(String str1, String str2){ |
26 | | - EditDistance ed = new EditDistance(str1); |
27 | | - int d[][] = ed.getMatrix(str2); |
| 25 | + private Map<Integer,Integer> getSpaceMap(String str1, String str2){ |
| 26 | + EditDistance editDistance = new EditDistance(str1); |
| 27 | + int d[][] = editDistance.getMatrix(str2); |
| 28 | + |
28 | 29 | // map: space -> same space in edited string |
29 | 30 | TreeMap<Integer,Integer> spaceMap = new TreeMap<Integer,Integer>(); |
30 | 31 | new Suggest().extractSpaceMap(d,str1.length(),str2.length(),spaceMap,str1,str2); |
31 | 32 | return spaceMap; |
32 | 33 | } |
33 | | - |
34 | | - public void testExtractSpaceMap() throws IOException { |
| 34 | + |
| 35 | + /** |
| 36 | + * |
| 37 | + * @throws IOException |
| 38 | + */ |
| 39 | + public void testExtractSpaceMap1() throws IOException { |
35 | 40 | assertEquals("{}",getSpaceMap(".999","0 999").toString()); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * |
| 45 | + * @throws IOException |
| 46 | + */ |
| 47 | + public void testExtractSpaceMap2() throws IOException { |
36 | 48 | assertEquals("{4=3}",getSpaceMap("some string","som estring").toString()); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * |
| 53 | + * @throws IOException |
| 54 | + */ |
| 55 | + public void testExtractSpaceMap3() throws IOException { |
37 | 56 | assertEquals("",getSpaceMap(" a "," b ").toString()); |
38 | 57 | } |
39 | 58 | |