r108959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108958‎ | r108959 | r108960 >
Date:05:38, 15 January 2012
Author:oren
Status:deferred
Tags:
Comment:
Increased test granularity to isolate the failures
Modified paths:
  • /trunk/lucene-search-2/test/org/wikimedia/lsearch/spell/SuggestUnitTest.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-2/test/org/wikimedia/lsearch/spell/SuggestUnitTest.java
@@ -1,17 +1,17 @@
22 package org.wikimedia.lsearch.spell;
33
44 import java.io.IOException;
5 -import java.util.HashMap;
65 import java.util.Map;
76 import java.util.TreeMap;
87
98 import org.wikimedia.lsearch.config.IndexId;
109 import org.wikimedia.lsearch.search.NamespaceFilter;
11 -import org.wikimedia.lsearch.search.SearcherCache;
1210 import org.wikimedia.lsearch.spell.dist.EditDistance;
1311 import org.wikimedia.lsearch.test.WikiTestCase;
1412
15 -public class SuggestUnitTest extends WikiTestCase {
 13+public class SuggestUnitTest extends WikiTestCase
 14+{
 15+
1616 public void testMakeNamespaces() throws IOException {
1717 IndexId iid = IndexId.get("entest");
1818 Suggest sug = new Suggest(iid);
@@ -21,18 +21,37 @@
2222 assertEquals("[0, 100, 2, 4]",sug.makeNamespaces(new NamespaceFilter("0,2,4,100")).namespaces.toString());
2323 }
2424
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+
2829 // map: space -> same space in edited string
2930 TreeMap<Integer,Integer> spaceMap = new TreeMap<Integer,Integer>();
3031 new Suggest().extractSpaceMap(d,str1.length(),str2.length(),spaceMap,str1,str2);
3132 return spaceMap;
3233 }
33 -
34 - public void testExtractSpaceMap() throws IOException {
 34+
 35+ /**
 36+ *
 37+ * @throws IOException
 38+ */
 39+ public void testExtractSpaceMap1() throws IOException {
3540 assertEquals("{}",getSpaceMap(".999","0 999").toString());
 41+ }
 42+
 43+ /**
 44+ *
 45+ * @throws IOException
 46+ */
 47+ public void testExtractSpaceMap2() throws IOException {
3648 assertEquals("{4=3}",getSpaceMap("some string","som estring").toString());
 49+ }
 50+
 51+ /**
 52+ *
 53+ * @throws IOException
 54+ */
 55+ public void testExtractSpaceMap3() throws IOException {
3756 assertEquals("",getSpaceMap(" a "," b ").toString());
3857 }
3958

Status & tagging log