allow single quote " ' " in query

see http://mantis.tokeek.de/view.php?id=379
-add QueryGoal test case for this
pull/1/head
reger 10 years ago
parent f76d81f5c9
commit e88537522d

@ -52,7 +52,7 @@ public class QueryGoal {
private static char space = ' '; private static char space = ' ';
private static char sq = '\''; private static char sq = '\'';
private static char dq = '"'; private static char dq = '"';
private static String seps = ".:;#'*`,!$%()=?^<>/&_"; private static String seps = ".:;#*`,!$%()=?^<>/&_";
public String query_original; public String query_original;
private HandleSet include_hashes, exclude_hashes; private HandleSet include_hashes, exclude_hashes;

@ -0,0 +1,38 @@
package net.yacy.search.query;
import java.util.HashMap;
import java.util.Iterator;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class QueryGoalTest {
/**
* Test of getIncludeString method, of class QueryGoal.
*/
@Test
public void testGetIncludeString() {
HashMap<String, String[]> testdata = new HashMap<String, String[]>();
// Prameter: (Query, [result_term1, result_term2 ..])
testdata.put("O'Reily's book", new String[]{"o'reily's", "book"});
testdata.put("\"O'Reily's book\"", new String[]{"o'reily's book"}); // quoted term
testdata.put("\"O'Reily's\" +book", new String[]{"o'reily's", "book"}); // +word
testdata.put("Umphrey's + McGee", new String[]{"umphrey's", "mcgee"});
testdata.put("'The Book' library", new String[]{"the book","library"}); //single quoted term
for (String testquery : testdata.keySet()) {
QueryGoal qg = new QueryGoal(testquery); // get test query
String[] singlestr = testdata.get(testquery); // get result strings
Iterator<String> it = qg.getIncludeStrings();
int i = 0;
while (it.hasNext()) {
String s = it.next();
System.out.println(singlestr[i] + " = " + s);
assertEquals(s, singlestr[i]);
i++;
}
}
}
}
Loading…
Cancel
Save