### Question:
NumericComparator implements Comparator { public double compare(String v1, String v2) { double d1; double d2; try { d1 = Double.parseDouble(v1); d2 = Double.parseDouble(v2); } catch (NumberFormatException e) { return 0.5; } if (d1 == 0.0 && d2 == 0.0) return 1.0; if (d1 < 0.0 && d2 < 0.0) { d1 *= -1.0; d2 *= -1.0; } if (d2 < d1) { double tmp = d2; d2 = d1; d1 = tmp; } double ratio = d1 / d2; if (ratio < minratio) return 0.0; else return ratio; }  boolean isTokenized(); void setMinRatio(double minratio); double compare(String v1, String v2);  }### Answer:
@Test public void testEqual() { assertEquals(1.0, comp.compare("42", "42")); }
@Test public void testEqual2() { assertEquals(1.0, comp.compare("42.0", "42.0")); }
@Test public void testHalf() { assertEquals(0.5, comp.compare("21.0", "42.0")); }
@Test public void testHalfInverted() { assertEquals(0.5, comp.compare("42.0", "21.0")); }
@Test public void testZero() { assertEquals(1.0, comp.compare("0.0", "0.0")); }
@Test public void testFirstIsZero() { assertEquals(0.0, comp.compare("0.0", "42.0")); }
@Test public void testSecondIsZero() { assertEquals(0.0, comp.compare("42.0", "0.0")); }
@Test public void testOneNegativeOnePositive() { assertEquals(0.0, comp.compare("-1", "2")); }
@Test public void testNegativeNumbers() { assertEquals(0.5, comp.compare("-1", "-2")); assertEquals(0.5, comp.compare("-2", "-1")); }