### Question:
QGramComparator implements Comparator { public double compare(String s1, String s2) { if (s1.equals(s2)) return 1.0; Set<String> q1 = tokenizer.qgrams(s1, q); Set<String> q2 = tokenizer.qgrams(s2, q); if (q1.isEmpty() || q2.isEmpty()) return 0.0; int common = 0; for (String gram : q1) if (q2.contains(gram)) common++; return formula.compute(common, q1, q2); } QGramComparator(); boolean isTokenized(); double compare(String s1, String s2); void setQ(int q); void setFormula(Formula formula); void setTokenizer(Tokenizer tokenizer);  }### Answer:
@Test public void testEmpty() { assertEquals(1.0, comp.compare("", "")); }
@Test public void testOneIsEmpty() { assertEquals(0.0, comp.compare("", "abc")); }
@Test public void testOneIsDifferent() { assertEquals((4.0 / 6.0), comp.compare("abc def", "cab def")); }
@Test public void testGail() { assertEquals((1.0 / 3.0), comp.compare("gail", "gayle")); }
@Test public void testKakadu() { assertEquals((1.0 / 2.0), comp.compare("kakadu", "cacadu")); }